fix(11-07): roll back the savepoint when a swallowed read failed
- beachcomber and lighthouse released their savepoint whenever the inner function reported no error; a Gate that counts a failed read as off, or a channel function or delete snapshot that swallows one, left the caller's Postgres transaction aborted (25P02) and failed the write - a failed RELEASE now rolls back to the savepoint, as the READMEs promise - beachcomber gets its testcontainers harness and sync tests (TestSyncGates, TestSyncAfterCommit, TestSyncDeleteAndSoftDelete, TestSyncFailuresNonFatal, TestServiceSetup); lighthouse gets TestBroadcastSwallowedReadFailure
This commit is contained in:
@@ -282,7 +282,13 @@ func inSavepoint(db *gorm.DB, fn func(tx *gorm.DB) error) error {
|
||||
db.RollbackTo(syncSavepoint)
|
||||
return err
|
||||
}
|
||||
db.Exec("RELEASE SAVEPOINT " + syncSavepoint)
|
||||
if db.Exec("RELEASE SAVEPOINT "+syncSavepoint).Error != nil {
|
||||
// A statement inside fn failed although fn did not report it (a
|
||||
// Gate counts a failed read as off): the transaction is aborted
|
||||
// and only a rollback to the savepoint makes it usable again.
|
||||
db.RollbackTo(syncSavepoint)
|
||||
db.Exec("RELEASE SAVEPOINT " + syncSavepoint)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user