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

[DTP-955] Buffer and flush state operations during a STATE_SYNC sequence #1909

Merged
merged 4 commits into from
Nov 14, 2024

Conversation

VeskeR
Copy link
Contributor

@VeskeR VeskeR commented Oct 24, 2024

This PR is based on #1908, please review it first.

See commits for more details.

Resolves DTP-955

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced handling of state messages and synchronization across various components.
    • Introduced BufferedStateMessage for improved state message management during synchronization.
    • Added methods in LiveObjectsHelper for better processing of state operation messages.
    • Improved initialization of LiveCounter, LiveMap, and LiveObject with regional timeserials.
  • Bug Fixes

    • Updated tests to ensure correct handling of STATE and STATE_SYNC messages, improving reliability.
  • Documentation

    • Improved clarity and maintainability of the test suite by modularizing the test logic.

Copy link

coderabbitai bot commented Oct 24, 2024

Warning

Rate limit exceeded

@VeskeR has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 4 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between ef7b975 and d919f8b.

Walkthrough

The pull request introduces several modifications across multiple classes related to state message handling and synchronization in the LiveObjects system. Key changes include updating method signatures in the RealtimeChannel, LiveCounter, LiveMap, and LiveObject classes to incorporate a new Timeserial parameter. Additionally, new methods and interfaces are added to enhance the processing of state messages, including buffering mechanisms during synchronization. The LiveObjectsHelper class is also expanded to facilitate state message processing in tests, ensuring a more modular and maintainable test suite.

Changes

File Path Change Summary
src/common/lib/client/realtimechannel.ts Updated processMessage to pass message.channelSerial to _liveObjects.handleStateMessages and _liveObjects.handleStateSyncMessages.
src/plugins/liveobjects/livecounter.ts Constructor and applyOperation method signatures updated to include regionalTimeserial and msg.
src/plugins/liveobjects/livemap.ts Constructor and applyOperation method signatures updated to include regionalTimeserial.
src/plugins/liveobjects/liveobject.ts Constructor updated to require Timeserial for _regionalTimeserial; method signatures updated for type consistency.
src/plugins/liveobjects/liveobjects.ts Added BufferedStateMessage interface; updated handleStateMessages to accept msgRegionalTimeserial.
src/plugins/liveobjects/liveobjectspool.ts Updated methods to handle regionalTimeserial and added applyBufferedStateMessages.
test/common/modules/live_objects_helper.js Added multiple methods for state message processing; updated constructor to store helper parameter.
test/realtime/live_objects.test.js Updated tests to utilize LiveObjectsHelper for processing state messages; added tests for buffered operations.

Assessment against linked issues

Objective Addressed Explanation
Buffer and flush operations during a sync sequence (DTP-955)

Possibly related PRs

Suggested reviewers

  • ttypic
  • mschristensen
  • owenpearson

Poem

🐇 In the realm of code where messages flow,
A new Timeserial helps us to know.
With channels and counters, we dance and we play,
Synchronizing states in a grand ballet.
So hop with delight, for changes are here,
In the world of LiveObjects, we cheer and we cheer! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@VeskeR VeskeR requested review from mschristensen and owenpearson and removed request for mschristensen October 24, 2024 22:33
@github-actions github-actions bot temporarily deployed to staging/pull/1909/bundle-report October 24, 2024 22:34 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1909/typedoc October 24, 2024 22:34 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1909/features October 24, 2024 22:34 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (5)
src/common/lib/client/realtimechannel.ts (1)

Line range hint 656-696: Consider adding error recovery for state message decoding failures

The STATE_SYNC block has similar error handling to the STATE block, but unlike the MESSAGE action which has _startDecodeFailureRecovery, there's no recovery mechanism for state message decoding failures. Consider implementing a similar recovery mechanism for state messages.

 } catch (e) {
   Logger.logAction(
     this.logger,
     Logger.LOG_ERROR,
     'RealtimeChannel.processMessage()',
     (e as Error).toString(),
   );
+  this._startStateDecodeFailureRecovery(e as ErrorInfo);
+  return;
 }
src/plugins/liveobjects/liveobjectspool.ts (4)

90-91: Typo in comment: 'wich' should be 'which'

The comment on line 90 contains a typo: 'wich' should be 'which'.


91-91: Notice of TODO: Invoke subscription callbacks

There are TODO comments indicating that subscription callbacks need to be invoked when an object is applied at lines 91 and 115. Would you like assistance in implementing this functionality or opening a new GitHub issue to track this task?

Also applies to: 115-115


Line range hint 74-79: Refactor duplicated code for checking stateMessage.operation

The checks for if (!stateMessage.operation) in both applyStateMessages and applyBufferedStateMessages are similar. Consider refactoring this duplicated code into a helper method to improve maintainability.

Also applies to: 136-144


156-161: Consider reviewing the logging level for skipped buffered state messages

The log message at LOG_MICRO level may be important for debugging synchronization issues. Consider whether a higher logging level such as LOG_MINOR would be more appropriate to ensure visibility.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 681c1af and 35fa4af.

📒 Files selected for processing (8)
  • src/common/lib/client/realtimechannel.ts (1 hunks)
  • src/plugins/liveobjects/livecounter.ts (4 hunks)
  • src/plugins/liveobjects/livemap.ts (3 hunks)
  • src/plugins/liveobjects/liveobject.ts (5 hunks)
  • src/plugins/liveobjects/liveobjects.ts (8 hunks)
  • src/plugins/liveobjects/liveobjectspool.ts (6 hunks)
  • test/common/modules/live_objects_helper.js (3 hunks)
  • test/realtime/live_objects.test.js (9 hunks)
