Skip to content

fix: preserve scan data across failed loads and rebuilds - #449

Merged
TheWitness merged 2 commits into
developfrom
fix/preserve-incomplete-scan-data
Nov 17, 2026
Merged

TheWitness merged 2 commits into
developfrom
fix/preserve-incomplete-scan-data

Conversation

@somethingwithproof

Copy link
Copy Markdown
Member

Fixes #448. Follow-up to #427/#437 and #447.

A failed scan copy could reach temp-table cleanup, a failed date read could delete valid metadata, and an interrupted aggregate rebuild could count its source twice. This change:

  • Returns failure from direct, staging and older-date loads; the poller retains temporary rows and stops before aggregation/cleanup. An incomplete stage is never exchanged or marked pending.
  • Requires all scan-date reads to succeed before reconciliation, checks writes, and reports failure separately from a valid empty history.
  • Marks an intact aggregate source before copying and clears only the derived destination on retry. Failed copies and final drops can be retried without adding the same counts again. No transactions or source-row deletes are introduced.

Validation: the full suite passed on PHP 8.2.35 and 8.3.36 with MariaDB 11.8.9 (1,013 passed, one root-only permission-test skip on each). Seven real-database recovery cases cover copy/drop failures, direct/exchange read/write failures, and scan-date retry. The aggregate fixture ends at 30 rather than 40 after retry; all 1,001 staged scan rows survive. The 91 focused tests also execute the poller cleanup decision and utility failure/success messages. Eighteen tests fail against the original production code.

Xdebug on PHP 8.4.25 exercised all 47 changed executable lines in the three library files. The existing test helper extracts poller/web functions into temporary files, so those entry-point lines are behavior-tested but are not attributed to their original files in Clover. This is not a claim of 100% whole-plugin coverage. PHP syntax, manifest and translation-template checks are included; the formatter still reports unrelated pre-existing differences in the MacTrack files.

Recovery/rollback: an unmarked nonempty migration source beside a populated destination is ambiguous because older workers deleted copied source rows. The fix preserves both and logs that manual recovery is needed. Keep backups of both tables and establish which contains the complete history before restarting such a migration. Do not force the copying marker merely because a source table exists. Complete or recover an interrupted migration before reverting to the previous additive retry behavior. Already-lost rows or already-inflated counts are not reconstructed automatically.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@sonarqubecloud

Copy link
Copy Markdown

@TheWitness
TheWitness merged commit e5ae411 into develop Nov 17, 2026
9 checks passed
@TheWitness
TheWitness deleted the fix/preserve-incomplete-scan-data branch November 17, 2026 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve scan data and aggregate counts after database failures

3 participants