Skip to content

Interval Collection: local rollback#24307

Merged
anthony-murphy merged 32 commits into
microsoft:mainfrom
anthony-murphy:ic/local-rollback
Apr 16, 2025
Merged

Interval Collection: local rollback#24307
anthony-murphy merged 32 commits into
microsoft:mainfrom
anthony-murphy:ic/local-rollback

Conversation

@anthony-murphy
Copy link
Copy Markdown
Contributor

@anthony-murphy anthony-murphy commented Apr 10, 2025

This change adds rollback functionality to interval collections, and fixes a bug in sequence:

  • adds rollback infrastructure and support for interval collections
  • fixes bug in sequence where the refseq was not properly managed during rollback leading to corruption in merge tree

@github-actions github-actions Bot added area: dds Issues related to distributed data structures area: dds: sharedstring area: tests Tests to add, test infrastructure improvements, etc base: main PRs targeted against main branch labels Apr 10, 2025
@anthony-murphy anthony-murphy marked this pull request as ready for review April 14, 2025 21:28
Copilot AI review requested due to automatic review settings April 14, 2025 21:28
@anthony-murphy anthony-murphy requested a review from a team as a code owner April 14, 2025 21:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

packages/dds/sequence/src/intervals/sequenceInterval.ts:225

  • [nitpick] Consider providing an explicit default value (e.g., false) for the 'rollback' parameter to ensure consistent behavior when it is not provided.
rollback?: boolean,

packages/dds/sequence/src/intervalCollection.ts:1414

  • [nitpick] Double-check that the 'rollback' flag is consistently handled in collaboration scenarios to prevent unintended delta submissions during rollback operations.
if (this.isCollaborating && rollback !== true) {

switch (opName) {
case "add": {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const interval = this.getIntervalById(id)!;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe assert that the interval exists instead of a non-null assertion?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

nice catch. there were actually some other problems on this code path, so improved delete overall.

await assertPropertiesEqual(a, b);
const firstLabels = Array.from(a.getIntervalCollectionLabels()).sort();
const otherLabels = Array.from(b.getIntervalCollectionLabels()).sort();
assert.deepEqual(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the reason for removing this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

collections are created lazily, there is not specific op. so when we see any op under a collection we just create it, so for rollback we might create a collection, but then not send any op, so the collection only exists on that one client, but it doesn't matter that it is exists, as if anyone ever adds something to it in an op, all clients will just agree it exists.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

in fact the call below, getIntervalCollection will create the interval collection locally too, so its not even just ops that create it.

...[
3, 4, 9, 10, 13, 21, 27, 35, 37, 38, 39, 40, 47, 48, 49, 63, 68, 71, 74, 87, 90, 92,
96, 98,
], // Can't rollback attach message,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you link the relevant work item here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this will be fixed by the staging mode feature

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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


this.localSeqToSerializedInterval.set(localSeq, serializedInterval);
}
this.addPendingChange(id, serializedInterval);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ah. was going to ask what's going on here but I see that our removePendingChange implementation is probably overly tolerant to inconsistent add/removes (specifically it's ok with calls to removePendingChange that had no corresponding add) which probably had some lurking bugs with more complex series of changes...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah. the existing code is all over the place. we leak pending state, we leak local references. so far i've taken a light approach to fixing those things to reduce churn. as we build out rollback in the presence of remote changes i expect to improve/fix a bunch of this

@anthony-murphy anthony-murphy merged commit e972660 into microsoft:main Apr 16, 2025
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: dds: sharedstring area: dds Issues related to distributed data structures area: tests Tests to add, test infrastructure improvements, etc base: main PRs targeted against main branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants