aeron-io/aeron · critical · ArchiveException
GENERIC
GENERIC
Error message
file closed by interrupt, recording aborted
What it means
RecordingWriter.onBlock writes received blocks of recorded data to the segment file. If the write is interrupted via ClosedByInterruptException (the thread's interrupt flag was set during file I/O, typically because the task/future was cancelled), the writer closes itself and rethrows an ArchiveException with GENERIC error code, aborting the recording.
Solutions
- This indicates the recording was deliberately aborted: stop the recording cleanly with stopRecording rather than interrupting the recorder thread.
- Check who interrupts the thread (Future.cancel(true), shutdownNow) and use non-interrupting cancellation for the recording lifecycle.
- Treat the writer as closed after this exception — create a new recording if data capture must continue.
- During shutdown, let in-flight recordings finish or explicitly close them before shutting down the executor.
Example fix
// before executor.shutdownNow(); // interrupts recorder mid-write // after recordingSubscription.cancel(); // stop recording cleanly executor.shutdown();
Defensive patterns
Strategy: try-catch
Validate before calling
// avoid interrupting the recorder thread: check before cancelling
if (!Thread.currentThread().isInterrupted()) { recordingSubscription.cancel(); } Try / catch
try {
writer.onBlock(buffer, offset, length, sessionId, termId);
} catch (ArchiveException e) {
if (e.errorCode() == ArchiveException.GENERIC
&& e.getMessage().contains("file closed by interrupt")) {
log.warn("recording aborted by interrupt; recorder is closed");
// do not reuse the writer; start a new recording if needed
}
} Prevention
- Stop recordings with stopRecording/cancel rather than thread interrupts.
- Avoid Future.cancel(true) and shutdownNow() on threads performing archive writes.
- Complete or explicitly close active recordings before executor shutdown.
- Keep interrupt-flag hygiene: clear/inspect interrupt status in code owning recorder threads.
When it happens
Trigger: The thread executing onBlock (recorder agent) is interrupted while writing to the recording segment file — e.g. the recording was cancelled, the archive agent's executor shut down with interrupt, or application code interrupts the owning thread during FileChannel write/force operations.
Common situations: Calling RecordingSubscriptionDescriptor.stopRecording / cancelling the archive client session, which interrupts the recorder; ExecutorService.shutdownNow() during application shutdown while a recording is active; timeout-based cancellation of the recording task.
Related errors
- Aeron client instance must set…
- Aeron client must use a RethrowingErrorHandler
- segment file length not a power of 2
- segment file length not in valid range
- Unable to derive…
AI-assisted analysis of aeron-io/aeron@6d60124e15 (2026-09-12).
Data as JSON: /api/errors/6627731c86a9d0cf.
Report an issue: GitHub.
Appendix: source
Thrown at aeron-archive/src/main/java/io/aeron/archive/RecordingWriter.java:156
if (forceWrites)
{
recordingFileChannel.force(forceMetadata);
}
final long writeTimeNs = nanoClock.nanoTime() - startNs;
recorder.bytesWritten(dataLength);
recorder.writeTimeNs(writeTimeNs);
segmentOffset += length;
if (segmentOffset >= segmentLength)
{
onFileRollOver();
}
}
catch (final ClosedByInterruptException ex)
{
close();
throw new ArchiveException("file closed by interrupt, recording aborted", ex, ArchiveException.GENERIC);
}
catch (final IOException ex)
{
close();
checkErrorType(ex, length);
}
catch (final Exception ex)
{
close();
LangUtil.rethrowUnchecked(ex);
}
}
/**
* {@inheritDoc}
*/
@Override
public void close()View on GitHub (pinned to 6d60124e15)