fix(#17): log count failures instead of swallowing them #21

Merged
KofTwentyTwo merged 2 commits from feature/GH-17-log-safecount into develop 2026-10-07 00:03:17 +00:00
KofTwentyTwo commented 2026-10-06 23:04:54 +00:00 (Migrated from github.com)

Summary

safeCount swallowed every exception from countDocumentsForTable without logging, and its null fallback was then written to documentCount, erasing the last good count.

  • ReconcileIndexStep.safeCount now logs a WARN with the exception and logPair("tableName", ...) before returning null.
  • BasepullIndexStep had an exact copy of it; that copy is removed and the step calls ReconcileIndexStep.safeCount, as FullReindexStep already did.
  • All three callers (basepull, reconcile, full reindex) skip documentCount when the count is null, so the row keeps its previous value. The rest of the run is unchanged.

Testing

  • New unit tests in BasepullIndexStepTest, ReconcileIndexStepTest and FullReindexStepTest seed a stale documentCount of 99, make the count throw, capture ReconcileIndexStep's logger with QLogger.activateCollectingLoggerForClass, and assert exactly one WARN line carrying the table name and the stack trace, a completed run, and documentCount still 99. They fail against the previous code.
  • CI=true ./mvnw verify: 310 unit tests and 18 integration tests pass, JaCoCo coverage checks met.

Closes #17

## Summary `safeCount` swallowed every exception from `countDocumentsForTable` without logging, and its `null` fallback was then written to `documentCount`, erasing the last good count. - `ReconcileIndexStep.safeCount` now logs a WARN with the exception and `logPair("tableName", ...)` before returning `null`. - `BasepullIndexStep` had an exact copy of it; that copy is removed and the step calls `ReconcileIndexStep.safeCount`, as `FullReindexStep` already did. - All three callers (basepull, reconcile, full reindex) skip `documentCount` when the count is `null`, so the row keeps its previous value. The rest of the run is unchanged. ## Testing - New unit tests in `BasepullIndexStepTest`, `ReconcileIndexStepTest` and `FullReindexStepTest` seed a stale `documentCount` of 99, make the count throw, capture `ReconcileIndexStep`'s logger with `QLogger.activateCollectingLoggerForClass`, and assert exactly one WARN line carrying the table name and the stack trace, a completed run, and `documentCount` still 99. They fail against the previous code. - `CI=true ./mvnw verify`: 310 unit tests and 18 integration tests pass, JaCoCo coverage checks met. Closes #17
Sign in to join this conversation.