Skip to content

One interrupt on any thread reading a TimeSeries sealed store closes its shared FileChannel for every thread and nothing ever reopens it, so the shard stays unreadable for the life of the process #9621

Closed

Description

@ruispereira

Summary

TimeSeriesSealedStore opens <base>.ts.sealed with its own RandomAccessFile and keeps the
FileChannel in a field for the life of the store, deliberately outside ArcadeDB's page manager
(its own class comment says so, and SnapshotHttpHandler and PostVerifyDatabaseHandler both
repeat it). Every read of every block goes through that one channel.

A thread interrupted while blocked in channel.read raises ClosedByInterruptException, and NIO
closes the channel for every other thread using it. That is the whole premise of #7768, #8944,
#9306 and #9444. Here nothing catches it and nothing reopens: indexFile/indexChannel are
reassigned only by the file-swap paths (truncateBefore, downsampleBlocks, commitTempFile,
truncateToBlockCount, installSealedFile), so the store is dead until a compaction, a retention
pass or a snapshot install happens to replace the file, or until the process restarts. Every read,
getFileSizeBytes and checkIntegrity fail with ClosedChannelException in the meantime. The
bytes on disk are untouched: reopening the store returns every row.

The reads are the ones most likely to be interrupted. TimeSeriesEngine fans sealed-store reads out
over a dedicated shardExecutor pool ("Sealed stores are read in parallel, one partial answer per
shard"), and that pool is drained with shutdownNow() on both close() and drop(), which
interrupts whatever worker has not finished; with one shard, or on the mutable-bucket half, the read
runs on the CALLING thread, which on a server is an HTTP worker or a DatabaseAsyncExecutorImpl
worker, and that executor interrupts its workers at three call sites. The difference from the page
file is not the likelihood, it is the blast radius: a page file recovers on the next operation,
while a sealed store that loses its channel does not recover at all.

Where (HEAD 2b0a7a6)

engine/src/main/java/com/arcadedb/engine/timeseries/TimeSeriesSealedStore.java:165 - the two
fields, held for the life of the store:

  private       RandomAccessFile     indexFile;
  private       FileChannel          indexChannel;

engine/src/main/java/com/arcadedb/engine/timeseries/TimeSeriesSealedStore.java:5116 - the one
read every block goes through, with no catch:

  private byte[] readBytes(final long offset, final int size) throws IOException {
    ...
      final int read = indexChannel.read(buf, offset + totalRead);

and the same bare indexChannel.read(...) at :4591, :4632, :4670, :4687, :4718, :4732,
:4741, :4749, :4772 in the directory loader, plus the bare indexChannel.write(...) at
:4565 and :4578 in writeEmptyHeader/rewriteHeader.
Against the sibling that was given the treatment one round ago,
engine/src/main/java/com/arcadedb/engine/PageShadow.java:62:

 * <b>Interrupts</b> (issue #9444). An interrupt landing on any thread doing I/O on a {@link FileChannel} closes it for

and engine/src/main/java/com/arcadedb/engine/PaginatedComponentFile.java:214:

  private void reopenAndRetry(final String operation, final ChannelOperation channelOperation) throws IOException {

Repro

Driven against a build of this HEAD, directly on the store (the same way
Issue6360SealedStoreIntegrityTest drives it). Four healthy blocks, 256 rows; one reader thread
whose interrupt flag is already set, so the very next positioned read raises
ClosedByInterruptException; then three reads from the main thread, whose interrupt flag is clear:

### blocks = 4  rows = 256
### interrupted reader got: java.nio.channels.ClosedByInterruptException: null
### main thread interrupt flag = false
### attempt 1 on an UNINTERRUPTED thread FAILED: java.nio.channels.ClosedChannelException: null
### attempt 2 on an UNINTERRUPTED thread FAILED: java.nio.channels.ClosedChannelException: null
### attempt 3 on an UNINTERRUPTED thread FAILED: java.nio.channels.ClosedChannelException: null
### getFileSizeBytes FAILED: java.io.IOException
### checkIntegrity FAILED: java.io.IOException: Stream Closed
### after reopening the store: rows = 256

The last line is the point: the data is intact and a reopen is all that was ever needed, which is
what the other three channels do for themselves.

Suggested fix

Give indexChannel the recovery PaginatedComponentFile already has, in the one place every read
goes through: a catch (ClosedChannelException) that reopens
new RandomAccessFile(basePath + ".ts.sealed", "rw"), clears and restores the interrupted flag the
way reopenAndRetry does, and repeats the operation a bounded number of times, with the reopen
under the store's directoryLock write lock so a concurrent file swap cannot be reopening the same
field at the same time. readBytes plus the header/metadata reads of loadDirectory cover every
read; writeEmptyHeader and rewriteHeader cover the writes. Only a reopen that is REFUSED (the
file is gone, the store was closed on purpose) is a real failure, which is the rule #9306 settled
for the page file.

Scope / confidence

Reproduced. What I tried to refute it with: (a) "the store is closed anyway when a pool is drained
with shutdownNow, so nothing survives to be broken" - shardExecutor.shutdownNow() is indeed on the
close path, but it is not the only interrupter: the sealed read also runs on the CALLING thread
(single-shard types, and the mutable-bucket half of every query), and a caller thread interrupted
for any reason poisons the store for every other thread while the database stays open, which is what
the repro drives; (b) "a compaction will reopen it" - it will, because the swap paths assign
indexFile/indexChannel fresh, but a compaction only runs when there is new data to compact, and
until then every query on that shard fails; a read-only or retired shard never recovers;
(c) "checkIntegrity or CHECK DATABASE would detect and repair it" - checkIntegrity fails with
IOException: Stream Closed on the same channel, printed above; (d) "this is the same severity as
the page file, which was fixed" - it is worse, because PaginatedComponentFile recovers on its next
operation and this does not recover at all; (e) "no other long-lived channel is in this state" -
SimpleFileIndexWriter is, and it is in the table; everything else in the tree with a FileChannel
either has the recovery or opens one per operation.

Activity

  1. added
    concurrency
    severity:major
    storage
    timeseries
    on Oct 10, 2026
  2. added this to the 26.11.1 milestone on Oct 10, 2026
  3. self-assigned this
    on Oct 10, 2026
  4. added
    in progress
    on Oct 11, 2026
  5. added a commit that references this issue on Oct 11, 2026
  6. robfrank commented on Oct 11, 2026

    @robfrank
    Collaborator

    Fixed in #9729. The sealed TimeSeries store kept one shared file channel, and an interrupt on any thread reading it closed the channel for every thread until the next file swap. Every operation on that channel now reopens it and retries, up to 5 times, the same way paginated database files already recover. The interrupted thread still sees its interrupt afterwards. A store that was closed on purpose, or whose file was deleted, is never reopened, so a dropped store cannot be re-created as an empty file.

    Still open: the retry budget is per read. With several threads being interrupted constantly on a heavily loaded machine, one read can still see the channel closed more than 5 times in a row and fail with ClosedChannelException. This was seen once in a stress test under load. Normal interrupts recover.


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  7. removed
    in progress
    on Oct 11, 2026
  8. added 2 commits that reference this issue on Oct 12, 2026
  9. added 3 commits that reference this issue on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugconcurrencyseverity:majorstoragetimeseries

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions