Skip to content

fix(#7768): a WAL file reopens the channel a thread interrupt closed, so one interrupted commit no longer kills a pool slot - #8148

Merged
robfrank merged 5 commits into
mainfrom
fix/7768-wal-slot-dies-on-interrupted-commit
Sep 22, 2026
Merged

robfrank merged 5 commits into
mainfrom
fix/7768-wal-slot-dies-on-interrupted-commit

Conversation

@robfrank

@robfrank robfrank commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #7768

WALFile held a raw FileChannel with no recovery for it, so a thread interrupted anywhere inside a commit made NIO close that channel (AbstractInterruptibleChannel.begin() fires the interruptor even when the flag is already set, so no timing race is needed) and nothing ever repaired or replaced the slot: the WALFile stayed in TransactionManager.activeWALFilePool with open == true and a dead channel, checkWALFiles() caught the resulting ClosedChannelException ahead of the IOException branch that was written to fence and answered it with a bare close(), and the size-based rotation branch that could have replaced the slot requires isOpen() and so could never fire for it again. Every later transaction whose threadId % poolSize landed on that slot then stalled for the full 30 s WRITE_WAL_TIMEOUT and failed with a message that reads like a slow disk, on a database that still reported itself open - and with the documented arcadedb.txWalFiles=1 the database stopped committing outright. This PR gives WALFile the #4930 channel-reopen treatment PaginatedComponentFile already has for the data files, stops checkWALFiles() swallowing the case #7479 wrote that fence for, and lets a commit fall back to the rest of the WAL pool instead of spinning on one slot for 30 s.

Finding ledger

The issue lists three suggested fixes plus one separate remark. Every one carries a final status:

  • 1. WALFile has no reopen-after-ClosedChannelException recovery - fixed, on every channel operation in the class, not only the commit path (append, force, getSize, and all three positional reads through the new readChunk)
  • 2. checkWALFiles() should replace the dead slot rather than merely close it - argued, not implemented; see Completeness below. With finding 1 in place a slot can only go dead when the reopen is refused, and finding 3 then fences the database, so there is no live pool left to rotate a fresh file into
  • 3. The narrower ClosedChannelException catch silently steals the case the IOException branch was written to fence - fixed, the catch is gone and the only thing that short-circuits the fence now is a file closed on purpose concurrently with the pass (a shutdown racing the housekeeping timer)
  • 4. (the "Separately" remark) writeTransactionToWAL should not spin 30 s against a slot it has already observed to be closed, and the message should not read as a disk-latency problem - fixed, by falling back to the other files in the pool and by naming the per-slot pool state in the timeout message

Completeness

The invariant

A WALFile that is still logically open (open == true) and whose backing file still exists on disk recovers its FileChannel and completes the I/O when a thread interrupt closed that channel; a transient interrupt therefore never leaves a permanently unusable slot in activeWALFilePool.

Enumerating every way to violate it

Every channel operation in WALFile is a way to meet the interrupt, so the sweep is over channel.* rather than over the one call site the report named. Line numbers below are from the sweep as it was run, i.e. against main before the first commit:

$ grep -n "channel\.\(read\|write\|size\|force\|tryLock\|close\)" engine/src/main/java/com/arcadedb/engine/WALFile.java
124:      return channel.tryLock();                                # constructor
153:      channel.close();                                         # close()
364:          final int n = channel.read(buffer, readPos);         # getTransaction, delta read
423:          final int n = channel.read(chunk, scanPos + read);   # findNextValidTransactionPosition, gap scan
575:      channel.force(false);                                    # writeTransactionToFile, txWalFlush=1
577:      channel.force(true);                                     # writeTransactionToFile, txWalFlush=2
587:    return channel.size();                                     # getSize()
636:      final int n = channel.read(buffer, readPos);             # readFully
650:    long writePos = channel.size();                            # append()
652:      writePos += channel.write(buffer, writePos);             # append()

Who drives each of them:

$ grep -rn --include='*.java' "getFirstTransaction()\|findNextValidTransactionPosition" . | grep "/src/main/"
engine/.../TransactionManager.java:458:          walPositions[i] = file.getFirstTransaction();
engine/.../TransactionManager.java:461:          if (walPositions[i] == null && file.findNextValidTransactionPosition(0) >= 0) {
engine/.../TransactionManager.java:503:          if (nextTx == null && walFile.findNextValidTransactionPosition(nextPos) >= 0) {
engine/.../WALFile.java:349, 518                                  # the declarations

All three sites are inside checkIntegrity(), i.e. the recovery path at open time.

$ grep -rn --include='*.java' "file.getSize()\|walFile.getSize()" . | grep "/src/main/"
engine/.../TransactionManager.java:1159:  if (file != null && file.isOpen() && file.getSize() > MAX_LOG_FILE_SIZE) {

The only runtime caller of WALFile.getSize() is the once-a-second housekeeping pass.

$ grep -rn --include='*.java' "writeTransactionToFile" . | grep "/src/main/"
engine/.../TransactionManager.java:343:  file.writeTransactionToFile(database, pages, sync, file, txId, bufferChanges);
engine/.../WALFile.java:667                                        # the declaration

One production call site, which passes the same object as receiver and as the file parameter - so replacing channel.force(...) with force(...) (implicit this) preserves the original receiver exactly.

Nothing outside engine touches the instance state this PR changes:

$ grep -rln --include='*.java' "WALFile" . | grep -v /target/ | grep -v "^./engine/"
ha-raft/.../ArcadeStateMachine.java, RaftReplicatedDatabase.java, SnapshotInstaller.java
integration/.../AbstractImporter.java
server/.../ServerDatabase.java

Every one of those references only the static nested types (WALTransaction, WALPage, FlushType), the MAGIC_NUMBER constant or the static deleteIfNotHeldByAnotherInstance - never an instance field. No API break.

Coverage table

Entry point Covered by fix? Covered by a test?
commit -> writeTransactionToWAL -> acquire() -> writeTransactionToFile -> append() -> channel.size()/channel.write() yes yes - appendReopensAChannelTheInterruptClosedAndWritesTheWholeRecord
commit -> writeTransactionToFile -> channel.force() (arcadedb.txWalFlush 1 or 2) yes yes - forceReopensAChannelTheInterruptClosed
housekeeping timer -> checkWALFiles() -> getSize() -> channel.size() yes yes - getSizeReopensAChannelTheInterruptClosed
recovery -> checkIntegrity() -> getFirstTransaction()/getTransaction()/findNextValidTransactionPosition()/readFully() -> channel.read() yes, all three read sites funnelled through readChunk() yes - recoveryReadsReopenAChannelTheInterruptClosed
the reported end-to-end symptom: a clean thread's commit after someone else's interrupted one yes yes - anInterruptedCommitLeavesTheWalPoolSlotUsable (txWalFiles=1)
checkWALFiles() swallowing ClosedChannelException instead of fencing (the #7479 contract) yes yes - aClosedChannelNoReopenCanRepairFencesInsteadOfBeingSwallowed
a slot closed on purpose concurrently with the housekeeping pass must stay benign yes yes - aSlotClosedConcurrentlyWithTheHousekeepingPassDoesNotFence
writeTransactionToWAL spinning 30 s on a slot whose file is permanently closed yes, falls back to the other pool files yes - aCommitFallsBackToAnotherWalFileWhenItsOwnSlotIsClosed
the timeout message reading as disk latency yes yes - theWalTimeoutDiagnosticNamesThePoolStateInsteadOfImplyingASlowDisk
a channel closed on purpose must never be reopened (the #4930 guard) yes, reopenChannel() refuses on !open yes - aChannelClosedOnPurposeIsNeverReopened
a WAL file gone from disk must never be re-created by the reopen (the #7479 guard) yes, reopenChannel() refuses when the path is absent yes - aWalFileGoneFromDiskIsNeverRecreatedByTheReopen
checkWALFiles() opening a replacement txlog_<n>.wal over a dead slot (the issue's suggestion 2) argued - see below n/a
channel.tryLock() in the constructor, channel.close() in close() argued - a channel just constructed, and one being torn down on purpose n/a

The two argued rows

Suggestion 2 (replace the dead slot) is deliberately not implemented. With the reopen in place, a slot can only stay dead when reopenChannel() refuses, which it does in exactly two cases: the file was closed on purpose (the database is shutting down, so the pool is going away regardless) or the file is gone from disk. The second is precisely the #7479 case, and checkWALFiles() now fences the database over it - a fenced database has no live pool to rotate a fresh file into, so opening a replacement txlog_<n>.wal there would create a file nothing will ever write to. The one branch that would leave a dead slot behind is the IOException handler's "no LocalDatabase to fence" fallback, and that is unreachable:

$ grep -rn --include='*.java' "DatabaseInternal getEmbedded()" . | grep "/src/main/"
server/.../ServerDatabase.java:714:  public DatabaseInternal getEmbedded() { return wrapped.getEmbedded(); }
engine/.../LocalDatabase.java:2504:  public DatabaseInternal getEmbedded() { return this; }
engine/.../DatabaseInternal.java:81:  DatabaseInternal getEmbedded();

Both implementations bottom out at LocalDatabase.getEmbedded() returning this, so database.getEmbedded() instanceof LocalDatabase always holds and the fence always runs. Separately, the new pool fallback means even a genuinely dead or null slot no longer takes its threads down: they are served by another file in the pool.

tryLock() and close() are not wrapped. tryLock() runs in the constructor on a channel created two lines above it, and close() is the deliberate teardown the reopen must never undo. Reopening in either would be wrong, not merely unnecessary.

Reachability

The changed code runs on the live commit path, not only under the new tests. Every SEVERE reopen line in the runs below was emitted by production code driven through an ordinary database.transaction(...) or through the real housekeeping pass, and the end-to-end test drives the fix through LocalDatabase with arcadedb.txWalFiles=1. Nothing is behind a new flag.

The tests were proved able to fail

Reverting both main-source files to HEAD and rerunning the new class (the force/isActive/describeWALFilePool calls neutralised so it still compiles) fails 8 of 10, with exactly the symptoms the issue reports:

[ERROR] Tests run: 10, Failures: 2, Errors: 6
  aCommitFallsBackToAnotherWalFileWhenItsOwnSlotIsClosed   30.21 s  » Timeout on writing transaction to WAL
  anInterruptedCommitLeavesTheWalPoolSlotUsable                     » Transaction error on commit
  appendReopensAChannelTheInterruptClosed...                        » ClosedByInterruptException
  getSizeReopensAChannelTheInterruptClosed                          » ClosedByInterruptException
  forceReopensAChannelTheInterruptClosed                            » ClosedByInterruptException
  recoveryReadsReopenAChannelTheInterruptClosed                     » WALException reading WAL file
  aClosedChannelNoReopenCanRepairFencesInsteadOfBeingSwallowed      » database not fenced
  aWalFileGoneFromDiskIsNeverRecreatedByTheReopen                   » no FileNotFoundException

The two that pass in both worlds are the negative guards (aChannelClosedOnPurposeIsNeverReopened, aSlotClosedConcurrentlyWithTheHousekeepingPassDoesNotFence), which is what a guard should do.

Residual risk

One deliberate behaviour change to an existing test

WALFileGetTransactionTest.ioErrorOnChannelThrowsWALException induced its I/O error by closing the channel through reflection. That is now, by design, a recoverable condition, so the test would have gone green for the wrong reason. Its assertion is untouched - the contract it exists for, "an I/O error surfaces as WALException and is never swallowed into a null", is still exactly what it checks - and only the inducement changed: the file is deleted as well, which makes the reopen legitimately refuse (#7479's guard) and the error genuinely unrecoverable. Calling this out explicitly because it is the one place where this PR edits a test it did not write.

Adversarial pass

The Task tool is not available in this environment, so no isolated subagent could be spawned for Phase 1.5; the pass was self-administered against the diff, with each finding checked by command rather than by recollection.

  • writeTransactionToFile changing the fsync receiver from this to the file parameter - real, fixed here before the PR opened. The first draft wrote file.force(...) to match the adjacent file.append(...); channel.force(...) had always been this.channel, and although the single production call site provably passes the same object, the literal translation is force(...). Changed, with a comment recording why.
  • Unbounded SEVERE logging on a reopen-per-read recovery scan - real, out of scope, filed as WALFile's interrupt reopen logs one SEVERE line per channel operation, so an interrupted recovery scan emits an unbounded flood #8139 and named under Residual risk.
  • The advisory lock being dropped across a reopen - real but inconsequential, argued under Residual risk with the grep over acquiredLock()'s three readers.
  • "The append retry could leave a torn prefix in the log" - not real, and the reason is in the code. The retry restarts from the offset the first attempt started at, recorded before the first write, rather than from the reopened channel's size() - which would count whatever bytes the interrupted write managed to put down and append the record after them. appendReopens…AndWritesTheWholeRecord asserts the file's bytes equal the record exactly.
  • "The pool fallback breaks the single-writer assumption append() documents" - not real. The fallback still goes through WALFile.acquire(), which is synchronized, so two threads that fall back onto the same file serialize on that file's monitor exactly as two threads hashing to it always did.
  • "Writing a transaction to a different WAL file than the thread's slot breaks recovery" - not real. checkIntegrity() reads every txlog_*.wal in the directory and merges them by txId; the threadId % length hash is a contention spreader, not a constraint. WalCommitOrderingTest, WalRecoveryCorrectnessTest, WALVersionGapRecoveryTest and Issue4508TornWALRecoveryTest all pass.
  • "The fallback scan adds contention on the hot path" - not real. It runs only after this thread's own slot has already refused, and it exits the moment one file accepts; the loop only repeats when every file in the pool is !active || !open, a state in which there are no successful writers to contend with. The normal path is one extra (JIT-inlinable) call and no extra allocation - tryWriteTransactionToWALFile captures exactly what the old inline lambda captured.
  • "A reopen could race a concurrent close() and resurrect the file" - not real. reopenChannel() is synchronized and close()/drop()/acquire() hold the same monitor, so the two cannot interleave; whichever runs first wins, and reopenChannel() refuses outright once open == false.

Test plan

  • mvn -o -pl engine test -Dsurefire.includes="**/Issue7768InterruptedWalSlotTest.java" - 11/11 green
  • The same class against HEAD's main sources - 8 of 10 fail, including a 30.2 s Timeout on writing transaction to WAL (evidence above)
  • Every WAL, TransactionManager, interrupt and flush test class in engine - 105/105 green:
    -Dsurefire.includes="**/*WAL*Test.java,**/*Wal*Test.java,**/TransactionManager*Test.java,**/InterruptedIOFailsLoudTest.java,**/PaginatedComponentFileInterruptedWriteTest.java,**/FlushRobustnessTest.java,**/Issue4508*Test.java,**/Issue4509*Test.java,**/Issue4958*Test.java,**/Issue7121*Test.java,**/Issue6932*Test.java"
  • Full engine module, -DexcludedGroups=benchmark,vector,slow - 16125 tests, 0 failures, 0 errors, 22 skipped
  • The WAL/TransactionManager subset re-run after the final force(...) receiver change - 108/108 green
  • Reviewer check worth making by hand: run a workload that cancels HTTP/gRPC requests mid-commit with arcadedb.txWalFiles=1, and confirm the database keeps committing instead of stalling 30 s per transaction

Coverage

Entry points this fix covers, from the table above: the commit WAL append, the commit fsync, the housekeeping size check, all three recovery read sites, the checkWALFiles fence decision, and the WAL-pool selection in writeTransactionToWAL.

Known gaps

Review cycles

Four review cycles ran against the claude bot and Codacy. CodeRabbit never reviewed this PR: its check reports Review rate limited ("You've used all 4 included reviews currently available") and it posted no review and no inline threads, so there are no CodeRabbit threads to resolve.

# Head What changed Review outcome
1 1a017c6 the fix as opened claude: no correctness, performance or security issues; "didn't find any … beyond what's already called out". Codacy: 1 new high ErrorProne issue
2 85269ed carry the closing exception into retryAfterReopen (logged, and attached as suppressed when the retry also fails) instead of binding and dropping it; and a real defect this surfaced - readChunk's retry now rewinds the buffer to where the attempt began, the read-side twin of the offset append already records, since an interrupted read can transfer bytes before throwing claude: "Nothing here blocks merge from my read". Codacy still failing
3 9da89d0 read the actual Codacy annotation instead of guessing further: TransactionManager.java:1249, "An instanceof check is being performed on the caught exception". The instanceof existed only to avoid a second copy of the #7479 fence, so the fence moved into fenceForInaccessibleWALFile() and ClosedChannelException got its own clause back - one that fences rather than swallowing claude: no correctness bug; two non-blocking notes. Codacy: success
4 9d0237d both of those notes taken: isActive() narrowed to package-private to match acquiredLock(), and tryWriteTransactionToWALFile's javadoc now states the fallback's scope boundary - a refusal is routed elsewhere, a throw is not, because a WAL file vanishing under a live instance is the #7479 case and writing more data anywhere is the opposite of what the fence is for claude: no correctness bug; one nit about a test's coupling
5 1bba4d4 that nit, taken as an assertion rather than the suggested comment: ClosingUnderneathWALFile stages its race on checkWALFiles() calling isOpen() twice, so the call count is now asserted - a comment cannot fail a build, and a cached read would otherwise leave the test passing while exercising nothing claude: "I don't see anything blocking here". Codacy success, lint green

The 108-test WAL/TransactionManager/interrupt/flush set was re-run green after every one of these commits.

Adversarial pass - additions from the review loop

Beyond the seven findings recorded above, two more were produced during the cycles and both are fixed here:

  • readChunk's retry could double-write into the buffer - real, and the more interesting of the two because it was not reported by any bot: re-reading the exception-cause change surfaced that an interrupted channel.read can transfer bytes before throwing, so retrying from the same file offset without rewinding the buffer would write them twice and drift the caller's readPos out of step with the buffer position. append had been given this care and the read path had not. Fixed in 85269ed.
  • The instanceof on a caught exception - real, found by Codacy and confirmed from the check-run annotation rather than guessed at. Fixed in 9da89d0, and the code is better for it: one fence site instead of a merged catch.

Deferred items

One non-blocking suggestion from the final review is not applied, recorded here rather than silently dropped:

retryAfterReopen() calls reopenChannel() and io.run() as two separate calls, so the two don't share one critical section - a close() from another thread (e.g., shutdown) can land in the gap between them, and the retried I/O then throws ClosedChannelException again with no second retry. This looks intentional and consistent with how the rest of the PR treats "closed concurrently with the pass" as benign … but it might be worth one line in the retryAfterReopen javadoc calling this out explicitly.

Rationale for deferring: the reviewer's own reading is right - it is intentional, and the behaviour it describes is correct (a database being closed underneath a retry should fail that operation, not fight the shutdown for it). What is left is a documentation line, and this PR had already spent its review budget; adding an unreviewed commit for a javadoc sentence trades a reviewed head for a cosmetic gain. Worth folding into #8139, which already touches this method's logging.

Final state

clean-approval - the latest review on the final head (1bba4d4) says nothing blocks the merge, no major issue is open, Codacy is green, and there are no CodeRabbit threads (rate-limited, never reviewed). The merge is the developer's: this branch was never merged, closed or force-pushed.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved transaction reliability when write-ahead log files become temporarily unavailable or channels are interrupted.
    • Transactions can now retry using another active log file when the selected file cannot be used.
    • Improved recovery for interrupted commits and WAL operations, including reads, writes, sizing, and flushing.
    • Prevented unnecessary database fencing during expected shutdown-related channel closures.
    • Improved timeout and storage error diagnostics with clearer transaction and pool-state details.

… so one interrupted commit no longer kills a pool slot

WALFile held a raw FileChannel with no recovery for it. A thread interrupted anywhere inside a
commit makes NIO close that channel - AbstractInterruptibleChannel.begin() fires the interruptor
even when the flag is already set, so no timing race is needed - and nothing then repaired or
replaced the slot: the WALFile stayed in TransactionManager's active pool with open == true and a
dead channel, checkWALFiles() caught the ClosedChannelException ahead of the IOException branch
written to fence and answered it with a bare close(), and the size-based rotation branch that could
have replaced the slot requires isOpen() and so could never fire for it again. Every later
transaction hashing to that slot stalled 30s and failed with a message reading like a slow disk, on
a database still reporting itself open; with the documented arcadedb.txWalFiles=1 the database
stopped committing outright.

Three parts:

- WALFile gains the #4930 channel-reopen recovery PaginatedComponentFile already has for the data
  files, on every channel operation in the class rather than only the commit path: append (which
  retries from the offset the first attempt started at, so an interrupted partial write is
  overwritten instead of leaving a torn prefix ahead of the record), force, getSize, and all three
  positional reads through a new readChunk funnel. Only an accidental close is repaired: a file
  closed on purpose stays closed, and a path gone from disk is never re-created.
- checkWALFiles() no longer catches ClosedChannelException ahead of IOException. The only one that
  can still reach it is one the reopen refused, which means the file is gone - the #7479 case that
  branch fences on. A file closed on purpose concurrently with the pass stays benign.
- writeTransactionToWAL offers the transaction to the other files in the pool before spinning on its
  own slot, and its timeout message names the per-slot pool state instead of implying disk latency.

WALFileGetTransactionTest.ioErrorOnChannelThrowsWALException induced its I/O error by closing the
channel, which is now recoverable by design; it deletes the file as well so the condition is
genuinely unrecoverable and the assertion it exists for is unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: edd74a5a-85d4-4b52-8fee-6000d2dabbd9

📥 Commits

Reviewing files that changed from the base of the PR and between 9a88be7 and 1bba4d4.

📒 Files selected for processing (4)
  • engine/src/main/java/com/arcadedb/engine/TransactionManager.java
  • engine/src/main/java/com/arcadedb/engine/WALFile.java
  • engine/src/test/java/com/arcadedb/engine/Issue7768InterruptedWalSlotTest.java
  • engine/src/test/java/com/arcadedb/engine/WALFileGetTransactionTest.java

Included review availability: Your plan provides up to 4 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The change adds interrupted-channel recovery to WALFile, fallback across active WAL slots, improved inaccessible-file handling, and diagnostics for WAL pool state. New tests cover recovery, fencing, fallback, missing files, and timeout reporting.

Changes

WAL recovery and transaction continuity

Layer / File(s) Summary
WAL channel reopen and retry
engine/src/main/java/com/arcadedb/engine/WALFile.java
WALFile reopens channels closed by interrupts, reacquires locks, retries reads, writes, force, and size operations, preserves interrupt status, and rewrites interrupted appends from the original offset.
WAL pool fallback and diagnostics
engine/src/main/java/com/arcadedb/engine/TransactionManager.java, engine/src/main/java/com/arcadedb/engine/WALFile.java
Transaction writes try other active WAL files when a selected file refuses the write. Timeout diagnostics include transaction ID, pool size, and per-slot state.
Housekeeping fencing behavior
engine/src/main/java/com/arcadedb/engine/TransactionManager.java
Housekeeping ignores closed files that are no longer open and fences local databases when an open WAL file remains inaccessible.
Interrupted WAL regression coverage
engine/src/test/java/com/arcadedb/engine/Issue7768InterruptedWalSlotTest.java, engine/src/test/java/com/arcadedb/engine/WALFileGetTransactionTest.java
Tests validate channel recovery, append integrity, interrupt preservation, missing-file handling, pool fallback, fencing behavior, shutdown races, and timeout diagnostics.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant TransactionManager
  participant WALFile
  participant FileChannel
  participant WALPath
  TransactionManager->>WALFile: write transaction
  WALFile->>FileChannel: append and force
  FileChannel-->>WALFile: ClosedChannelException
  WALFile->>WALPath: verify WAL file exists
  WALFile->>FileChannel: reopen channel and reacquire lock
  WALFile->>FileChannel: retry append and force
  WALFile-->>TransactionManager: completed write or propagated failure
Loading

Suggested reviewers: lvca

Merge Risk: ⚪ Minimal · up to 1bba4

The change restores interrupted WAL channels and provides fallback across available WAL slots while preserving fencing for unrecoverable files. It is ready to merge with minimal residual risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 32.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 43 functions across 4 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 the main change: reopening WAL channels closed by thread interrupts so interrupted commits do not permanently disable a pool slot.
Description check ✅ Passed The description thoroughly explains the motivation, related issue, implementation, test coverage, residual risks, and review history. It does not use all template headings verbatim and does not explic…
Linked Issues check ✅ Passed The PR meets the coding requirements in [#7768]. WALFile reopens an accidentally closed channel and retries append, size, force, and positional read operations. It clears and restores the interrupt …
Out of Scope Changes check ✅ Passed The reviewed changes stay within [#7768]. The production changes repair WAL channels, handle inaccessible WAL files, preserve fencing behavior, add pool fallback, and improve related diagnostics. The …
  • 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

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.

@mergify

mergify Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@codacy-production

codacy-production Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 30 complexity

Metric Results
Complexity 30

View in Codacy

🟢 Coverage 92.13% diff coverage · -6.19% coverage variation

Metric Results
Coverage variation ✅ -6.19% coverage variation
Diff coverage ✅ 92.13% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (642f431) 187386 155921 83.21%
Head commit (1bba4d4) 220002 (+32616) 169450 (+13529) 77.02% (-6.19%)

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 (#8148) 89 82 92.13%

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 Sep 22, 2026

Copy link
Copy Markdown

Review

This is a careful, well-scoped fix. I traced the concurrency story by hand (couldn't run mvn/gh api in this sandbox - both require interactive approval that isn't available here - so this is a static review, not a re-run of the test suite the PR description reports).

Correctness

  • The reopenChannel() gating is sound: open only transitions true -> false (in close()), never back, and reopenChannel()/close()/acquire() all synchronize on the same monitor, so there's no window where a deliberate close races a reopen into resurrecting a channel. Verified against the intrinsic-lock reentrancy that lets append()'s retry call reopenChannel() (synchronized) from inside acquire()'s own synchronized block on the same thread - that's safe only because it's the same thread re-entering, and it is.
  • checkWALFiles()'s new 'e instanceof ClosedChannelException && !file.isOpen()' guard is correctly exhaustive: reopenChannel() throws a bare ClosedChannelException only via the !open branch, and FileNotFoundException (a different IOException subtype) for the "file gone from disk" branch - so the GraphImporter fails to load data properly when ArcadeDB server is alive #7479 fencing path is never accidentally skipped, only the "closed on purpose" shutdown race is. I traced both branches end-to-end against getSize()'s call chain and they land where the PR claims.
  • append()'s retry restarts from the offset recorded before the first write attempt, not from the reopened channel's size() - so a torn partial write is overwritten rather than leaving a gap ahead of the record. Confirmed by reading appendAt.
  • The writeTransactionToFile/force() receiver change (file.force() -> force(), i.e. this) is correct: tryWriteTransactionToWALFile is the sole production call site and always passes the same object as both receiver and file argument, confirmed with grep.
  • Single-writer assumption for append()/appendAt is preserved - still funneled through acquire()'s synchronized guard.

One thing worth double-checking in CI rather than by inspection

retryAfterReopen logs at SEVERE on every reopen, including once per chunk in getTransaction's delta-read loop and findNextValidTransactionPosition's scan. The PR body already flags this as a known gap (#8139, deliberately out of scope) - agreed that's the right call for this PR, just flagging so it doesn't get lost.

Minor

  • describeWALFilePool and the new pool-fallback loop in writeTransactionToWAL only run on the unhappy path (a slot that acquire() already refused), so no hot-path allocation/contention concern - the common case is unchanged (one acquire() call, one lambda).
  • WALFile.force(boolean) is package-private, used directly by the new tests in the same package - reasonable, keeps it off the public API surface.

Test coverage

Good - one test per entry point in the coverage table (append/force/getSize/all three read sites, the end-to-end interrupted-commit-with-txWalFiles=1 case, the checkWALFiles fencing regression, the pool-fallback timeout-avoidance case, and two negative guards for "never resurrect a deliberately-closed or deleted file"). The one existing test that had to change (WALFileGetTransactionTest.ioErrorOnChannelThrowsWALException) is adjusted correctly to keep exercising what it was written for, by deleting the file so the condition is genuinely unrecoverable rather than now-legitimately-recoverable.

Didn't find any correctness, performance, or security issues beyond what's already called out. The design consistently follows the existing PaginatedComponentFile.reopenChannelUnderWriteLock() (#4930) idiom rather than introducing a new pattern.

…on a retried read

Codacy reported one new high-severity ErrorProne issue on the diff; the only candidates in it were
the catch blocks that bound the exception and then dropped it. Rather than silence them, the cause
is now carried: retryAfterReopen takes the ClosedChannelException that triggered the recovery, logs
it with the diagnostic instead of passing null, and attaches it as a suppressed exception when the
retry itself fails - so a refused reopen no longer hides what closed the channel. The dead-handle
close inside reopenChannel() logs its failure at FINE instead of discarding it.

Re-reading readChunk for that change surfaced a real defect of its own, the read-side twin of the
one append() already guards against: an interrupted read can transfer bytes into the buffer before
throwing, and the retry reads from the SAME file offset, so without rewinding the buffer to where
the attempt began those bytes would be written twice and the caller's readPos would drift out of
step with the buffer position. The position is now recorded before the attempt and restored on
retry.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@claude

claude Bot commented Sep 22, 2026

Copy link
Copy Markdown

Review

I independently traced the interrupt/reopen/retry logic in WALFile.java and the pool-fallback/fencing logic in TransactionManager.java line by line (not just the PR description, which is already unusually thorough) and did not find a correctness bug. Notes below.

Correctness

  • Monitor reuse is sound. acquire(), close(), and the new reopenChannel() are all synchronized on the same instance monitor, and acquire()'s callback (which drives append()/force()) can re-enter reopenChannel() on the same thread because Java's intrinsic lock is reentrant - no deadlock. A concurrent unsynchronized reader (getSize(), the recovery reads) that hits reopenChannel() will simply block until an in-flight acquire()-held write finishes, which is the correct ordering.
  • append()'s retry-from-original-offset is correct. startPos is captured before the first write attempt and reused on retry regardless of how far the interrupted write got, so the retry fully overwrites the region rather than resuming past a partial write. Since these are positional writes into a region no committed record has claimed yet, this can't produce a torn prefix.
  • readChunk()'s buffer-rewind-on-retry is correct for both call sites that loop over it (getTransaction's delta read and findNextValidTransactionPosition's chunk scan): positionBeforeAttempt is captured per-call, inside the outer while-loop, so a retry only undoes the current call's partial transfer, not previously-accumulated bytes.
  • The reopenChannel() refusal paths are both exercised correctly downstream. A refusal via !open surfaces as ClosedChannelException, which checkWALFiles()'s if (e instanceof ClosedChannelException && !file.isOpen()) continue; correctly treats as benign (a concurrent deliberate close). A refusal via a missing file surfaces as FileNotFoundException (not a ClosedChannelException), which correctly falls through to the fencing branch - the GraphImporter fails to load data properly when ArcadeDB server is alive #7479 contract this PR is careful not to regress.
  • checkWALFiles()'s catch reordering does what the description says: the old code caught ClosedChannelException ahead of the IOException/fencing branch with a bare close() and no fence; that catch is gone, and the only thing that can still short-circuit the fence is a reopen that was refused because the file is closed on purpose.
  • I did not find any channel.* call in WALFile.java left outside the reopen/retry funnel except the two the PR explicitly and correctly argues should stay outside it: tryLock() in the constructor and close() in close().
  • channel.write() inside appendAt()'s internal retry-loop (for [storage] Low-severity storage/WAL cleanups (short read/write loops, stats, staleness) #4958 partial writes) is not itself wrapped in a ClosedChannelException catch, but that's fine - it's always invoked through append(), whose outer try/catch covers the whole appendAt() call, so an interrupt on any loop iteration is still caught and retried at the top.

Design

  • The pool-fallback in writeTransactionToWAL doesn't weaken the single-writer-per-file assumption append() relies on: tryWriteTransactionToWALFile still goes through WALFile.acquire(), which is synchronized, so two threads falling back onto the same file still serialize correctly.
  • Recovery (checkIntegrity()) reads and merges every txlog_*.wal by txId, so writing a transaction to a WAL file other than the thread's hashed slot (the new fallback) doesn't break recovery - the hash is genuinely just a contention spreader, as the PR argues.
  • Not implementing "replace the dead slot" (the issue's suggestion Bump gremlin.version from 3.4.10 to 3.5.1 #2) is reasonable given the fencing-on-refusal design: once a slot can only go dead when reopenChannel() refuses, and every refusal either means "shutting down anyway" or "fence the whole database," there's no live pool left to rotate a new file into.

Test coverage

The new Issue7768InterruptedWalSlotTest covers every entry point named in the description's coverage table, including two negative guards (aChannelClosedOnPurposeIsNeverReopened, aWalFileGoneFromDiskIsNeverRecreatedByTheReopen) that verify the reopen doesn't overreach. Good use of StallAwareStopwatch.assertGaveUpWithin per this repo's convention instead of a raw wall-clock assertion. The one existing test that was edited (WALFileGetTransactionTest.ioErrorOnChannelThrowsWALException) is changed for a legitimate reason (a bare closed channel is now recoverable by design) and its original assertion/contract is preserved by also deleting the backing file so the condition stays genuinely unrecoverable.

Minor / non-blocking

  • The in-code comments in WALFile.java and TransactionManager.java are extremely dense (multi-paragraph prose per method, cross-referencing several issue numbers each). That's noticeably heavier than the surrounding codebase's comment style. It's all high-value "why," not "what," so it's consistent with CLAUDE.md's comment guidance in spirit, but a maintainer skimming these methods later may find the volume harder to navigate than a couple of tighter sentences plus the issue number for anyone who wants the full history.
  • reopenChannel() logs the "closed on %s (interrupted thread?)" line at SEVERE on every single recovered channel operation; the PR already flags this (filed as WALFile's interrupt reopen logs one SEVERE line per channel operation, so an interrupted recovery scan emits an unbounded flood #8139) as producing a flood on a multi-chunk recovery scan under one sustained interrupt. Agreed this is fine to leave out of scope, just confirming the flagged gap is real and not overstated.
  • describeWALFilePool and the other *ForTesting hooks are package-private, which is consistent with the existing test-support pattern in TransactionManager.

I was not able to run mvn in this environment to reproduce the test results independently (sandbox blocks build tool invocations), so I'm relying on static reading rather than re-executing the described 16125-test run - the logic traced out consistently with what the PR claims, for what that's worth.

Nothing here blocks merge from my read.

🤖 Generated with Claude Code

…stead of an instanceof on the caught exception

Codacy's remaining high-severity finding, now read from the check-run annotation rather than
guessed at: TransactionManager.java:1249, "An instanceof check is being performed on the caught
exception. Create a separate catch clause for this exception type."

The instanceof was there to avoid a second copy of the #7479 fence. Lifting that fence into
fenceForInaccessibleWALFile() removes the reason: ClosedChannelException gets its own clause again -
this time one that fences rather than swallowing, unless the file was closed on purpose while the
pass was running - and the IOException clause delegates to the same helper. One fence site, no
instanceof, and the two conditions now read as the two distinct cases they are.

Behaviour is unchanged; the 108 WAL, TransactionManager, interrupt and flush tests stay green.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@claude

claude Bot commented Sep 22, 2026

Copy link
Copy Markdown

Review of #8148

Solid, well-documented fix for a real bug: WALFile now recovers a FileChannel an interrupted thread closed, checkWALFiles() no longer lets ClosedChannelException (an IOException subtype) slip past the fencing branch, and writeTransactionToWAL no longer spins the full 30s on a single dead pool slot. The PR description's own coverage table and "argued" rows are accurate as far as I traced them - I verified independently rather than just trusting the writeup:

  • All three read call sites (getTransaction, findNextValidTransactionPosition, readFully/readInt) do funnel through the new readChunk, confirming the stated coverage.
  • acquire(), close(), and reopenChannel() are all synchronized on the same monitor, so a reopen genuinely can't interleave with a deliberate close - the double-checked channel.isOpen() inside reopenChannel() correctly collapses concurrent reopeners into one.
  • readChunk's buffer-position rewind on retry and append's offset-recorded-before-the-first-write are both correct: I checked the actual bytes-written accounting, not just the comments claiming it.
  • The checkWALFiles() split into ClosedChannelException (silently skip when !file.isOpen(), i.e. a concurrent deliberate close) vs. the general IOException fence path is right, and matches what the two negative-guard tests (aChannelClosedOnPurposeIsNeverReopened, aSlotClosedConcurrentlyWithTheHousekeepingPassDoesNotFence) exercise.

Two things worth a look before/after merge, neither blocking given the size and quality of the test suite already here:

1. The pool fallback in writeTransactionToWAL doesn't cover every way a slot can refuse.
tryWriteTransactionToWALFile only returns false (triggering the fallback loop to the other pool files) when WALFile.acquire() cleanly refuses, i.e. !active || !open. If a thread's own slot is still logically open but reopenChannel() throws a hard IOException (e.g. the FileNotFoundException guard when the backing file vanished from disk - the #7479 case, but scoped to just this one slot rather than the whole pool going bad), that exception is wrapped by acquire() into an unchecked WALException and propagates straight out of writeTransactionToWAL - the healthy pool files are never tried. That's arguably fine (failing loud on a very abnormal condition, and the housekeeping tick will fence the whole database within ~1s regardless), but it's a gap relative to the PR's stated goal ("offers the transaction to the other files in the pool ... instead of spinning on one slot"), and it isn't covered by aCommitFallsBackToAnotherWalFileWhenItsOwnSlotIsClosed (that test uses a plainly-close()d file, which hits the clean-refusal path, not the throwing one). Worth either a comment noting the scope boundary explicitly, or a follow-up test/tweak if the intent was for the fallback to be exception-safe too.

2. WALFile.isActive() is public but only used within com.arcadedb.engine.
TransactionManager.describeWALFilePool (same package) is the only caller. Its sibling accessor acquiredLock() in the same class is package-private for the same kind of intra-package-only use. Minor inconsistency - would be tidier as package-private to keep the public API surface minimal, per the project's general design principles.

Nothing else stood out: no new dependencies, the volatile widening on file/channel/lock is the minimum needed for cross-thread visibility of the reopened channel and doesn't introduce unnecessary synchronization on the hot path, and the deliberate behavior change to WALFileGetTransactionTest.ioErrorOnChannelThrowsWALException is well justified and clearly called out. Test coverage is thorough and the regression test class is exactly the kind of end-to-end + unit combination this kind of concurrency fix needs.

… pool fallback's scope boundary

Two non-blocking review notes, both taken.

isActive() was public for no reason: its only caller is describeWALFilePool in the same package, and
its sibling accessor acquiredLock() a few lines above is package-private for exactly that reason.
Narrowed to match.

The reviewer also observed, correctly, that the pool fallback only engages when acquire() cleanly
REFUSES a slot, not when the write throws - so a slot whose file has vanished from disk propagates a
WALException rather than routing the transaction to a healthy file. That is deliberate, and it is now
said so in tryWriteTransactionToWALFile's javadoc: a WAL file disappearing under a live instance is
the #7479 case, the next housekeeping tick fences the whole database over it, and writing more data
anywhere in the meantime is the opposite of what that fence exists for. Only a cleanly refused slot -
closed, absent or mid-rotation - is routed elsewhere.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@claude

claude Bot commented Sep 22, 2026

Copy link
Copy Markdown

Review

I read through WALFile.java, TransactionManager.java, and both test files (the PR description's own ledger/adversarial-pass is unusually thorough, so I focused on trying to find things it didn't already cover, plus general code-quality/style checks). Note: I could not execute mvn compile/tests in this sandboxed session (the tool run required interactive approval I don't have here), so this is a static review only — please rely on the CI/test results already reported in the PR description.

Correctness

Traced the concurrency story by hand:

  • reopenChannel() is synchronized on the same monitor as close()/acquire(), so a reopen can never interleave with a deliberate close, and the double-checked channel.isOpen() guard correctly collapses concurrent reopeners into one.
  • append()'s retry restarts from the pre-attempt offset (not the reopened channel's size()), so a torn partial write is overwritten rather than leaving a gap ahead of the record — verified this against appendReopensAChannelTheInterruptClosedAndWritesTheWholeRecord.
  • readChunk()'s new buffer-position rewind-on-retry is a real, independent bug fix beyond the append case (an interrupted read can transfer bytes before throwing, and without the rewind the retry would double-write into the buffer). Good catch during self-review.
  • The exception-type routing in checkWALFiles() checks out: a FileNotFoundException from a refused reopen (file gone from disk, GraphImporter fails to load data properly when ArcadeDB server is alive #7479) is a plain IOException, not a ClosedChannelException, so it always reaches the unconditional fence branch — the file.isOpen() guard on the ClosedChannelException branch can only ever swallow the "closed on purpose concurrently" case, not the disk-gone case. That's the crux of the fix and it's correctly wired.
  • writeTransactionToWAL's pool fallback can't double-write a transaction: the first successful tryWriteTransactionToWALFile breaks immediately, and the fallback loop only tries slots the first attempt didn't touch.

I didn't find a correctness bug beyond what's already called out in the PR body.

Minor observations (non-blocking)

  1. Issue7768InterruptedWalSlotTest.ClosingUnderneathWALFile simulates the "closed concurrently with housekeeping" race by having isOpen() return true then false on successive calls, relying on checkWALFiles() calling isOpen() twice (once in the if, once in the catch). That's a bit coupled to the current implementation shape — if checkWALFiles() is ever refactored to cache the isOpen() result in a local, this test would keep passing but silently stop exercising the intended race. Might be worth a one-line comment in the test noting that coupling, for future maintainers.
  2. The always-SEVERE log per reopened channel operation (flood risk on an interrupted recovery scan) is already tracked separately as WALFile's interrupt reopen logs one SEVERE line per channel operation, so an interrupted recovery scan emits an unbounded flood #8139 rather than solved here — agreed that's the right scope boundary, just flagging that I checked it wasn't accidentally left unaddressed.
  3. Style/CLAUDE.md compliance looks good: final used consistently, no fully-qualified names, single-statement ifs left brace-free, no stray System.out/debug prints, and the new tests use assertThat(...).isX() throughout.
  4. The one existing test that was intentionally changed (WALFileGetTransactionTest.ioErrorOnChannelThrowsWALException) still asserts the same contract (I/O error → WALException, never a swallowed null); the added tempFile.delete() is necessary and correctly documented since a closed-but-still-on-disk channel is now recoverable by design.

Test coverage

Coverage is unusually complete for the entry points described (append/force/getSize/recovery-reads, the end-to-end interrupted-commit scenario, the fence-vs-swallow distinction, and the pool fallback/timeout message). I traced a couple of the trickier ones (aClosedChannelNoReopenCanRepairFencesInsteadOfBeingSwallowed, aSlotClosedConcurrentlyWithTheHousekeepingPassDoesNotFence) against the actual checkWALFiles() control flow and they exercise exactly what they claim to.

Security / performance

No security concerns (purely internal I/O recovery on already-open local files, no new external input surface). Performance impact is negligible — the pool fallback and describeWALFilePool only run on the already-slow error path, and the hot commit path gets one extra (JIT-inlinable) volatile read.

Nice work — this is a well-scoped fix with a genuinely thorough test suite backing it.

… depends on

The reviewer noted that ClosingUnderneathWALFile stages its race by reporting "open" on the first
isOpen() call and "closed" afterwards, which couples the test to checkWALFiles() consulting isOpen()
twice - once in the rotation guard, once in the ClosedChannelException branch. Cache that read in a
local one day and the stub reports "open" throughout: the test keeps passing while exercising
nothing.

A comment was suggested; asserting it is better, because a comment cannot fail a build. The call
count is now captured after the housekeeping pass and asserted to be at least two, with a message
saying what stops being tested if it ever drops to one.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@claude

claude Bot commented Sep 22, 2026

Copy link
Copy Markdown

Review

This is an unusually well-documented fix, and the code matches what the PR description promises. I read through both WALFile.java and TransactionManager.java in full (all 5 commits) plus the new test class. Summary below.

Correctness

  • reopenChannel() correctly refuses in the two cases it must: !open (closed on purpose via close()/drop()) throws ClosedChannelException, and a path missing on disk throws FileNotFoundException rather than recreating the file - this preserves the GraphImporter fails to load data properly when ArcadeDB server is alive #7479 guarantee that a WAL file another process deleted is never resurrected.
  • The double-checked channel != null && channel.isOpen() inside the synchronized reopenChannel() correctly avoids two threads racing to reopen the same dead channel and leaking a descriptor.
  • append()'s retry correctly restarts from the offset recorded before the first attempt (not the reopened channel's size()), so a partial/interrupted write is overwritten rather than leaving a torn prefix ahead of the record - this is the right defense against the WALFile.getTransaction returns null on partial record, recovery abandons rest of WAL #4508 gap-detector corruption.
  • readChunk()'s buffer-position rewind on retry is a good catch (added in the second commit) - an interrupted read can transfer bytes into the buffer before throwing, and without the rewind the retry would double-write into the buffer and desync the caller's readPos bookkeeping.
  • The split of checkWALFiles()'s ClosedChannelException catch from the generic IOException catch, both funneled through fenceForInaccessibleWALFile(), correctly distinguishes "reopen refused because closed-on-purpose" (benign, filtered by the file.isOpen() check) from "reopen refused because gone from disk" (fences, since that exception surfaces as FileNotFoundException, not ClosedChannelException, and falls into the generic branch). Traced this through by hand and it holds.
  • The pool fallback in writeTransactionToWAL deliberately only engages on a clean refusal (acquire() returning false), not on a thrown WALException - documented in the javadoc. Worth noting this isn't a new gap: the pre-existing code also propagated a throw immediately without ever reaching a fallback, so this is not a regression, just a preserved boundary.

Potential edge case (non-blocking)

retryAfterReopen() calls reopenChannel() and io.run() as two separate calls, so the two don't share one critical section - a close() from another thread (e.g., shutdown) can land in the gap between them, and the retried I/O then throws ClosedChannelException again with no second retry. This looks intentional and consistent with how the rest of the PR treats "closed concurrently with the pass" as benign (there's even a dedicated test for the analogous race in checkWALFiles), but it might be worth one line in the retryAfterReopen javadoc calling this out explicitly the way reopenChannel's javadoc does, since it's not otherwise obvious that the retry itself is unprotected.

Performance

file, channel, lock moving from final to volatile is the necessary and correct trade-off (same pattern as PaginatedComponentFile from #4930) - a plain field wouldn't be safely visible across the thread that reopens it and the thread(s) reading it afterward. The cost is a volatile read on every channel operation instead of a plain one; on the WAL commit path that's negligible next to the actual I/O.

Known accepted gap

The SEVERE log line fires once per recovered channel operation, so an interrupted multi-chunk recovery scan could emit a flood of identical lines. Called out explicitly in the PR and filed as #8139 rather than solved here - reasonable to defer since #7768 was partly about this failure being invisible below FINE, and fixing the flood is a separate design decision (dedupe? rate-limit? single summary line?).

Test coverage

Thorough - one test per entry point in the coverage table (append, force, getSize, all three recovery read paths), the two negative guards (closed-on-purpose is never reopened, a deleted file is never recreated), the shutdown-race benign case, the pool-fallback case, and an end-to-end reproduction with arcadedb.txWalFiles=1 matching the exact configuration called out in the issue. Good adherence to this repo's conventions: StallAwareStopwatch.assertGaveUpWithin instead of raw wall-clock assertions, and the ClosingUnderneathWALFile stub asserting its own isOpen() call count (commit 5) rather than leaving that coupling as a comment that could silently stop testing anything.

The one existing test that was modified (WALFileGetTransactionTest.ioErrorOnChannelThrowsWALException) has a clear, honest explanation for why its inducement had to change (closing a channel is now recoverable by design) - the assertion itself is untouched, which is the right way to handle a fix that changes what used to be an error into a recovered condition.

Nit

describeWALFilePool/isActive() are reasonable, narrowly-scoped (package-private) test-support additions, consistent with the existing checkWALFilesForTesting/replaceActiveWALFileForTesting/acquiredLock() pattern already in the class.

I wasn't able to run mvn -o -pl engine test myself in this review environment (the sandbox declined the build invocation), so I'm relying on manual trace-through plus the test plan already reported in the PR description (16125/16125 green on the full engine module). Given the thoroughness of the diff and the adversarial self-review already documented, I don't see anything blocking here.

@codecov

codecov Bot commented Sep 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.39326% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.90%. Comparing base (642f431) to head (1bba4d4).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...n/java/com/arcadedb/engine/TransactionManager.java 78.12% 4 Missing and 3 partials ⚠️
...ine/src/main/java/com/arcadedb/engine/WALFile.java 89.47% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8148      +/-   ##
============================================
+ Coverage     74.88%   74.90%   +0.02%     
  Complexity     2579     2579              
============================================
  Files          2004     2004              
  Lines        187386   187457      +71     
  Branches      39184    39196      +12     
============================================
+ Hits         140320   140413      +93     
+ Misses        31504    31482      -22     
  Partials      15562    15562              

☔ 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.

@robfrank
robfrank merged commit 7fc5251 into main Sep 22, 2026
34 of 37 checks passed
@robfrank
robfrank deleted the fix/7768-wal-slot-dies-on-interrupted-commit branch September 22, 2026 13:20
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