Skip to content

fix(tables): keep table cells working through lost database connections - #9705

Open
waleedlatif1 wants to merge 9 commits into
stagingfrom
fix/table-cell-db-reset
Open

waleedlatif1 wants to merge 9 commits into
stagingfrom
fix/table-cell-db-reset

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • A reset database socket no longer crashes a table cell. Before, a read outside the task's error handling failed the run, and with no later sweep the cell stayed Queued for good, along with the row's remaining groups.
  • Retry cell reads in process with withDatabaseReadRetry, bounded by attempts and elapsed time.
  • Add withIdempotentWriteRetry for pickup and terminal state writes. It retries connection loss only, never lock, deadlock, or capacity errors.
  • A lost connection leaves a write's outcome unknown, so writeWorkflowGroupStateDurably checks what the last attempt did before repeating it. A landed commit only re-emits its event, so an edit made since survives and a cleared cell stays cleared. Cancel stamps have no guard and are never repeated.
  • A failure before a terminal state now marks the cell as an error so the user can re-run it. If a Stop or newer run owns the cell, the carrier ends instead of starting the next group. If that write fails too, the run still fails and alerts.
  • If a read between groups runs out of retries, fail every unclaimed marker on the row while still holding its lock, then fail the run. Other carriers bail on that lock expecting its owner to drain their markers.
  • A final write that committed despite reporting failure keeps its result instead of being overwritten with an error.
  • On a retry, a write that follows pickup skips a cell the user cleared or a marker from a newer run.
  • Stop storing driver text, SQL, and bound values as the visible cell error. Block errors that are already safe keep their message and block name.
  • No Trigger.dev retry: it replays from the payload's group and would run a billed workflow again for any group already finished.

Type of Change

  • Bug fix

Testing

  • cell-write.integration.ts: real schema, updateRow, and SQL guards through a proxy that forwards COMMIT, withholds the reply, and sends a real TCP reset. Covers a landed commit, a later user edit, a cleared cell, a Stop or newer run during backoff, a repeated cancel stamp, and which row markers get failed.
  • Fails any fault-injection test whose reset never fired.
  • connection-loss.integration.ts: real resets against postgres.js for reads and transactional writes, including a full pool of reset sockets.
  • workflow-column-execution-connection-loss.test.ts, read-retry.test.ts, and sibling cell-write, dispatcher, and resume suites.
  • Reverted each guard separately and watched its named test go red, then restored it.
  • Ran the two integration suites six times locally on disposable Postgres via test:integration, plus scoped Biome. Type-check, check:audits, and the full test suite run in CI.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 5, 2026 9:24am UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment •

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.

All reported issues were addressed across 9 files

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/db/read-retry.ts Resolved
@greptile-apps

greptile-apps Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issue was found.

Summary

Keeps table cells moving through lost database connections without replaying workflows.

  • Table-cell carriers retry database reads and finish row work after repeated failures.
  • Cell state writes survive lost database replies without reviving newer work.
  • Cell error messages hide database details and identify lost connections.

All previous threads were rechecked against the supplied current code; no original finding remains outstanding. None had a supplied Comment number.

  • waleedlatif1 previously deferred sibling-marker cleanup; the current code now covers those markers.
  • waleedlatif1 accepted that an unclaimed, status-only error badge could return after a clear. Writes after pickup now skip cleared cells.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Run cell under row lock] --> B[Retry database operation]
  B --> C{Write reply lost?}
  C -->|Yes| D{State already committed?}
  D -->|Yes| E[Send stored outputs]
  D -->|No| F[Retry guarded write]
  A --> G{Cascade throws?}
  G -->|Yes| H[Fail unclaimed markers]
  H --> I[Tell open tables to refetch]
  I --> J[Release lock and fail task]
Loading

Reviews (8) · Last reviewed commit: "fix(tables): refresh open tables when a ..." · Reviewed by Greptile

Comment thread apps/sim/lib/table/cell-write.ts Resolved
Comment thread apps/sim/lib/table/cell-write.ts Resolved
Comment thread apps/sim/lib/table/constants.ts Resolved
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

Comment thread apps/sim/lib/table/cell-write.ts Resolved
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

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.

All reported issues were addressed across 13 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

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.

All reported issues were addressed across 13 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/table/cell-write.ts Resolved
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

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.

All reported issues were addressed across 13 files

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

No issues found across 13 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Turn on auto-fix | Re-trigger cubic

Track whether a carrier's own pickup landed instead of inferring it from the write. After a pickup,
an unclaimed marker belongs to a newer run, so the write is dropped and the cascade drains it. Before
a pickup, an error over a marker leaves the execution id null so a newer carrier can still claim it.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

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.

All reported issues were addressed across 13 files

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/table/cell-write.ts Resolved
Comment thread apps/sim/lib/table/constants.ts Resolved
A repeat after a lost reply finds nothing left to update, so it cannot name the cells the lost attempt
failed. The cleanup now owns its retry and signals a refetch. Correct the retry budget comment:
maxElapsedMs only decides whether another attempt starts.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

No issues found across 13 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Turn on auto-fix | Re-trigger cubic

This branch was previously deployed

1 inactive deployment
Preview — 283f404d Deployed Nov 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant