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(sink): align init epoch for coordinated sinks #20598

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wenym1
Copy link
Contributor

@wenym1 wenym1 commented Feb 25, 2025

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

What's changed and what's your intention?

Resolve #19337

In coordinated sinks, different parallelisms coordinate with each other by their epoch progress. More specifically, they should write the data of the same epoch simultaneously, and then commit together on the epoch, and then write the same epoch truncate offset to storage. Since different parallelisms should work on the same epoch, we need to ensure that after recovery they are initialized from the same epoch. However, in sink log store, since we only need to ensure at-least-once delivery, the truncation offset set by log reader is not guaranteed to be applied and written to persistent storage. This works for normal sinks in which different parallelisms work independently. But for coordinated sink, it may happen that, for example, the truncate offset on epoch1 of parallelism1 is applied to storage, but on parallelism2, the offset is not applied. After recovery, parallelism1 will be initialized from the next epoch of epoch1, but parallelism2 will still be initialized from epoch1, and then the two parallelisms won't be initialized at the same epoch, and then cause error in #19337.

In this PR, we introduce a flag to KvLogStoreFactory named align_epoch_on_init. The flag will be set to true for coordinated sinks. When this feature is on, in initialization, we won't use left unbounded to read the historical stream. Instead, we will load the truncate offset globally from all vnodes from the committed snapshot, and use the latest truncate offset as the left bound to read historical stream. In the example above, parallelism2 can see that some other parallelisms have written truncate offset on epoch1, and then it will skip epoch1 and initialize from the next epoch, though itself never writes the truncate offset yet.

Checklist

  • I have written necessary rustdoc comments.
  • I have added necessary unit tests and integration tests.
  • I have added test labels as necessary.
  • I have added fuzzing tests or opened an issue to track them.
  • My PR contains breaking changes.
  • My PR changes performance-critical code, so I will run (micro) benchmarks and present the results.
  • My PR contains critical fixes that are necessary to be merged into the latest release.

Documentation

  • My PR needs documentation updates.
Release note

@wenym1 wenym1 force-pushed the yiming/align-init-epoch-coordinated-sink branch from 5752fff to 65b11a7 Compare February 25, 2025 08:50
Copy link
Contributor

@chenzl25 chenzl25 left a comment

Choose a reason for hiding this comment

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

LGTM!

@wenym1 wenym1 enabled auto-merge February 25, 2025 10:46
@wenym1 wenym1 added this pull request to the merge queue Feb 25, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CoordinatorWorker received CommitRequests with different epochs when collecting metadata from SinkWriters
2 participants