Skip to content

Commit

Permalink
sqlite: return err in store.prepare for slow query (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl authored Jun 12, 2024
1 parent f370102 commit 4f339bf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions persist/sqlite/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ func (s *Store) exec(query string, args ...any) (sql.Result, error) {
func (s *Store) prepare(query string) (*loggedStmt, error) {
start := time.Now()
stmt, err := s.db.Prepare(query)
if dur := time.Since(start); dur > longQueryDuration {
s.log.Debug("slow prepare", zap.String("query", query), zap.Duration("elapsed", dur), zap.Stack("stack"))
} else if err != nil {
if err != nil {
return nil, err
} else if dur := time.Since(start); dur > longQueryDuration {
s.log.Debug("slow prepare", zap.String("query", query), zap.Duration("elapsed", dur), zap.Stack("stack"))
}
return &loggedStmt{
Stmt: stmt,
Expand Down

0 comments on commit 4f339bf

Please sign in to comment.