fix: rebase onto main, fix SQLite concurrency, lint clean
All checks were successful
check / check (push) Successful in 2m11s
All checks were successful
check / check (push) Successful in 2m11s
- Add busy_timeout PRAGMA and MaxOpenConns(1) for SQLite stability - Use per-test temp DB in handler tests to prevent state leaks - Pre-allocate migrations slice (prealloc lint) - Remove invalid linter names (wsl_v5, noinlineerr) from .golangci.yml - Remove unused //nolint:gosec directives - Replace context.Background() with t.Context() in tests - Use goimports formatting for all files - All make check passes with zero failures
This commit is contained in:
@@ -81,7 +81,7 @@ func (s *Database) GetDB() *sql.DB {
|
||||
func (s *Database) connect(ctx context.Context) error {
|
||||
dbURL := s.params.Config.DBURL
|
||||
if dbURL == "" {
|
||||
dbURL = "file:./data.db?_journal_mode=WAL"
|
||||
dbURL = "file:./data.db?_journal_mode=WAL&_busy_timeout=5000"
|
||||
}
|
||||
|
||||
s.log.Info("connecting to database", "url", dbURL)
|
||||
@@ -104,6 +104,8 @@ func (s *Database) connect(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
d.SetMaxOpenConns(1)
|
||||
|
||||
s.db = d
|
||||
s.log.Info("database connected")
|
||||
|
||||
@@ -114,6 +116,13 @@ func (s *Database) connect(ctx context.Context) error {
|
||||
return fmt.Errorf("enable foreign keys: %w", err)
|
||||
}
|
||||
|
||||
_, err = s.db.ExecContext(
|
||||
ctx, "PRAGMA busy_timeout = 5000",
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("set busy timeout: %w", err)
|
||||
}
|
||||
|
||||
return s.runMigrations(ctx)
|
||||
}
|
||||
|
||||
@@ -233,7 +242,7 @@ func (s *Database) loadMigrations() (
|
||||
)
|
||||
}
|
||||
|
||||
var migrations []migration
|
||||
migrations := make([]migration, 0, len(entries))
|
||||
|
||||
for _, entry := range entries {
|
||||
if entry.IsDir() ||
|
||||
|
||||
Reference in New Issue
Block a user