Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(streaming): fix force-append-only sink panicking #8155

Merged
merged 3 commits into from
Feb 24, 2023
Merged

Conversation

xx01cyx
Copy link
Contributor

@xx01cyx xx01cyx commented Feb 23, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

  • Fix the bug that the force-append-only sink panics on data chunks full of DELETE messages.
  • Modify the timing of txn starting accordingly.
  • Convert UPDATE INSERT messages into INSERT messages instead of dropping them.

Checklist For Contributors

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

  • My PR DOES NOT contain user-facing changes.
Click here for Documentation

Types of user-facing changes

Please keep the types that apply to your changes, and remove the others.

  • Installation and deployment
  • Connector (sources & sinks)
  • SQL commands, functions, and operators
  • RisingWave cluster configuration changes
  • Other (please specify in the release note below)

Release note

@github-actions github-actions bot added the type/fix Bug fix label Feb 23, 2023
@codecov
Copy link

codecov bot commented Feb 23, 2023

Codecov Report

Merging #8155 (2363409) into main (4453ae1) will increase coverage by 0.09%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #8155      +/-   ##
==========================================
+ Coverage   71.63%   71.73%   +0.09%     
==========================================
  Files        1133     1133              
  Lines      182211   182210       -1     
==========================================
+ Hits       130530   130704     +174     
+ Misses      51681    51506     -175     
Flag Coverage Δ
rust 71.73% <100.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/stream/src/executor/sink.rs 62.30% <100.00%> (+62.30%) ⬆️
src/batch/src/task/task_execution.rs 51.62% <0.00%> (-0.51%) ⬇️
src/object_store/src/object/mem.rs 86.87% <0.00%> (-0.39%) ⬇️
src/object_store/src/object/mod.rs 48.65% <0.00%> (-0.21%) ⬇️
src/storage/src/hummock/sstable_store.rs 64.77% <0.00%> (-0.16%) ⬇️
src/meta/src/hummock/manager/mod.rs 77.83% <0.00%> (+0.06%) ⬆️
src/storage/src/hummock/compactor/mod.rs 80.69% <0.00%> (+0.19%) ⬆️
src/common/src/types/ordered_float.rs 31.06% <0.00%> (+0.19%) ⬆️
src/meta/src/hummock/mock_hummock_meta_client.rs 65.46% <0.00%> (+1.03%) ⬆️
src/connector/src/sink/console.rs 90.37% <0.00%> (+4.27%) ⬆️
... and 3 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@fuyufjh fuyufjh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM

@@ -55,17 +55,18 @@ async fn build_sink(
}

// Drop all the UPDATE/DELETE messages in this chunk.
fn force_append_only(chunk: StreamChunk, data_types: Vec<DataType>) -> StreamChunk {
fn force_append_only(chunk: StreamChunk, data_types: Vec<DataType>) -> Option<StreamChunk> {
let mut builder = DataChunkBuilder::new(data_types, chunk.cardinality() + 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big problem by why + 1? 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some implementation details: DataChunkBuilder will return a chunk once the number of rows reaches its size. But instead of this early return, we want it to return at the end of this function. This +1 is to avoid this early return.

@@ -55,17 +55,18 @@ async fn build_sink(
}

// Drop all the UPDATE/DELETE messages in this chunk.
fn force_append_only(chunk: StreamChunk, data_types: Vec<DataType>) -> StreamChunk {
fn force_append_only(chunk: StreamChunk, data_types: Vec<DataType>) -> Option<StreamChunk> {
let mut builder = DataChunkBuilder::new(data_types, chunk.cardinality() + 1);
for (op, row_ref) in chunk.rows() {
if op == Op::Insert {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So Update events are ignored. Previously I thought the insert part of update would be kept. Did we have any discussion on that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, keeping UpdateInsert means keeping the UPDATE operation, which doesn't conform with the semantics of "append-only". cc. @tabVersion @st1page

Copy link
Contributor

@st1page st1page Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think eric means we should convert UpdateInsert into Insert here. I weakly +1 and it makes sense to me. And user can get the latest data.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with @fuyufjh and @st1page , we map UpdateInsert to Insert and ignore UpdateDelete & Delete.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in this PR.

@mergify mergify bot merged commit 26de7bd into main Feb 24, 2023
@mergify mergify bot deleted the cyx/fix-sink-panic branch February 24, 2023 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/fix Bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants