2.2 KiB
Phase 11 deferred items
Out-of-scope findings logged by plan executors. Not fixed; each names the plan that owns the code.
From plan 11-05 (found while debugging beachcomber)
-
lighthouse broadcast callbacks run after GORM's own commit on single-statement writes (plan 11-03 code).
modules/lighthouse/broadcast.goinstallCallbacksregisterslighthouse:after_create,lighthouse:after_updateandlighthouse:after_deletewith only anAfter("gorm:after_*")anchor. GORM's callback sorter appends such a callback to the end of the already sorted chain, which is pastgorm:commit_or_rollback_transaction. 11-05 observed this directly for the identical beachcomber registration:InstanceGet("gorm:started_transaction")was set, butConnPoolwas already the*sql.DB. For a plaingdb.Createoutside any explicit transaction, the broadcast job is therefore enqueued after the commit and outside the write's transaction, not "on the write's*sql.Tx" as the lighthouse README states. A failed write still broadcasts nothing, becausedb.Erroris set. Writes insidelagoon.Transactionor a plaingormtransaction are unaffected. Fix: add.Before("gorm:commit_or_rollback_transaction")to the three registrations (beachcomber does this since9543e65), and add a test for a single-statement write. Candidate owner: plan 11-07 (unit tests). -
lagoon hands AfterCommit callbacks a handle that carries the write's statement (plan 11-01 code).
modules/lagoon/transaction.goflushStatementAfterCommitbuilds its handle withdb.Session(&gorm.Session{NewDB: true, Context: ctx}), andAfterCommit's immediate path passes the callback's owndb. Because a Context is set,Sessionclones the write's statement (model, table, clauses). A laterWithContexton that handle continues from the clone, so a query then runs through the written model's statement. beachcomber defends itself withcleanSession(9543e65). Any otherAfterCommituser that callsWithContextorSessionwithoutNewDBon the handle it receives would hit the same bug. Fix: passdb.Session(&gorm.Session{NewDB: true, Context: ctx}).Clauses().Session(&gorm.Session{NewDB: true}), or document the requirement. Candidate owner: plan 11-07.