Skip to content

Enable rollback for ConsensusRegisterCollection #24734

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ChumpChief
Copy link
Contributor

@ChumpChief ChumpChief commented May 29, 2025

CRC doesn't actually modify anything until the op is ack'd, so nothing is required to restore data state in rollback.

Only thing is to ensure we resolve the promise in a sane way, where we can use the existing semantic of resolving with false to mean "your write didn't go through".

Part of AB#31942

@Copilot Copilot AI review requested due to automatic review settings May 29, 2025 23:06
@ChumpChief ChumpChief requested a review from a team as a code owner May 29, 2025 23:06
Copy link
Contributor

@Copilot 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.

Pull Request Overview

This PR enables rollback functionality for ConsensusRegisterCollection so that write operations resolve with false when rolled back or when the container is disposed.

  • Updated end-to-end tests to validate rollback and disposal behaviors.
  • Modified ConsensusRegisterCollection to use an internal event emitter for ack and rollback resolution of pending messages.
  • Updated API documentation to reflect the new sealed rollback method.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/test/test-end-to-end-tests/src/test/consensusRegisterCollectionEndToEndTests.spec.ts Added tests for write promise resolution on container disposal and rollback scenarios
packages/dds/register-collection/src/consensusRegisterCollection.ts Implemented rollback handling using an internal emitter and updated the write method to support three resolution paths
packages/dds/register-collection/api-report/register-collection.legacy.alpha.api.md Documented the new rollback method in the API report

sharedMap1.set("collection", collection1.handle);
await provider.ensureSynchronized();
const write1P = collection1.write("key1", "value1");
if (container1.dispose !== undefined) {
Copy link
Preview

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider checking for the existence of the dispose method using 'typeof container1.dispose === "function"' to ensure the check is robust.

Suggested change
if (container1.dispose !== undefined) {
if (typeof container1.dispose === "function") {

Copilot uses AI. Check for mistakes.

// 2. The write is rolled back
// 3. The runtime is disposed
// The boolean value returned by the promise is true if the attempted write was ack'd and won, false otherwise.
return new Promise<boolean>((resolve) => {
Copy link
Preview

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

[nitpick] Add inline comments explaining the use of pendingMessageId along with the internalEvents listeners in the write method to improve readability and maintainability.

Copilot uses AI. Check for mistakes.

@github-actions github-actions bot added area: dds Issues related to distributed data structures area: tests Tests to add, test infrastructure improvements, etc public api change Changes to a public API base: main PRs targeted against main branch labels May 29, 2025
Copy link
Contributor

🔗 No broken links found! ✅

Your attention to detail is admirable.

linkcheck output


> fluid-framework-docs-site@0.0.0 ci:check-links /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test "npm run serve -- --no-open" 3000 check-links

1: starting server using command "npm run serve -- --no-open"
and when url "[ 'http://127.0.0.1:3000' ]" is responding with HTTP status code 200
running tests using command "npm run check-links"


> fluid-framework-docs-site@0.0.0 serve
> docusaurus serve --no-open

[SUCCESS] Serving "build" directory at: http://localhost:3000/

> fluid-framework-docs-site@0.0.0 check-links
> linkcheck http://localhost:3000 --skip-file skipped-urls.txt

Crawling...

Stats:
  222975 links
    1707 destination URLs
    1939 URLs ignored
       0 warnings
       0 errors


@anthony-murphy
Copy link
Contributor

anthony-murphy commented May 30, 2025

i would like to see more test coverage here. can this be integrated into the local server stress? For matrix i added both stress and unit test coverage: #24604

@@ -343,6 +395,16 @@ export class ConsensusRegisterCollection<T>
return serializer.parse(content);
}

/**
* @sealed
Copy link
Contributor

Choose a reason for hiding this comment

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

Semantic docs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dds Issues related to distributed data structures area: tests Tests to add, test infrastructure improvements, etc base: main PRs targeted against main branch Feature_StagingMode public api change Changes to a public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants