Skip to content

fix(#9529): async batch replay waits the jittered retry backoff - #9535

Merged
lvca merged 1 commit into
mainfrom
worktree-arcadedb-9529-async-batch-backoff
Oct 9, 2026
Merged

lvca merged 1 commit into
mainfrom
worktree-arcadedb-9529-async-batch-backoff

Conversation

@lvca

@lvca lvca commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Fixes #9529

commitBatch() replayed a batch that hit a ConcurrentModificationException back to back, so the replay raced the workers that caused the conflict on the same bucket tail page. With four workers on one bucket about 1 run in 100 (two cores) ran out of arcadedb.txRetries and reported a whole batch through onError.

The replay now sleeps the TX_RETRY_DELAY / TX_RETRY_DELAY_BASE exponential backoff with full jitter (RetryBackoff, issue #5587) before every attempt after the first, the same policy LocalDatabase.transaction() uses. TX_RETRY_DELAY=0 disables it.

Tests: Issue9529AsyncBatchReplayBackoffTest (hook-observed backoff window, no backoff without conflict, disabled at 0, 4-worker single-bucket load). The hook test fails without the fix. Related #7615/#7667 tests and the rest of the async engine tests pass (119 tests).

Summary by CodeRabbit

Bug Fixes

  • Async batch transactions now apply the configured retry delay after conflicts, avoiding immediate repeated attempts and helping concurrent writes complete more reliably.
  • Batches with no conflicts, or with retry delays set to zero, continue without an added wait.

…e each attempt

commitBatch() replayed a conflicted batch back to back, racing the workers that caused the conflict on the same bucket tail page; with four workers on one bucket about 1 run in 100 exhausted TX_RETRIES and lost a batch. The replay now sleeps the TX_RETRY_DELAY/TX_RETRY_DELAY_BASE exponential backoff with full jitter, like LocalDatabase.transaction().
@lvca lvca added this to the 26.11.1 milestone Oct 8, 2026
@lvca lvca self-assigned this Oct 8, 2026
@mergify

mergify Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@claude

claude Bot commented Oct 8, 2026

Copy link
Copy Markdown

Review

Small, focused fix that reuses RetryBackoff and the existing TX_RETRY_DELAY* settings, so it matches LocalDatabase.transaction(). I found no blocking issues, and I did not build the PR or run its tests.

Code

  • delayBeforeReplay(attempt - 1, ...) gives retry index 0 for the first replay, which matches the test window comments. TX_RETRY_DELAY=0 returns early and skips the hook, as documented.
  • The InterruptedException handler restores the interrupt flag and carries on with the replay. During shutdown, the next begin() or retry may then run on an interrupted thread. Consider failing the batch through the normal error path if the worker is being stopped.
  • Please confirm the failed attempt is rolled back and its page locks released before the sleep, so the backoff holds no resources while it waits.
  • The worst-case stall per batch is roughly txRetries * cap. The PR could mention that.
  • TEST_BATCH_RETRY_DELAY_HOOK follows the existing hook pattern and costs one volatile read, only on the retry path.

Tests

  • The hook-based assertions are deterministic and avoid wall-clock timing, in line with CLAUDE.md.
  • The hooks are static and global, so these tests cannot run concurrently with other tests that use them. They are reset in finally, which is good. Check that the module does not run test classes in parallel.
  • fourWorkersOnOneBucketLoseNoBatch inserts 9.7k records and is probabilistic (about 1% failure before the fix). It is a smoke test rather than a regression test. Consider @Tag("slow") if it takes noticeable time.
  • The first test restores config with getDefValue(). That is fine if database.getConfiguration() is per-instance, so please confirm.
  • Test style matches the guidelines.

Overall this looks good to merge once the points above are checked.

@codacy-production

codacy-production Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Coverage 87.50% diff coverage · -5.64% coverage variation

Metric Results
Coverage variation ✅ -5.64% coverage variation
Diff coverage ✅ 87.50% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (54721c4) 221022 189032 85.53%
Head commit (dd8e9f4) 253654 (+32632) 202633 (+13601) 79.89% (-5.64%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#9535) 16 14 87.50%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4ccc5f52-edaa-4ff6-9166-43ad1521edba
📥 Commits

Reviewing files that changed from the base of the PR and between 54721c4 and dd8e9f4.

📒 Files selected for processing (2)
  • engine/src/main/java/com/arcadedb/database/async/DatabaseAsyncExecutorImpl.java
  • engine/src/test/java/com/arcadedb/database/async/Issue9529AsyncBatchReplayBackoffTest.java

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

Async batch commits now apply configured backoff before retrying a batch. Regression tests check delay behavior and record counts, including a four-worker insert test.

Changes

Async batch retry backoff

Layer / File(s) Summary
Apply retry backoff to batch replay
engine/src/main/java/com/arcadedb/database/async/DatabaseAsyncExecutorImpl.java
commitBatch() reads retry settings from a configuration snapshot and applies RetryBackoff delays before replay attempts. A test hook observes positive delays.
Verify replay delay and batch completion
engine/src/test/java/com/arcadedb/database/async/Issue9529AsyncBatchReplayBackoffTest.java
Tests cover conflicts, no conflict, zero retry delay, and four-worker inserts. They check reported errors and final record counts.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: robfrank

Merge Risk: ⚪ Minimal · up to dd8e9

Batch retries now apply the configured backoff, with no identified issue that needs resolution before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly identifies issue #9529 and the primary change: adding jittered retry backoff to async batch replay.
Description check Passed The description explains the change, motivation, related issue, implementation details, and test coverage. It does not use the template headings or confirm the mvn clean package checklist item, but …
Linked Issues check Passed The PR meets the coding requirements for #9529. commitBatch() calls RetryBackoff.delayMs() before each replay after the first attempt. It uses TX_RETRY_DELAY_BASE and TX_RETRY_DELAY, preserves…
Out of Scope Changes check Passed The changes stay within #9529 scope. The production change adds the required batch replay backoff and a test-only observation hook. The new tests verify the retry policy and the reported contention sc…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.30%. Comparing base (54721c4) to head (dd8e9f4).

Files with missing lines Patch % Lines
...dedb/database/async/DatabaseAsyncExecutorImpl.java 87.50% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main    #9535   +/-   ##
=========================================
  Coverage     77.30%   77.30%           
+ Complexity     4131     4128    -3     
=========================================
  Files          2155     2155           
  Lines        221022   221037   +15     
  Branches      47290    47292    +2     
=========================================
+ Hits         170850   170867   +17     
+ Misses        32028    32026    -2     
  Partials      18144    18144           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant