Commit 95792e4
committed
fix: prevent SQLITE_BUSY on concurrent v2 writes
The busy_timeout PRAGMA is per-connection, but it was only set on the
single connection touched at startup by setV2WALMode(); the other pooled
connections defaulted to busy_timeout=0 and failed immediately under
write contention. Sequelize's sqlite dialect does not honour
dialectOptions.busyTimeout, so set busy_timeout on every pooled
connection via the shared installSqlitePragmas hook.
Also set transactionType=IMMEDIATE on the v2 sqlite configs. SQLite
ignores busy_timeout when a DEFERRED transaction upgrades a held read
lock to a write lock (it returns SQLITE_BUSY at once to avoid deadlock),
which intermittently failed read-then-write transactions (e.g. cascade
delete staging) racing the background sync. IMMEDIATE acquires the write
lock up front so they queue on busy_timeout instead.1 parent 74febd8 commit 95792e4
2 files changed
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
121 | 128 | | |
122 | 129 | | |
123 | 130 | | |
124 | 131 | | |
| 132 | + | |
125 | 133 | | |
126 | 134 | | |
127 | 135 | | |
| |||
130 | 138 | | |
131 | 139 | | |
132 | 140 | | |
| 141 | + | |
133 | 142 | | |
134 | 143 | | |
135 | 144 | | |
136 | 145 | | |
137 | 146 | | |
| 147 | + | |
138 | 148 | | |
139 | 149 | | |
140 | 150 | | |
| |||
143 | 153 | | |
144 | 154 | | |
145 | 155 | | |
| 156 | + | |
146 | 157 | | |
147 | 158 | | |
148 | 159 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
7 | 13 | | |
8 | 14 | | |
9 | 15 | | |
| |||
0 commit comments