Repository navigation
Description
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 forand 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
fix(#9621): reopen a TimeSeries sealed store channel a thread interru…
robfrank commentedon Oct 11, 2026
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.
test(#9621): wait for an interrupt to land mid-read instead of hoping…
test(#9621): stop and join the readers on every path, a timed-out wai…
fix(#9621): reopen a TimeSeries sealed store channel a thread interru…
test(#9621): wait for an interrupt to land mid-read instead of hoping…
test(#9621): stop and join the readers on every path, a timed-out wai…