feat(agentcompat): add SQLite hold scoped attribution

Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
This commit is contained in:
naibaandnaiba/CloudCode committed 2026-07-20 04:29:21 +00:00
1 parent 26e92da33b
commit 0c6eb416a5
39 files changed
+5527 -6

No files matched your search

@@ -0,0 +1,26 @@
//go:build agentcompat && linux
package singleton
import (
"errors"
)
func (connection *sqliteAttributionConnection) Close() error {
connection.lifecycleMu.Lock()
state := connection.transaction
connection.lifecycleMu.Unlock()
if state == nil {
return connection.closeRaw()
}
// database/sql may close Conn before Tx reaches Rollback; converge the attribution state here.
rollbackErr := state.rollback(connection)
return errors.Join(rollbackErr, connection.closeRaw())
}
func (connection *sqliteAttributionConnection) closeRaw() error {
if connection.closeRawConnection != nil {
return connection.closeRawConnection()
}
return connection.connection.Close()
}