@@ -28,6 +28,7 @@ import (
28
28
const (
29
29
DefaultMonitorInterval = 1 * time .Second
30
30
DefaultCheckpointInterval = 1 * time .Minute
31
+ DefaultBusyTimeout = 1 * time .Second
31
32
DefaultMinCheckpointPageN = 1000
32
33
DefaultMaxCheckpointPageN = 10000
33
34
DefaultTruncatePageN = 500000
@@ -37,9 +38,6 @@ const (
37
38
// If this index is reached then a new generation will be started.
38
39
const MaxIndex = 0x7FFFFFFF
39
40
40
- // BusyTimeout is the timeout to wait for EBUSY from SQLite.
41
- const BusyTimeout = 1 * time .Second
42
-
43
41
// DB represents a managed instance of a SQLite database in the file system.
44
42
type DB struct {
45
43
mu sync.RWMutex
@@ -103,6 +101,9 @@ type DB struct {
103
101
// Frequency at which to perform db sync.
104
102
MonitorInterval time.Duration
105
103
104
+ // The timeout to wait for EBUSY from SQLite.
105
+ BusyTimeout time.Duration
106
+
106
107
// List of replicas for the database.
107
108
// Must be set before calling Open().
108
109
Replicas []* Replica
@@ -125,6 +126,7 @@ func NewDB(path string) *DB {
125
126
TruncatePageN : DefaultTruncatePageN ,
126
127
CheckpointInterval : DefaultCheckpointInterval ,
127
128
MonitorInterval : DefaultMonitorInterval ,
129
+ BusyTimeout : DefaultBusyTimeout ,
128
130
Logger : slog .With ("db" , path ),
129
131
}
130
132
@@ -411,7 +413,7 @@ func (db *DB) init() (err error) {
411
413
db .dirInfo = fi
412
414
413
415
dsn := db .path
414
- dsn += fmt .Sprintf ("?_busy_timeout=%d" , BusyTimeout .Milliseconds ())
416
+ dsn += fmt .Sprintf ("?_busy_timeout=%d" , db . BusyTimeout .Milliseconds ())
415
417
416
418
// Connect to SQLite database. Use the driver registered with a hook to
417
419
// prevent WAL files from being removed.
0 commit comments