{"record":{"id":"32d63d8f38cb0809","repo":"t8y2/dbx","slug":"begin-manual-transaction-w","errorCode":null,"errorMessage":"begin manual transaction: %w","messagePattern":"begin manual transaction: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/oracle-go/main.go","lineNumber":1204,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\t// Hold one exclusive physical connection so DML/SELECT/schema stay on the\n\t// same Oracle session for the life of the interactive transaction.\n\tconn, err := db.Conn(context.Background())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reserve connection for manual transaction: %w\", err)\n\t}\n\tif strings.TrimSpace(schema) != \"\" {\n\t\tif _, err := conn.ExecContext(context.Background(), \"ALTER SESSION SET CURRENT_SCHEMA = \"+quoteIdentifier(schema)); err != nil {\n\t\t\t_ = conn.Close()\n\t\t\treturn err\n\t\t}\n\t}\n\ttx, err := conn.BeginTx(context.Background(), nil)\n\tif err != nil {\n\t\t_ = conn.Close()\n\t\treturn fmt.Errorf(\"begin manual transaction: %w\", err)\n\t}\n\ts.manualConn = conn\n\ts.manualTx = tx\n\treturn nil\n}\n\nfunc (s *server) commitManualTransaction() error {\n\tif s.manualTx == nil {\n\t\treturn errors.New(\"no manual transaction open\")\n\t}\n\terr := s.manualTx.Commit()\n\ts.clearManualTransaction()\n\treturn err\n}\n\nfunc (s *server) rollbackManualTransaction() error {\n\tif s.manualTx == nil {\n\t\treturn errors.New(\"no manual transaction open\")","sourceCodeStart":1186,"sourceCodeEnd":1222,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/oracle-go/main.go#L1186-L1222","documentation":"After successfully reserving an exclusive connection, the driver starts the actual database transaction with conn.BeginTx. If Oracle rejects the begin (connection already broken, session terminated, driver error), the reserved connection is closed and this wrapped error is returned. The manual transaction is therefore not started.","triggerScenarios":"Calling beginManualTransaction when the reserved connection was invalidated between db.Conn and BeginTx (network drop, server killed the session, idle timeout, driver.ErrBadConn), or an Oracle-side error preventing a new transaction on that session.","commonSituations":"Oracle session killed by a DBA or resource limit while the code runs; firewall/NAT dropping idle connections; begin called immediately after a reconnect where the pooled conn was stale.","solutions":["Retry the whole beginManualTransaction operation (pool will hand out a fresh connection)","Check for ORA- errors in the wrapped cause (e.g. ORA-00028 session killed, ORA-03113 end-of-file) and address per Oracle docs","Enable connection lifetime/max-idle tuning so stale connections are culled before reuse","Verify network stability between the driver host and the Oracle instance"],"exampleFix":"// before\ntx, err := conn.BeginTx(ctx, nil) // stale conn -> ORA-03113\n// after\nfor attempt := 0; attempt < 2; attempt++ {\n    if err := beginManualTransaction(s, schema); err == nil { break }\n    time.Sleep(500 * time.Millisecond) // retry gets a fresh pooled conn\n}","handlingStrategy":"retry","validationCode":"if err := db.PingContext(ctx); err != nil { return err } // ensure pool conns are healthy before reserve+begin","typeGuard":null,"tryCatchPattern":"err := beginManualTransaction(s, schema)\nif err != nil && strings.Contains(err.Error(), \"begin manual transaction\") {\n    time.Sleep(250 * time.Millisecond)\n    err = beginManualTransaction(s, schema) // retry gets a fresh pooled conn\n}","preventionTips":["Set ConnMaxLifetime below firewall/NAT idle timeouts so stale conns are culled","Retry reserve+begin as one unit — a reserved conn is closed on failure","Watch for ORA-03113/ORA-00028 in wrapped errors to address root cause","Begin the manual transaction promptly after reserving; avoid long gaps"],"tags":["go","oracle","transaction","stale-connection"],"backgroundTag":"begin-transaction-failed","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}