Skip to content

Commit

Permalink
sqlite: adjust transaction time
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Mar 6, 2024
1 parent 03fd5eb commit 3dbf170
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions persist/sqlite/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ func sqliteFilepath(fp string) string {
// an error, the transaction is rolled back. Otherwise, the transaction is
// committed.
func doTransaction(db *sql.DB, log *zap.Logger, fn func(tx *txn) error) error {
start := time.Now()
dbtx, err := db.Begin()
if err != nil {
return fmt.Errorf("failed to begin transaction: %w", err)
}
start := time.Now()
defer func() {
if err := dbtx.Rollback(); err != nil && !errors.Is(err, sql.ErrTxDone) {
log.Error("failed to rollback transaction", zap.Error(err))
Expand All @@ -89,7 +89,6 @@ func doTransaction(db *sql.DB, log *zap.Logger, fn func(tx *txn) error) error {
log.Debug("long transaction", zap.Duration("elapsed", time.Since(start)), zap.Stack("stack"), zap.Bool("failed", err != nil))
}
}()

tx := &txn{
Tx: dbtx,
log: log,
Expand Down

0 comments on commit 3dbf170

Please sign in to comment.