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
Add concurrent op check #11309
Add concurrent op check #11309
Conversation
| @@ -186,6 +190,9 @@ export class DeltaManager<TConnectionManager extends IConnectionManager> | |||
| public get clientDetails() { return this.connectionManager.clientDetails; } | |||
|
|
|||
| public submit(type: MessageType, contents: any, batch = false, metadata?: any) { | |||
| if (this.opsCurrentlyProcessing > 0) { | |||
| this.close(new UsageError("Currently processing ops: Container closed")); | |||
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.
Let's add better message here. I'd say "Making changes to data model is disallowed while processing ops."
| @@ -762,6 +768,7 @@ export class DeltaManager<TConnectionManager extends IConnectionManager> | |||
|
|
|||
| private processInboundMessage(message: ISequencedDocumentMessage): void { | |||
| const startTime = Date.now(); | |||
| this.opsCurrentlyProcessing++; | |||
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.
I'd rather make it a boolean (as there is no reentrancy here). You could also add asserts that it is false (zero in current form) before we change it here, and true below we reset it back
| @@ -1890,6 +1890,10 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents> | |||
|
|
|||
| public process(messageArg: ISequencedDocumentMessage, local: boolean) { | |||
| this.verifyNotClosed(); | |||
| if (this.opsCurrentlyProcessing !== 0) { | |||
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.
I do not remember why we decided to go with checking it in two places, but worth adding some comment on why we are doing
| @@ -332,6 +332,12 @@ describe("Loader", () => { | |||
| deltaManager.connectionManager.forceReadonly(true); | |||
| }); | |||
| }); | |||
|
|
|||
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.
You could test it at that level (at least the check in DeltaManager, so yes, adding some code to do so would be nice).
|
Please add breaking.md note about these changes, how users can temporarily disable it, and the fact that they will lose such capability in the future, thus need to fix any bugs it finds. |
| pushOp(message); | ||
| pushOp(message); | ||
| pushOp(message); | ||
| await processOps(); |
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.
I'm not sure what this test actually testing. It does not result in ops being generated while processing an op.
I.e. it will either pass of fail in the same way, with or without your other changes.
Plus, if I got it right, this code uses MockDeltaManager, not real (production) code you are modifying, and there is no ContainerRuntime created in this test (as far as I can see).
I think the easiest way to validate new behavior is to use some existing DDS (in end-to-end tests) and change it from within event handler.
5b01974
to
36bda61
Compare
36bda61
to
c5bc163
Compare
bcaf97c
to
47fbe72
Compare
9aaa435
to
2e4dccc
Compare
2e4dccc
to
c0914fe
Compare
|
This commit is queued for merging with the |
Description
AB#1092
This PR adds assertions to DeltaManager and ContainerRuntime to ensure that ops are not being sent while currently being processsed. Currently this is happening unchecked, leading to non-deterministic outcomes.
Reviewer Guidance