Summary
ledger/snapshot.Calculator discards read-only transaction cleanup errors.
Audit Details
Finding ID: M18, MEDIUM error handling finding.
Affected file: ledger/snapshot/calculator.go.
The audit found:
defer func() { _ = txn.Commit() }()
In this path the transaction is read-only, so commit effectively performs cleanup/rollback. A cleanup error is unlikely, but it is currently invisible.
Impact: database/resource cleanup failures during snapshot calculation are silently lost, making operational issues harder to diagnose.
What Needs to Happen
- Replace the discarded cleanup error with an observable path.
- If calculation already returned an error, join or log the cleanup error.
- If calculation succeeded but cleanup failed, return that error or log at WARN based on transaction semantics.
- Add a focused test with a fake transaction if practical.
Acceptance Criteria
- Cleanup errors are not silently discarded.
- Successful calculation behavior remains unchanged when cleanup succeeds.
Summary
ledger/snapshot.Calculatordiscards read-only transaction cleanup errors.Audit Details
Finding ID: M18, MEDIUM error handling finding.
Affected file:
ledger/snapshot/calculator.go.The audit found:
In this path the transaction is read-only, so commit effectively performs cleanup/rollback. A cleanup error is unlikely, but it is currently invisible.
Impact: database/resource cleanup failures during snapshot calculation are silently lost, making operational issues harder to diagnose.
What Needs to Happen
Acceptance Criteria