Skip to content

fix(#11250): quarantine and resync a database whose crash recovery did not complete (#11259) [skip ci] - #11259

Merged
robfrank merged 2 commits into
mainfrom
fix/11250-ha-power-loss-production-mode
Nov 4, 2026
Merged

robfrank merged 2 commits into
mainfrom
fix/11250-ha-power-loss-production-mode

Conversation

@robfrank

@robfrank robfrank commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #11250 (partial fix, see Coverage; the issue should stay open until the residue in #11258 is handled).

A node whose crash recovery stopped on a WAL gap (WAL preserved as .corrupt, "Recovery ... did not complete") still rejoined Raft, won elections and answered reads. TransactionManager now exposes isLastRecoveryIncomplete(), and RaftHAServer.start() quarantines every open database with an incomplete recovery under the new cause LOCAL_RECOVERY_INCOMPLETE. The existing quarantine machinery then refuses readiness, hands leadership off, persists across restarts and re-installs the database from the leader. A sole voter has no copy to resync from, so it only gets a SEVERE log (same reasoning as #9308).

Test plan

  • Issue11250RecoveryOutcomeTest (engine): WAL-gap recovery reports incomplete, clean recovery does not
  • Issue11250IncompleteRecoveryQuarantineTest (ha-raft): quarantine with the new cause, leadership hand-off, idempotence, sole voter exempt
  • Issue7577ClusterStatusSchemaMatchesTheHandlerTest, Issue7735QuarantineSurvivesRestartTest, Issue9308SoleVoterApplyErrorTest, Issue4958PreservedWALTest still pass
  • Jepsen LazyFS bank + elle sweep (cannot be run here)

Coverage

Review cycles

Cycle 1: claude review had no blocking items. Applied: flag is now sticky (point 1), WARNING instead of FINE (point 3). Deferred: sole-voter status surfacing (point 2), real-server scan test (point 4, stated in Coverage), spec line width nit (point 5). Later cycles were not awaited by the agent; the developer owns the rest.

…ned and resynced instead of serving

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 24 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a36a9af2-0cef-476e-bc7e-dce1977ff015
Commits

Reviewing files that changed from the base of the PR and between fce9f92 and 730a03e.

Files selected for processing: 7
  • engine/src/main/java/com/arcadedb/engine/TransactionManager.java
  • engine/src/test/java/com/arcadedb/engine/Issue11250RecoveryOutcomeTest.java
  • ha-raft/src/main/java/com/arcadedb/server/ha/raft/ArcadeStateMachine.java
  • ha-raft/src/main/java/com/arcadedb/server/ha/raft/DivergenceCause.java
  • ha-raft/src/main/java/com/arcadedb/server/ha/raft/RaftHAServer.java
  • ha-raft/src/test/java/com/arcadedb/server/ha/raft/Issue11250IncompleteRecoveryQuarantineTest.java
  • server/src/main/java/com/arcadedb/server/http/handler/openapi/PluginApiSpec.java
  • Autofix · 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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@mergify

mergify Bot commented Nov 3, 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.

@codacy-production

codacy-production Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 5 complexity

Metric Results
Complexity 5

View in Codacy

🟢 Coverage 76.32% diff coverage · -4.63% coverage variation

Metric Results
Coverage variation ✅ -4.63% coverage variation
Diff coverage ✅ 76.32% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (fce9f92) 260052 227534 87.50%
Head commit (730a03e) 292917 (+32865) 242742 (+15208) 82.87% (-4.63%)

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 (#11259) 38 29 76.32%

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.

@claude

claude Bot commented Nov 3, 2026

Copy link
Copy Markdown

Review of #11259: the change is small, reuses the existing quarantine machinery, and the unit tests are on point. I have no blocking concerns and see no security issue. I only read the diff; I did not build or run the tests.

Points to check

  1. lastRecoveryIncomplete = !completed is assigned on every recoverWALFiles() call. If a later call finds nothing to replay, it resets the flag to false and hides an earlier incomplete outcome. Please check whether checkIntegrity() or reopen paths can call it twice in one instance. If they can, make the flag sticky (only set it to true here, and clear it on an explicit reset).
  2. The WAL is preserved as .corrupt, so the next restart will not report an incomplete recovery. You rely on the persisted quarantine surviving restarts (Issue7735). That looks right, but the sole-voter case has no such protection: after one restart it silently serves the damaged copy. The SEVERE log is the only trace, and it is easy to miss. Consider surfacing it in cluster status or health.
  3. quarantineDatabasesWithIncompleteRecovery() swallows RuntimeException at FINE level. A failure to read the recovery outcome means the node skips the safety check silently. WARNING would be safer. srv.getDatabase(dbName, false, false) could also open a database as a side effect, so please confirm it does not.
  4. The scan has no test against a real server, as you note in the PR description. A small integration test would help: corrupt a WAL, restart, and assert the quarantine.
  5. Nit: in PluginApiSpec the divergenceCause description line now exceeds the usual width.

Verdict: good fix for the partial scope, pending point 1.

@claude

claude Bot commented Nov 3, 2026

Copy link
Copy Markdown

Review of #11259

No blocking issues found.

What it does well

Points to consider

  1. quarantineDatabasesWithIncompleteRecovery() runs in start() before raftClient is built. Please confirm that triggerDatabaseResync and handOffLeadershipIfLeader tolerate the Raft server not being fully up yet. If they are no-ops or deferred in that state, the node would stay quarantined without a resync until something else triggers one. The PR notes that the scan has no real-server test, and this is the case that test would exercise. A small integration test with a pre-seeded .corrupt or gap WAL would close the gap.
  2. The flag lives only in memory for the lifetime of the TransactionManager. On a second restart before the resync finishes, recovery finds no WAL and the flag is false. Persisted quarantine (#7495's quarantine hangs on an in-memory flag, so a restart brings the node back Ready with alerts:[] and permanently missing the committed entry #7735) should cover this, but only if quarantineDatabase persists before a crash. Please confirm that.
  3. The sole-voter case only logs SEVERE (you deferred this). Surfacing it in cluster status or a health check would make it much harder to miss.
  4. Nit: the divergenceCause string in PluginApiSpec now exceeds the 160-column line width.
  5. Nit: the two consecutive if (!completed) blocks in TransactionManager could be merged.

Security: nothing concerning. There is no new input surface, dependency or external I/O. The change makes a node refuse to serve possibly damaged data.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.15789% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.39%. Comparing base (fce9f92) to head (730a03e).

Files with missing lines Patch % Lines
...om/arcadedb/server/ha/raft/ArcadeStateMachine.java 57.57% 9 Missing and 5 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #11259      +/-   ##
============================================
- Coverage     79.40%   79.39%   -0.01%     
- Complexity     4997     4999       +2     
============================================
  Files          2327     2327              
  Lines        260052   260090      +38     
  Branches      56975    56985      +10     
============================================
+ Hits         206487   206498      +11     
- Misses        32559    32592      +33     
+ Partials      21006    21000       -6     

☔ 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

Development

Successfully merging this pull request may close these issues.

1 participant