-
Notifications
You must be signed in to change notification settings - Fork 536
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
Wait to raise Connected event for Read connection until container is caught up #9377
Wait to raise Connected event for Read connection until container is caught up #9377
Conversation
I think it looks good. Some things missing:
|
ecb4c27
to
9cd2bf2
Compare
Revisiting this finally. Writing down some questions I'm trying to clarify in my head:
|
@jatgarg can you take a look too please? Thanks! |
Answering my own question...
This PR kind of inverts this - now always "connected" event means we're caught up. So |
It can just gate on "connected" state, since "connected" state now gates on caught up.
|
@vladsud, @agarwal-navin, @jatgarg -- Here's my update on this PR, and some input I need from you:
Anything else I should consider here? I anticipate moving this from Draft on Monday or Tuesday. Thanks guys! |
Remaining tasks:
|
⯅ @fluid-example/bundle-size-tests: +1.61 KB
Baseline commit: 4beded1 |
@@ -178,6 +178,10 @@ export async function waitContainerToCatchUp(container: IContainer) { | |||
}; | |||
container.on("closed", closedCallback); | |||
|
|||
// Depending on config, transition to "connected" state may include the guarantee | |||
// that all known ops have been processed. If so, we may introduce additional wait here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If so, we may introduce additional wait here
What do you all think - is this correct or not? It may not add additional delay since events fire synchronously.
@agarwal-navin @vladsud @tyler-cai-microsoft @jatgarg -- Thanks for the early review! Ready for review now. Just need to add UTs for the new "CatchUpMonitor" classes but otherwise ready to go. |
packages/loader/container-loader/src/test/connectionStateHandler.spec.ts
Outdated
Show resolved
Hide resolved
this.opHandler({ sequenceNumber: this.deltaManager.lastSequenceNumber }); | ||
|
||
// If a listener is added after we are already caught up, notify that new listener immediately | ||
this.on("newListener", (event: string, listener) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like instead of using events, it's better to use a property that exposes a promise. I.e. something like
public caughtUp: Promise<number>;
Promise seems to be better because this event files once, and past "firing" reflected on new listeners - that's exactly what promise does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a great point. I don't remember why I switched to event-based to begin with, but I bet it would work better with Promise. That said, I don't have time to try it out now, and also leaving it will reduce merge conflicts with your follow-on refactor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Singing off to unblock you - I did not look through it now, but was poking in my prototyping on top of it and overall, it looks fine.
This commit is queued for merging with the |
Opened https://dev.azure.com/fluidframework/internal/_workitems/edit/1384 to track rolling this out |
Part of #7884. See comments in connectionStateHandler.ts for description of the desired behavior here.
Note that the new behavior is behind a feature gate "Fluid.Container.CatchUpBeforeDeclaringConnected". I didn't make any changes to existing function
waitContainerToCatchUp
, even though some functionality is duplicated. Once we finish rolling this out, we can remove the duplicate logic from that function since it will simply wait for the "connected" event (we may even deprecate it at that point)To-Do:
Some follow-up work items to open afterwards:
waitContainerToCatchUp