invoices: bound rapid migration test workload - #11206
Conversation
Run the SQLite and Postgres property checks as isolated subtests, close each database after its check, and migrate a bounded batch of randomized invoices per Rapid iteration. This preserves multi-invoice transaction coverage while preventing the accidental 100-by-100 workload from exhausting the Postgres fixture under the race detector.
9e98006 to
381faa6
Compare
🟢 PR Severity: LOW
🟢 Low (1 files)
AnalysisA To override, add a |
Lrifton92
left a comment
There was a problem hiding this comment.
Reviewed at 381faa6.
The restructuring matches the description. Each backend runs as its own subtest, so the Postgres fixture only lives through the Postgres checks. Every Rapid check gets a fresh store, whose handle is closed in rt.Cleanup rather than kept until the outer test exits. The per-check batch goes from 100 invoices to 10, which removes the accidental 100×100 multiplier while still putting several migrations in one transaction.
Two changes are improvements beyond the timeout fix:
- The
ExecTxclosure now returns theMigrateSingleInvoiceerror instead of callingrequire.NoErrorinside it.FailNowfrom inside the transaction callback would bypass the executor's rollback and retry handling. - The map becomes a slice, so the migration order within a check is deterministic, which helps when Rapid replays a failure.
What I ran on this head:
TestMigrateSingleInvoiceRapid/SQLitepasses: "[rapid] OK, passed 100 tests". The earlydb.Close()plus the helper's own cleanup close is exercised on this path without error, sincesql.DB.Closeis idempotent.- The Postgres subtest needs Docker, which I don't have here, so that half is unverified locally.
- To check that 10 invoices per check still gives useful coverage, I added a
breakafter the firstInsertInvoiceHTLCCustomRecordinsql_migration.go, so only one custom record per HTLC is migrated. Rapid fails immediately ("failed after 0 tests") and shrinks to a minimal invoice. So a data-loss bug on a common shape is still caught at the new batch size. Rarer combinations get fewer draws than before (1,000 generated invoices per backend instead of 10,000), which is the stated trade-off. go vet ./invoices/is clean and no added line exceeds 80 columns.
Minor, non-blocking: each check's Postgres CREATE DATABASE and each SQLite temp dir are still registered on the subtest's t (sqldb/postgres_fixture.go:158, sqldb/sqlite.go:236), so 100 of them accumulate until the subtest ends. The handles are closed early, which is what matters for the fixture, but the comment at lines 583-585 could say the databases themselves stay until the subtest ends.
LGTM.
|
Successfully created backport PR for |
|
Successfully created backport PR for |
…21.x-branch [v0.21.x-branch] Backport #11206: invoices: bound rapid migration test workload
…20.x-branch [v0.20.x-branch] Backport #11206: invoices: bound rapid migration test workload
Change
TestMigrateSingleInvoiceRapidperformed Rapid's default 100 property checks,but generated and migrated another 100 invoices inside every check for both
SQLite and Postgres. The resulting 20,000 migrations and delayed database
cleanup made the race build exceed the Postgres fixture's fixed ten-minute
lifetime.
covers only Postgres checks.
retaining every handle until the outer test exits.
retains multiple migrations in one transaction and post-commit lookup
coverage while replacing the accidental 100-by-100 multiplier with 1,000
generated invoices per backend.
This addresses the repeated race-job timeout observed after the Go 1.27.1
toolchain update in #11200 without increasing the fixture timeout.
Verification
TestMigrateSingleInvoiceRapid: pass in 142.330s.make lint-native: 0 issues.