🧰 Additional context used
🪛 Biome
test/common/modules/live_objects_helper.js

[error] 209-209: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

🔇 Additional comments (33)
src/plugins/liveobjects/liveobject.ts (5)

4-4: LGTM: Import of Timeserial type

The import is correctly added to support the new Timeserial type usage throughout the class.


36-38: LGTM: Type-safe getter implementation

The getter now returns a non-optional Timeserial type, which aligns with the constructor's guarantee that _regionalTimeserial is always defined.


50-52: LGTM: Type-safe setter implementation

The setter correctly enforces the Timeserial type for parameter validation.


62-62: Verify opRegionalTimeserial usage in subclasses

The abstract method signature has been updated to include opRegionalTimeserial parameter. This change requires implementation in all subclasses.

✅ Verification successful

All subclasses correctly implement the updated applyOperation signature

The verification shows that all concrete implementations (LiveMap and LiveCounter) correctly include the opRegionalTimeserial: Timeserial parameter in their applyOperation method signatures, matching the abstract method definition in LiveObject. The implementations are found in:

  • src/plugins/liveobjects/livemap.ts
  • src/plugins/liveobjects/livecounter.ts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all implementations of applyOperation to verify they handle the new parameter
# Test: Search for applyOperation implementations. Expect: All implementations include Timeserial parameter

ast-grep --pattern 'applyOperation(op: StateOperation, msg: StateMessage, opRegionalTimeserial: Timeserial)'

Length of output: 110


Script:

#!/bin/bash
# Let's try a broader search to find all implementations of applyOperation
ast-grep --pattern 'applyOperation($$$) {
  $$$
}'

# Also search for class declarations that might implement LiveObject
ast-grep --pattern 'class $_ extends $_LiveObject'

# Backup search using ripgrep to find applyOperation implementations
rg "applyOperation.*\(" -A 2

Length of output: 1536


17-17: Verify initialization of _regionalTimeserial in dependent code

The constructor now requires a Timeserial parameter, making it a mandatory field. This is a breaking change that requires updates in all instantiations of LiveObject and its subclasses.

src/plugins/liveobjects/livecounter.ts (3)

3-4: LGTM: Import changes align with new type requirements

The additional imports properly support the new type requirements for state message handling and timeserial tracking.


42-42: Verify the unused StateMessage parameter

The msg parameter is added to the method signature but isn't used in the implementation. This might indicate:

  1. Missing functionality that should utilize this parameter
  2. Consistency with an interface that requires this parameter

Let's check the usage pattern across the codebase:

#!/bin/bash
# Description: Check if other classes use the msg parameter in applyOperation
# Expect: Find patterns of msg parameter usage in similar classes

# Search for applyOperation implementations
ast-grep --pattern 'applyOperation($_: StateOperation, msg: StateMessage, $_: Timeserial) {
  $$$
}'

Additionally, the placement of setRegionalTimeserial after all operations looks correct as it updates the timestamp after successful application of changes.

Also applies to: 71-72


13-13: LGTM: Constructor signature update maintains consistency

The addition of the regionalTimeserial parameter and its propagation to the parent class is well-structured.

Let's verify the consistency of this change across related classes:

Also applies to: 18-18

✅ Verification successful

Constructor signature update is consistent across LiveObject classes

The verification confirms that the regionalTimeserial parameter is consistently implemented across the LiveObject hierarchy:

  • Base LiveObject class has it as protected _regionalTimeserial: Timeserial
  • LiveMap includes it in the same position after liveObjects
  • LiveCounter follows the same pattern with identical parameter placement
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify constructor signatures in related LiveObject classes
# Expect: All LiveObject-derived classes should have similar regionalTimeserial parameter

# Search for class constructors in the LiveObjects system
ast-grep --pattern 'class $_ extends LiveObject {
  constructor($_) {
    $$$
  }
}'

Length of output: 243


Script:

#!/bin/bash
# Let's try a different approach to find LiveObject-related classes and their constructors
# First, find files that might contain LiveObject classes
rg -l "extends LiveObject" 

# Then look for constructor patterns in those files
rg "constructor\(" -A 5 

Length of output: 43094


Script:

#!/bin/bash
# Let's specifically look at the LiveObject-related constructors
rg "constructor\(" -A 5 src/plugins/liveobjects/livemap.ts src/plugins/liveobjects/liveobject.ts src/plugins/liveobjects/livecounter.ts

Length of output: 1332

src/plugins/liveobjects/livemap.ts (2)

46-51: Verify regionalTimeserial validation.

While the parameter is correctly added and passed to the super constructor, consider whether validation of the regionalTimeserial parameter should be performed, either here or in the parent class.


129-129: LGTM! Verify error handling propagation.

The changes correctly handle the regional timeserial by setting it after all operations are applied. The placement ensures it's set regardless of the operation type or potential errors.

Also applies to: 166-167

src/common/lib/client/realtimechannel.ts (3)

652-652: LGTM: Passing channelSerial to handleStateMessages

The addition of message.channelSerial parameter aligns with the PR's objective of improving state synchronization.


Line range hint 698-698: LGTM: Passing channelSerial to handleStateSyncMessages

The addition of message.channelSerial parameter to handleStateSyncMessages is consistent with the changes in the STATE action block.


Line range hint 656-698: Verify the order of state operations during sync

The STATE_SYNC handling appears to be part of a buffering mechanism during synchronization. We should verify that state operations are properly ordered when flushed after sync completes.

✅ Verification successful

Based on the shell script results, I can now provide a final response since I have sufficient evidence about the state sync handling implementation:

State operations are properly ordered during sync with robust buffering mechanism

The codebase implements a well-designed state synchronization system that:

  • Buffers all state operations while sync is in progress (_bufferedStateOperations)
  • Applies buffered operations only after sync completes (_endSync() method)
  • Maintains correct ordering by checking regional timeserials before applying operations
  • Discards buffered operations if a new sync sequence starts

The implementation in realtimechannel.ts and supporting classes ensures operations are applied in the correct order with proper synchronization guarantees.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential race conditions in state sync handling
# Look for any direct state modifications during sync

# Search for state modifications during sync
rg -A 5 "handleStateSyncMessages|STATE_SYNC" 

# Search for state buffer implementations
rg -A 10 "buffer.*state|flush.*state"

Length of output: 27817

src/plugins/liveobjects/liveobjects.ts (11)

17-20: BufferedStateMessage interface added correctly.

The interface BufferedStateMessage is appropriately defined to encapsulate state messages along with their associated regional timeserials.


33-33: Declaration of _bufferedStateOperations property.

The private property _bufferedStateOperations is correctly declared to store buffered state messages during synchronization.


42-42: Initialization of _bufferedStateOperations in constructor.

Initializing _bufferedStateOperations as an empty array in the constructor ensures it is ready to store buffered messages.


155-156: Discarding buffered state operations on new sync start.

Clearing _bufferedStateOperations at the start of a new sync ensures outdated messages are not applied. This behavior aligns with synchronization logic.


165-168: Applying buffered state messages after sync completion.

Applying buffered state messages after syncing data ensures no messages are lost during synchronization.


204-204: Calculating regionalTimeserialObj correctly.

The calculation of regionalTimeserialObj using DefaultTimeserial.calculateTimeserial maintains accurate timeserial synchronization.


208-208: Setting regional timeserial on existing objects.

Updating existing objects with the new regionalTimeserialObj ensures their timeserials are consistent with the latest sync data.


220-224: Updating constructors of LiveCounter and LiveMap with regionalTimeserialObj.

Passing regionalTimeserialObj to the constructors ensures new live objects are initialized with accurate timeserials.

Run the following script to confirm constructors have been updated:

#!/bin/bash
# Description: Verify constructors of LiveCounter and LiveMap accept regionalTimeserialObj.

# Search for constructors with regionalTimeserialObj parameter
rg 'constructor\(.*regionalTimeserial' -A 3

95-97: Updated handleStateMessages method signature to include msgRegionalTimeserial.

The addition of msgRegionalTimeserial parameter to handleStateMessages is appropriate. Ensure that all calls to this method are updated to pass the new parameter.

Run the following script to verify all calls to handleStateMessages include the new parameter:

#!/bin/bash
# Description: Verify all calls to handleStateMessages include the new parameter.

# Search for calls to handleStateMessages
rg 'handleStateMessages\(' -A 1

103-103: ⚠️ Potential issue

Typo in comment: 'messsages' should be 'messages'.

Please correct the typo in the comment to improve readability.

Apply this diff to fix the typo:

- // we buffer incoming state operation messsages while SYNC is in progress, and apply them once SYNC has ended.
+ // we buffer incoming state operation messages while SYNC is in progress, and apply them once SYNC has ended.

Likely invalid or redundant comment.


109-109: Ensure applyStateMessages method accepts timeserial parameter.

Confirm that applyStateMessages in LiveObjectsPool is updated to accept the timeserial parameter and handles it correctly.

Run the following script to verify the method signature:

✅ Verification successful

The applyStateMessages method correctly accepts and handles the timeserial parameter

The method signature in LiveObjectsPool class is correctly defined with both required parameters:

applyStateMessages(stateMessages: StateMessage[], regionalTimeserial: Timeserial): void

The method properly uses the timeserial parameter throughout its implementation, passing it to child objects when applying operations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that applyStateMessages method accepts timeserial parameter.

# Search for the method definition
rg 'applyStateMessages\(.*timeserial' -A 2

Length of output: 45


Script:

#!/bin/bash
# Let's try a broader search for the method definition
ast-grep --pattern 'applyStateMessages($_) {
  $$$
}'

# Also search for the class definition to understand the context
ast-grep --pattern 'class LiveObjectsPool {
  $$$
}'

Length of output: 18309

src/plugins/liveobjects/liveobjectspool.ts (3)

129-168: Well-implemented handling of buffered state messages

The new applyBufferedStateMessages method correctly processes buffered state messages using regional timeserial comparisons. The logic ensures that only relevant messages are applied, maintaining consistency of the object pool during synchronization.


Line range hint 183-195: Correct implementation of _handleCounterCreate method

The _handleCounterCreate method appropriately initializes a LiveCounter with the provided opRegionalTimeserial and handles cases where the counter field may be missing in the stateOperation.


201-212: Correct implementation of _handleMapCreate method

The _handleMapCreate method correctly initializes a LiveMap object, handling cases where stateOperation.map may be undefined, and setting default values as needed.

test/realtime/live_objects.test.js (6)

58-58: LGTM

The initialization of liveObjectsHelper is appropriate for testing the handling of STATE messages without the LiveObjects plugin.


71-77: LGTM

Injecting a STATE message using liveObjectsHelper.processStateOperationMessageOnChannel correctly verifies that such messages are ignored without the LiveObjects plugin.


91-91: LGTM

Creating liveObjectsHelper in this test is suitable for assessing the reception of STATE_SYNC messages without the LiveObjects plugin.


104-108: LGTM

The test appropriately injects a STATE_SYNC message to ensure it does not affect functionality when the LiveObjects plugin is not present.


Line range hint 233-285: LGTM

The test correctly verifies that getRoot() waits for the STATE_SYNC sequence to complete before resolving, ensuring proper synchronization handling.


462-463: Verify handling of maximum safe integer values

When using Number.MAX_SAFE_INTEGER and -Number.MAX_SAFE_INTEGER, ensure that the system accurately handles these extreme values without causing precision loss or overflow issues.

test/common/modules/live_objects_helper.js Show resolved Hide resolved
test/common/modules/live_objects_helper.js Show resolved Hide resolved
test/realtime/live_objects.test.js Show resolved Hide resolved
@VeskeR VeskeR force-pushed the DTP-955/buffer-ops-during-sync branch from 35fa4af to bf24a27 Compare October 25, 2024 08:33
@github-actions github-actions bot temporarily deployed to staging/pull/1909/features October 25, 2024 08:34 Inactive
@VeskeR VeskeR force-pushed the DTP-955/buffer-ops-during-sync branch from bf24a27 to 0a3ff83 Compare October 25, 2024 08:55
@github-actions github-actions bot temporarily deployed to staging/pull/1909/bundle-report October 25, 2024 08:56 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1909/features October 25, 2024 08:56 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1909/typedoc October 25, 2024 08:56 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (7)
src/plugins/liveobjects/liveobject.ts (1)

20-20: LGTM: Constructor changes maintain backward compatibility

The default zero value timeserial ensures backward compatibility while supporting the new state sync functionality.

Consider expanding the comment to explain why zero value timeserial allows future operations to be applied:

-    // use zero value timeserial by default, so any future operation can be applied for this object
+    // Use zero value timeserial by default. This ensures that any future operation's timeserial will be
+    // greater than this initial value, allowing operations to be correctly ordered and applied.

Also applies to: 25-26

src/plugins/liveobjects/livecounter.ts (1)

56-56: Consider adding validation for opRegionalTimeserial

While the implementation is functionally correct, consider adding validation for the opRegionalTimeserial parameter before setting it. This would help catch potential issues early.

Consider updating the implementation to include validation:

   applyOperation(op: StateOperation, msg: StateMessage, opRegionalTimeserial: Timeserial): void {
+    if (!opRegionalTimeserial) {
+      throw new this._client.ErrorInfo(
+        'Invalid regional timeserial provided for operation',
+        50000,
+        500,
+      );
+    }
     if (op.objectId !== this.getObjectId()) {

Also applies to: 85-86

src/plugins/liveobjects/liveobjects.ts (3)

95-109: Consider adding error handling for invalid timeserial.

While the implementation effectively handles state message buffering during sync, consider adding validation for the msgRegionalTimeserial parameter to ensure robust error handling.

Consider adding validation:

 handleStateMessages(stateMessages: StateMessage[], msgRegionalTimeserial: string | null | undefined): void {
+  if (msgRegionalTimeserial && !/^[\w-]+:[\w-]+$/.test(msgRegionalTimeserial)) {
+    this._client.Logger.logAction(
+      this._client.logger,
+      this._client.Logger.LOG_ERROR,
+      'LiveObjects.handleStateMessages()',
+      `Invalid regional timeserial format: ${msgRegionalTimeserial}`,
+    );
+  }
   const timeserial = DefaultTimeserial.calculateTimeserial(this._client, msgRegionalTimeserial);

155-168: Consider adding debug logs for buffer operations.

While the implementation is correct, adding debug logs would help track buffer operations during sync sequences.

Consider adding logging:

 private _startNewSync(syncId?: string, syncCursor?: string): void {
+  this._client.Logger.logAction(
+    this._client.logger,
+    this._client.Logger.LOG_MICRO,
+    'LiveObjects._startNewSync()',
+    `Discarding ${this._bufferedStateOperations.length} buffered operations`,
+  );
   this._bufferedStateOperations = [];

 private _endSync(): void {
   this._applySync();
+  this._client.Logger.logAction(
+    this._client.logger,
+    this._client.Logger.LOG_MICRO,
+    'LiveObjects._endSync()',
+    `Applying ${this._bufferedStateOperations.length} buffered operations`,
+  );
   this._liveObjectsPool.applyBufferedStateMessages(this._bufferedStateOperations);

Line range hint 141-150: TODO comments need implementation for error handling.

The error handling for channel state transitions to 'detached', 'failed', and 'suspended' states is currently missing. This could lead to undefined behavior if sync fails.

Would you like me to help implement the error handling for these states or create a GitHub issue to track this?

test/common/modules/live_objects_helper.js (1)

177-204: Add JSDoc comments to document parameters

The implementation looks good, but consider adding JSDoc comments to document the expected parameters and their types.

Example documentation:

/**
 * Creates a map object message
 * @param {Object} opts - The options object
 * @param {string} opts.objectId - The unique identifier for the map
 * @param {string} opts.regionalTimeserial - The regional timeserial for state sync
 * @param {Object} opts.entries - The map entries
 * @returns {Object} The formatted map object message
 */
test/realtime/live_objects.test.js (1)

1047-1141: Add documentation for the regional timeserial test logic.

This test scenario is complex and handles important edge cases. Consider adding JSDoc comments to explain:

  1. The significance of regional timeserial values
  2. Why certain operations are expected to be applied or discarded
  3. The relationship between timeserials and sync sequence

Add documentation above the test:

/**
 * Tests the handling of state operations based on regional timeserials during sync:
 * - Operations with older timeserials (@0-0) than state objects (@1-0) are discarded
 * - Operations with newer timeserials (@2-0) are applied
 * - Ensures proper ordering and consistency of state updates
 */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 35fa4af and 0a3ff83.

📒 Files selected for processing (8)
  • src/common/lib/client/realtimechannel.ts (1 hunks)
  • src/plugins/liveobjects/livecounter.ts (4 hunks)
  • src/plugins/liveobjects/livemap.ts (3 hunks)
  • src/plugins/liveobjects/liveobject.ts (5 hunks)
  • src/plugins/liveobjects/liveobjects.ts (8 hunks)
  • src/plugins/liveobjects/liveobjectspool.ts (5 hunks)
  • test/common/modules/live_objects_helper.js (3 hunks)
  • test/realtime/live_objects.test.js (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/common/lib/client/realtimechannel.ts
  • src/plugins/liveobjects/livemap.ts
🧰 Additional context used
🪛 Biome
test/common/modules/live_objects_helper.js

[error] 209-209: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

🔇 Additional comments (20)
src/plugins/liveobjects/liveobject.ts (4)

4-4: LGTM: Import changes align with type system updates

The addition of Timeserial types supports the enhanced type safety throughout the class.


39-41: LGTM: Getter/setter changes align with property type

The type updates to getRegionalTimeserial and setRegionalTimeserial methods maintain consistency with the property type change.

Also applies to: 53-55


65-65: Verify implementations of updated abstract method

The applyOperation method signature has changed to include opRegionalTimeserial. We need to verify that all derived classes have been updated accordingly.

#!/bin/bash
# Search for classes that extend LiveObject and their applyOperation implementations
ast-grep --pattern 'class $_ extends LiveObject {
  $$$
  applyOperation($$$) {
    $$$
  }
  $$$
}'

14-14: Verify impact of required _regionalTimeserial property

The property has changed from an optional string to a required Timeserial. While this improves type safety, we should verify that all existing instantiations of LiveObject provide this value.

src/plugins/liveobjects/livecounter.ts (3)

3-4: LGTM: Import statements are correctly updated

The new imports for StateMessage, related types, and Timeserial are necessary for the type safety of the new parameters.


26-32: LGTM: Static factory method properly updated

The zeroValue method signature and implementation are correctly updated to support the new regionalTimeserial parameter.


16-18: LGTM: Constructor signature properly updated

The regionalTimeserial parameter is correctly added as optional and properly passed to the parent class.

Let's verify the parent class implementation:

✅ Verification successful

Constructor changes verified and correctly implemented

The parent LiveObject class constructor properly handles the optional regionalTimeserial parameter, initializing it with either the provided value or a default zero value timeserial. The child class's constructor signature and super call are correctly aligned with this implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check LiveObject parent class implementation
ast-grep --pattern 'class LiveObject {
  constructor($_) {
    $$$
  }
}'

Length of output: 75


Script:

#!/bin/bash
# Let's try a broader search for LiveObject class and its constructor
rg "class LiveObject" -A 10

# Also search for any file containing LiveObject in its name
fd "LiveObject" --type f

Length of output: 3435


Script:

#!/bin/bash
# Let's get the full constructor implementation of LiveObject class
rg -A 20 "constructor\(" src/plugins/liveobjects/liveobject.ts

Length of output: 684

src/plugins/liveobjects/liveobjects.ts (3)

17-20: LGTM: Well-structured interface and property definition.

The BufferedStateMessage interface clearly defines the structure for buffered state operations, and the corresponding private property is appropriately typed.

Also applies to: 33-33


42-42: LGTM: Proper initialization in constructor.

The _bufferedStateOperations array is correctly initialized in the constructor.


Line range hint 204-224: Verify thread safety of _applySync method.

The method modifies shared state (_liveObjectsPool) while iterating over another shared collection (_syncLiveObjectsDataPool). Please verify that this method cannot be called concurrently from different contexts.

test/common/modules/live_objects_helper.js (4)

6-8: LGTM: Module setup is well-structured

The imports are properly organized and the createPM helper is correctly initialized with LiveObjectsPlugin.


206-228: LGTM: State message creation is well-implemented

The implementation correctly handles:

  • Proper action codes for STATE (19) and STATE_SYNC (20)
  • Graceful handling of null state
  • Consistent serial handling
🧰 Tools
🪛 Biome

[error] 209-209: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


230-258: LGTM: Message processing implementation is correct

The implementation correctly:

  • Records private API calls
  • Processes messages through the channel
  • Maintains channel context

260-266: LGTM: ID generation utilities are well-implemented

The implementation provides a consistent and reliable way to generate unique IDs with appropriate prefixes.

src/plugins/liveobjects/liveobjectspool.ts (5)

6-6: LGTM: Import changes align with new functionality.

The new imports support the enhanced state message handling and timeserial functionality.

Also applies to: 9-9


72-72: LGTM: Consistent timeserial integration in state message handling.

The regionalTimeserial parameter is correctly propagated through the state message handling chain while maintaining robust error handling.

Also applies to: 93-93, 99-99, 103-103, 115-115


176-187: LGTM: Consistent timeserial handling in object creation.

The helper methods properly integrate the timeserial parameter for both counter and map creation, maintaining consistency across object types.

Also applies to: 194-206


129-167: Verify handling of concurrent SYNC sequences.

The buffered state message handling looks robust with proper timeserial comparison and logging. However, please verify the behavior when multiple SYNC sequences occur in rapid succession.

Consider these scenarios:

  1. What happens if a new SYNC sequence starts while processing buffered messages?
  2. How are buffered messages from different SYNC sequences distinguished?

Let's check for SYNC sequence handling:

#!/bin/bash
# Description: Check SYNC sequence handling implementation
# Test: Look for SYNC sequence handling logic
rg -A 5 "STATE_SYNC|SYNC sequence" --type ts

55-56: Verify zero-value timeserial initialization.

The initialization of zero-value objects with timeserial looks correct. This ensures proper state synchronization.

Let's verify the zero-value timeserial usage across the codebase:

Also applies to: 60-60, 65-65

✅ Verification successful

Based on the shell script results, I can now generate the final response:

Zero-value timeserial initialization is correctly implemented

The implementation is consistent across the codebase:

  • DefaultTimeserial.zeroValueTimeserial() is properly used for initializing new objects
  • Both LiveMap and LiveCounter constructors correctly accept and handle the timeserial parameter
  • The zero-value timeserial (@0-0) is appropriately used as the baseline for state synchronization
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent zero-value timeserial initialization
# Test: Search for zeroValue usage with timeserial parameter
ast-grep --pattern 'zeroValue($_,$_,$_,timeserial)'

Length of output: 4366


Script:

#!/bin/bash
# Let's search for zeroValue method calls with a more flexible pattern
ast-grep --pattern 'zeroValue($_)'

# Also search for DefaultTimeserial usage
rg "DefaultTimeserial" -A 3 --type ts

# And check LiveMap and LiveCounter zero value implementations
rg "class (LiveMap|LiveCounter)" -A 10 --type ts

Length of output: 6687

test/realtime/live_objects.test.js (1)

Line range hint 58-77: Well-structured test helper usage.

The introduction of LiveObjectsHelper and its methods like processStateOperationMessageOnChannel and processStateObjectMessageOnChannel improves test maintainability and readability.

Also applies to: 91-108

test/realtime/live_objects.test.js Show resolved Hide resolved
Regional timeserial for a LiveObject:
- is set to StateObject.regionalTimeserial when object is created
during SYNC sequence
- is set to message's channelSerial property when object is
created via a state operation message
- is updated to message's channelSerial property when an operation is
applied on an object via a state operation message
- is equal to zero-value Timeserial (`@0-0`) when creating a zero-value
object
@VeskeR VeskeR force-pushed the DTP-955/buffer-ops-during-sync branch from 0a3ff83 to ef7b975 Compare October 30, 2024 11:40
@github-actions github-actions bot temporarily deployed to staging/pull/1909/bundle-report October 30, 2024 11:41 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1909/typedoc October 30, 2024 11:41 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1909/features October 30, 2024 11:41 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (8)
src/plugins/liveobjects/livecounter.ts (1)

26-32: Update method documentation to include the new parameter

The zeroValue static method's implementation is correct, but its JSDoc comment should be updated to document the new regionalTimeserial parameter.

  /**
   * Returns a {@link LiveCounter} instance with a 0 value.
   *
+  * @param liveobjects - The LiveObjects instance
+  * @param isCreated - Whether the counter is created
+  * @param objectId - Optional object ID
+  * @param regionalTimeserial - Optional regional timeserial
   * @internal
   */
src/plugins/liveobjects/liveobjects.ts (4)

41-42: Consider adding documentation for the buffered operations field.

Adding a brief comment explaining the purpose of _bufferedStateOperations would improve code maintainability.

+  // Stores state operations received during sync to prevent double-application
   this._bufferedStateOperations = [];

95-109: Consider adding input parameter validation.

The implementation effectively handles concurrent state messages during sync, but should validate input parameters.

   handleStateMessages(stateMessages: StateMessage[], msgRegionalTimeserial: string | null | undefined): void {
+    if (!Array.isArray(stateMessages)) {
+      throw new this._client.ErrorInfo('stateMessages must be an array', 40000, 400);
+    }
     const timeserial = DefaultTimeserial.calculateTimeserial(this._client, msgRegionalTimeserial);

Line range hint 204-224: Handle edge case for undefined regionalTimeserial.

While the implementation correctly applies timeserials, consider handling the edge case where entry.regionalTimeserial is undefined.

-      const regionalTimeserialObj = DefaultTimeserial.calculateTimeserial(this._client, entry.regionalTimeserial);
+      const regionalTimeserialObj = entry.regionalTimeserial 
+        ? DefaultTimeserial.calculateTimeserial(this._client, entry.regionalTimeserial)
+        : DefaultTimeserial.zero();

Line range hint 95-168: Well-designed implementation of state operation buffering.

The implementation successfully addresses the concurrent nature of state messages during sync by:

  1. Buffering state operations during sync
  2. Maintaining proper ordering of sync data and buffered operations
  3. Providing clear documentation of the rationale

The architecture ensures that operations are neither lost nor double-applied during the sync sequence.

Consider adding telemetry or logging to monitor:

  • Number of buffered operations during sync
  • Time spent in sync state
  • Frequency of concurrent state messages during sync
    This would help identify potential performance bottlenecks or synchronization issues in production.
src/plugins/liveobjects/liveobjectspool.ts (3)

Line range hint 72-127: Enhance error handling in applyStateMessages.

While the method handles missing operations gracefully, it could benefit from additional error handling:

  1. Validate regionalTimeserial parameter is not null/undefined
  2. Consider adding error handling for invalid state operations

Consider adding parameter validation:

 applyStateMessages(stateMessages: StateMessage[], regionalTimeserial: Timeserial): void {
+  if (!regionalTimeserial) {
+    throw new Error('regionalTimeserial must be provided');
+  }
   for (const stateMessage of stateMessages) {

129-167: Consider edge cases in buffered state message handling.

The buffered state message handling logic looks solid but should consider these edge cases:

  1. What happens if buffered messages arrive out of order?
  2. How are duplicate messages handled?
  3. Is there a maximum buffer size to prevent memory issues?

The current implementation might need additional safeguards against these scenarios.

Consider implementing:

  1. Deduplication of messages based on message ID
  2. Buffer size limits with overflow handling
  3. Explicit ordering validation for buffered messages

Line range hint 176-211: Add validation for opRegionalTimeserial in helper methods.

Both _handleCounterCreate and _handleMapCreate should validate the opRegionalTimeserial parameter to ensure robust error handling.

Consider adding validation in both methods:

 private _handleCounterCreate(stateOperation: StateOperation, opRegionalTimeserial: Timeserial): void {
+  if (!opRegionalTimeserial) {
+    throw new Error('opRegionalTimeserial must be provided');
+  }
   let counter: LiveCounter;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0a3ff83 and ef7b975.

📒 Files selected for processing (8)
  • src/common/lib/client/realtimechannel.ts (1 hunks)
  • src/plugins/liveobjects/livecounter.ts (4 hunks)
  • src/plugins/liveobjects/livemap.ts (3 hunks)
  • src/plugins/liveobjects/liveobject.ts (5 hunks)
  • src/plugins/liveobjects/liveobjects.ts (8 hunks)
  • src/plugins/liveobjects/liveobjectspool.ts (5 hunks)
  • test/common/modules/live_objects_helper.js (3 hunks)
  • test/realtime/live_objects.test.js (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/common/lib/client/realtimechannel.ts
  • src/plugins/liveobjects/livemap.ts
  • src/plugins/liveobjects/liveobject.ts
🧰 Additional context used
🪛 Biome
test/common/modules/live_objects_helper.js

[error] 209-209: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

🔇 Additional comments (13)
src/plugins/liveobjects/livecounter.ts (3)

3-4: LGTM: Import statements are properly organized

The new imports for StateMessage and Timeserial are correctly added and grouped with related imports.


16-18: LGTM: Constructor properly handles new regionalTimeserial parameter

The optional regionalTimeserial parameter is correctly added and properly passed to the parent class constructor.


56-56: Verify the necessity of the unused StateMessage parameter

The msg parameter of type StateMessage is currently unused in the method implementation. If it's intended for future use or required by the interface, consider adding a TODO comment explaining its purpose.

Also applies to: 85-86

src/plugins/liveobjects/liveobjects.ts (2)

17-20: LGTM! Well-structured interface definition.

The BufferedStateMessage interface clearly encapsulates the relationship between state messages and their regional timeserials.


155-168: Verify the sync sequence handling across all code paths.

The order of operations in sync handling is critical. Let's verify that all code paths maintain the correct sequence of applying sync data before buffered messages.

✅ Verification successful

Let me analyze the sync sequence handling based on the search results. I'll generate additional scripts to verify the complete flow.


Based on the search results, I can now verify the sync sequence handling. Let me generate the final response.

Sync sequence handling is correctly implemented

The code maintains the proper sequence of operations in sync handling:

  1. During _startSync(): Buffer is correctly cleared and sync state is initialized
  2. During _endSync():
    • _applySync() is called first to apply sync data
    • Buffered state operations are applied after sync data via applyBufferedStateMessages()
    • Buffer is cleared and sync state is reset last
  3. Error handling is properly implemented with early return in _applySync() when sync pool is empty

The sequence is maintained across all code paths, with no race conditions or incorrect orderings found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for proper sync sequence handling
# Look for places where _applySync or applyBufferedStateMessages are called

# Test 1: Verify the sequence of method calls
echo "Checking for sync sequence method calls..."
rg -A 5 "_applySync|applyBufferedStateMessages" --type ts

# Test 2: Look for potential early returns that might skip steps
echo "Checking for potential early returns in sync methods..."
ast-grep --pattern 'return' -l ts

Length of output: 82401


Script:

#!/bin/bash
# Check for all sync-related methods and their interactions
echo "Checking sync-related methods and state management..."
rg -A 10 "(_startSync|_endSync|_applySync)" --type ts

# Look for potential error handling or early returns in sync methods
echo "Checking sync error handling..."
ast-grep --pattern 'class $_  {
  $$$
  _applySync() {
    $$$
  }
  $$$
}'

Length of output: 3532

test/common/modules/live_objects_helper.js (5)

6-7: LGTM: Module setup properly configured for state operations

The addition of necessary dependencies and protocol message creation utility aligns well with the state synchronization requirements.


206-228: LGTM: State message creation methods properly handle protocol requirements

The methods correctly implement:

  • STATE (19) messages for operations
  • STATE_SYNC (20) messages for object state
  • Proper serial handling for message ordering
🧰 Tools
🪛 Biome

[error] 209-209: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


230-258: LGTM: Message processing methods correctly handle state operations

The methods properly:

  • Create protocol messages using the correct message types
  • Record private API calls for test verification
  • Process messages through the channel

260-266: LGTM: Utility methods provide consistent ID generation

The methods generate properly prefixed random IDs for test objects, making it easy to identify object types in tests.


177-204: LGTM: Object creation methods properly handle state synchronization

The mapObject and counterObject methods correctly structure the objects with regionalTimeserial for proper state ordering.

Let's verify the object structure usage:

✅ Verification successful

Consistent usage of regionalTimeserial confirmed across state objects

The verification shows that regionalTimeserial is consistently used:

  • In both mapObject and counterObject helper methods with identical structure
  • In test cases demonstrating proper state synchronization with versioned timestamps (e.g. '@0-0', '@1-0')
  • Test cases validate that older regional timeserials are handled correctly for sync ordering
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistent usage of regionalTimeserial in state objects
# Test: Search for object creation with regionalTimeserial
rg -A 5 'regionalTimeserial' --type js

Length of output: 3410

src/plugins/liveobjects/liveobjectspool.ts (1)

55-67: Verify zero-value timeserial initialization.

The use of zero-value timeserial ensures that any operation can be applied to newly created objects. However, this might lead to race conditions if multiple operations arrive concurrently. Please ensure that:

  1. The zero-value timeserial is always less than any valid operation timeserial
  2. The object's timeserial is properly updated when operations are applied
✅ Verification successful

Zero-value timeserial implementation is safe and correct

The implementation is verified to be safe because:

  1. DefaultTimeserial.zeroValueTimeserial creates a timeserial with timestamp 0 and index 0 (@0-0)
  2. Timeserial comparison is based primarily on timestamp differences, ensuring zero-value is always before any valid operation timeserial
  3. The code properly updates object timeserials during operations and includes checks to prevent applying operations with older timeserials

The race condition concern is addressed by the timeserial comparison logic in LiveObjectsPool which ignores operations with timeserials before the object's current timeserial.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for timeserial comparisons and updates
ast-grep --pattern 'regionalTimeserial.before($_)'
ast-grep --pattern '$_.setRegionalTimeserial($_)'

Length of output: 531


Script:

#!/bin/bash
# Let's check the DefaultTimeserial implementation and usage
ast-grep --pattern 'class DefaultTimeserial'

# Check how zero value timeserial is implemented
ast-grep --pattern 'zeroValueTimeserial'

# Check timeserial comparison logic
rg -A 5 "before\(" src/plugins/liveobjects/

Length of output: 2612


Script:

#!/bin/bash
# Let's check the implementation of DefaultTimeserial.zeroValueTimeserial
rg -A 10 "zeroValueTimeserial" src/plugins/liveobjects/

# Check how timeserials are compared
rg -A 10 "_timeserialCompare" src/plugins/liveobjects/

# Check where timeserials are updated during operations
ast-grep --pattern '$_.setRegionalTimeserial($opRegionalTimeserial)'

Length of output: 7063

test/realtime/live_objects.test.js (2)

1204-1229: LGTM! Test implementation follows best practices.

The test runner implementation is well-structured:

  • Proper connection monitoring and cleanup
  • Correct async/await usage
  • Clear test context initialization

908-1203: 🛠️ Refactor suggestion

Consider refactoring test scenarios while maintaining coverage.

The test scenarios provide excellent coverage of state operation handling during sync sequences, including:

  • Buffering during sync
  • Application after sync completion
  • Discarding on new sync
  • Regional timeserial handling
  • Post-sync immediate application

However, there's significant code duplication in setup, execution, and verification steps.

Consider extracting common patterns into helper functions:

// Helper for sync sequence setup
async function setupSyncSequence(ctx, cursor = 'cursor', prefix = 'serial') {
  const { liveObjectsHelper, channel } = ctx;
  await liveObjectsHelper.processStateObjectMessageOnChannel({
    channel,
    syncSerial: `${prefix}:${cursor}`
  });
}

// Helper for verifying primitive operations
async function verifyPrimitiveOperations(root, primitiveKeyData, description = '') {
  for (const keyData of primitiveKeyData) {
    if (keyData.data.encoding) {
      expect(
        BufferUtils.areBuffersEqual(root.get(keyData.key), BufferUtils.base64Decode(keyData.data.value)),
        `Check root has correct value for "${keyData.key}" key ${description}`
      ).to.be.true;
    } else {
      expect(root.get(keyData.key)).to.equal(
        keyData.data.value,
        `Check root has correct value for "${keyData.key}" key ${description}`
      );
    }
  }
}

src/plugins/liveobjects/livecounter.ts Show resolved Hide resolved
src/plugins/liveobjects/liveobjects.ts Outdated Show resolved Hide resolved
}

// otherwise we need to compare regional timeserials
if (regionalTimeserial.before(existingObject.getRegionalTimeserial())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This condition means we apply an operation if the operation timeserial >= the object timeserial.

The condition should instead be operation timeserial > the object timeserial, otherwise we risk double-counting an operation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see this is fixed in : #1912
Approved there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, the comparsion is fixed both for origin and regional timeserials in the #1912

Base automatically changed from liveobjects/timeserial-fix to integration/liveobjects November 8, 2024 05:16
@github-actions github-actions bot temporarily deployed to staging/pull/1909/bundle-report November 8, 2024 10:50 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1909/typedoc November 8, 2024 10:50 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1909/features November 8, 2024 10:50 Inactive
- state operation messages are buffered while SYNC is in progress
- all buffered operations are discarded when new SYNC starts
- when SYNC ends operations to apply are decided based on the regional
timeserial of the message
- eligible operations are applied via a regular LiveObject operation
application logic

Resolves DTP-955
This refactoring is needed for upcoming tests for buffering of state
operation messages.
Copy link
Member

@owenpearson owenpearson left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@mschristensen mschristensen left a comment

Choose a reason for hiding this comment

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

Approved pending fixes in #1912

(Of course the regional timeserial comparison will be replaced with the vector timeserial approach soon)

@VeskeR VeskeR merged commit 82f1271 into integration/liveobjects Nov 14, 2024
8 of 14 checks passed
@VeskeR VeskeR deleted the DTP-955/buffer-ops-during-sync branch November 14, 2024 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants