Commit 987bb4f
committed
fix(turso): replace client.transaction() with UPDATE...RETURNING to prevent connection leak in queue poller
@libsql/client's transaction() method sets this.#db = null after BEGIN
so that concurrent execute() calls use a separate connection. After
commit/rollback, the detached Database object is abandoned to GC. At the
default 100ms poll interval this orphans ~10 native SQLite connections
per second — more than GC can reclaim — exhausting OS file-handle or
native-heap limits and crashing the host process (exit code 5) after
5-10 minutes of idle operation.
Replacing the three-step SELECT + UPDATE + COMMIT with a single atomic
UPDATE...RETURNING via client.execute() preserves atomicity through
SQLite's implicit per-statement transaction while reusing the single
cached connection (execute() calls #getDb() without nulling #db).
Fixes: https://github.com/mizzle-dev/workflow-worlds/issues/TBD1 parent 4c2fed0 commit 987bb4f
1 file changed
Lines changed: 20 additions & 38 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | | - | |
241 | 240 | | |
242 | 241 | | |
243 | 242 | | |
| |||
247 | 246 | | |
248 | 247 | | |
249 | 248 | | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
263 | 257 | | |
264 | 258 | | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
282 | 264 | | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
288 | 272 | | |
289 | | - | |
290 | | - | |
291 | 273 | | |
292 | 274 | | |
293 | 275 | | |
| |||
0 commit comments