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

refactor(stream): own and recreate shared context and local barrier manager in recovery #15157

Merged
merged 12 commits into from
Feb 27, 2024

Conversation

wenym1
Copy link
Contributor

@wenym1 wenym1 commented Feb 20, 2024

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

What's changed and what's your intention?

Currently we have SharedContext and LocalBarrierManager that are created at CN initialization and then exists in long run. SharedContext is for actors to communicate and exchange information, and it gets cleared in every recovery. LocalBarrierManager is used for actors to send barrier related event to barrier worker loop via a channel. However, the same channel is still used after recovery, and it's possible that there is some stale actor events sent after the reset event are stored in the channel and get handled after recovery, which may caused bug. Therefore, the LocalBarrierManager should also be cleared in recovery.

Since both SharedContext and LocalBarrierManager should be cleared in recovery, it's better to just recreate them and let the actors created after recovery to use the new ones. Therefore, in this PR, we change to own the shared context and local barrier manager in the barrier worker loop, and we will recreate them in recovery.

The current LocalBarrierEvent mixes the events reported by actor and the requests sent from stream manager. In this PR we split the request sent from stream manager to a separate enum named LocalActorOperation. The stream manager no longer send request via LocalBarrierManager, but instead holds its own channel to send request to local barrier worker loop. The LocalBarrierManager is owned in the barrier worker loop, and pass to actor during actor creation.

Previously the stream manager also holds a reference to SharedContext to handle some rpc request. In this PR we change to handle the rpc request via sending a request to barrier worker loop and wait for result.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

Copy link
Contributor

@zwang28 zwang28 left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 30 to 34
query T
select * from v
except
select * from mv;
----
Copy link
Member

Choose a reason for hiding this comment

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

I think we can still keep this one. 😄

manager
.send_barrier(barrier.clone(), actor_ids_to_send, actor_ids_to_collect)
actor_op_tx
.send_and_await(|tx| LocalActorOperation::InjectBarrier {
Copy link
Member

Choose a reason for hiding this comment

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

Can we still extracting it as a method? Same for AwaitEpochCommited.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@wenym1 wenym1 requested a review from BugenZhao February 27, 2024 06:22
@wenym1 wenym1 added this pull request to the merge queue Feb 27, 2024
Copy link
Member

@yezizp2012 yezizp2012 left a comment

Choose a reason for hiding this comment

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

LGTM

Merged via the queue into main with commit da06fa2 Feb 27, 2024
26 of 27 checks passed
@wenym1 wenym1 deleted the yiming/recreate-shared-context branch February 27, 2024 07:37
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.

4 participants