3 suggestions
Optional improvements
[suggestion] · Buffered block and undo write errors bypass fatal-error handling
A short fwrite aborts the node or kernel host without sending fatalError, while related close failures use the application's existing fatal-error handling.
Location: src/streams.h:716 (head).
Details and suggested fix
If a local storage error makes fwrite return short during either an automatic full-buffer flush or the explicit final flush, this Assert calls std::abort(). Use the existing fatal-error path rather than enforcing process termination in the stream wrapper. An fclose failure can also leave corrupt output, yet these same callers notify the application and return failure, allowing orderly shutdown. std::exchange already prevents the destructor from retrying failed buffered data. Let flush() throw std::ios_base::failure after that reset, including when called by write(). Catch it in both blockstorage writers, explicitly close the AutoFile to satisfy its destructor contract, invoke fatalError/FatalError, and return failure. Keep the aborting check for the destructor fallback, where no caller remains to handle the failure. Base also terminated on these write failures, so this is a recommendation against codifying that policy, not a new crash regression.
[suggestion] · Short-write diagnostics omit the operating-system error
The fixed short-write log cannot distinguish a full filesystem from an I/O error before the process aborts on a buffered-write failure.
Location: src/streams.cpp:130 (head).
Details and suggested fix
When fwrite returns fewer bytes than requested, write_buffer() logs only AutoFile::write_buffer: write failed and returns false. For block and undo writes, Assert aborts before the callers reach their fclose handlers, which log SysErrorString(errno). The assertion reports the failed expression, not the storage error. Capture errno immediately after the failed fwrite, before logging, and include SysErrorString(saved_errno) in LogError. This distinguishes failures such as ENOSPC and EIO without changing the bool/noexcept contract or abort policy. Base also used fixed text, so this is diagnostic enrichment rather than a regression. ISO C does not guarantee meaningful errno for every short write, and some libc stream-state failures leave it unset; the added detail remains useful for kernel write failures that set it.
[suggestion] · AutoFile short-write logging depends on obfuscation
Caught short writes through AutoFile::write now add an error-level log only with obfuscation enabled, changing diagnostics for callers such as DumpMempool.
Location: src/streams.cpp:110 (head).
Details and suggested fix
For a nonempty write with obfuscation enabled, AutoFile::write() now calls the logging write_buffer() and throws AutoFile::write: write failed when it returns false. The plain branch throws for a short write without logging. DumpMempool enables obfuscation after its header, catches these exceptions, closes the file, and reports at info level that it is continuing anyway. Its obfuscated payload short writes therefore gain an extra error-level stream log. Use a private non-logging helper that reports the failure reason, let AutoFile::write() throw that reason, and retain logging in write_buffer() before buffered failures abort. This also preserves the specific obfuscation position unknown exception reason lost by the bool conversion; no current production caller producing that state was found. Ordinary short-write exception text was already generic at base, and null-handle failures still retain the outer guard's specific exception. The impact is limited to diagnostics.