Skip to content

Conversation

scottn12
Copy link
Contributor

@scottn12 scottn12 commented Aug 20, 2025

Description

This PR makes TaskManager more consistently behave as a consensus based DDS. This will be useful when implementing rollback as it will make the behavior consistent across all op types.

This PR changes the following functions/events that previously behaved at least partially optimistically to now behave on a consensus basis:

  1. assigned() - This function had previosly used pending local ops to determine if the local client would soon become unassigned (local abandon/complete ops).
  2. "completed" event - This event would previously fire immediately locally after complete() was called locally (without waiting for ack).
  3. queued() - This function uses local ops to determine if we will optimistaclly be tryingn to become assigned for a task after all local ops are processed.

Misc

AB#44704
Fixes AB#7310
Fixes AB#5185

@github-actions github-actions bot added area: dds Issues related to distributed data structures base: main PRs targeted against main branch labels Aug 20, 2025
@scottn12 scottn12 marked this pull request as ready for review August 20, 2025 20:19
@scottn12 scottn12 requested review from Copilot and ChumpChief August 20, 2025 20:19
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 modifies TaskManager to use consensus-based behavior consistently across all operations, removing optimistic behavior that was previously implemented. The main goal is to make TaskManager behavior consistent for implementing rollback functionality by ensuring all operations wait for acknowledgment before reflecting state changes.

Key changes include:

  • Removing optimistic behavior from assigned(), queued(), and "completed" event functions
  • Implementing consensus-based state checking that only reflects acknowledged operations
  • Adding a new queuedOptimistically() method for internal optimistic checks where needed

Reviewed Changes

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

File Description
taskManager.ts Core implementation changes removing optimistic behavior and adding consensus-based state management
taskManager.spec.ts Updated test assertions to reflect new consensus-based behavior expectations
taskManager.fuzz.spec.ts Re-enabled previously skipped fuzz tests that were failing due to eventual consistency issues
interfaces.ts Updated documentation to clarify consensus-based behavior in API comments

Copy link
Contributor

@ChumpChief ChumpChief left a comment

Choose a reason for hiding this comment

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

A couple conditionals I'm not sure about and I'd recommend deferring event emission until internal state is fully updated, but I think this generally looks like it's in a reasonable direction!

if (!this.isAttached()) {
this.taskQueues.delete(taskId);
this.completedWatcher.emit("completed", taskId);
this.emit("completed", taskId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar here re: "completed" handlers not having evidence of the completion in the pending ops when they run

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the particular block you highlighted is a bit different since this is the detached scenario and we won't actually be sending an op at all (we return one line later).

@scottn12 scottn12 requested a review from ChumpChief August 22, 2025 15:16
@scottn12 scottn12 changed the title feat(task-manager): Make TaskManager conesnsus behavior more consistent feat(task-manager): Make TaskManager conesnsus behavior consistent Aug 26, 2025
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 base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants