Skip to content

TransactionManager.close(false) deletes WAL files without fsyncing data pages #4332

@ruispereira

Description

@ruispereira

Affected version: 26.4.2 (confirmed still present in 26.5.1)
Component: com.arcadedb.engine.TransactionManager

Summary

cleanWALFiles(dropFiles=false, force=false) ignores pendingPagesToFlush,
and the close path then unconditionally rm-s every .wal file. Data pages
are never fsynced on the shutdown path.

Code

engine/com/arcadedb/engine/TransactionManager.java:126–150, 614–638

if (force || !dropFiles || file.getPendingPagesToFlush() == 0) {        // !dropFiles always wins
  if (dropFiles) file.drop(); else file.close();
  it.remove();
}
…
File[] walFiles = dir.listFiles((d, n) -> n.endsWith(".wal"));
Stream.of(walFiles).forEach(File::delete);                              // always

Impact

A clean JVM exit followed by an OS crash / power loss can permanently lose
committed transactions: data pages were write()-ed but not force()-ed,
and the WAL has been deleted.

Suggested fix

Before deleting WAL files in close(false), fsync every
PaginatedComponentFile (channel.force(true)). Alternatively, do not delete
WAL on close(false) — leave them and let the next open replay them (replay
is idempotent).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions