* Ask every worker to close and reopen its read-only connection, and wait * for all acks. MUST be called only at the pool-idle boundary (all fanned * chunks settled, next batch not yet dispatched) — the workers close their * connections in place. Why: a long-lived reader pins WAL checkpoint
()
| 296 | * covers the rest of the run. |
| 297 | */ |
| 298 | async recycleWorkers(): Promise<void> { |
| 299 | if (this.failed) throw this.failed; |
| 300 | await Promise.all( |
| 301 | this.workers.map( |
| 302 | (pw) => |
| 303 | new Promise<void>((resolve, reject) => { |
| 304 | const id = this.nextId++; |
| 305 | const t = setTimeout(() => { |
| 306 | if (this.recycleWaiters.delete(id)) { |
| 307 | const err = new Error('resolver worker recycle timed out'); |
| 308 | this.fail(err); |
| 309 | reject(err); |
| 310 | } |
| 311 | }, 10_000); |
| 312 | this.recycleWaiters.set(id, () => { |
| 313 | clearTimeout(t); |
| 314 | resolve(); |
| 315 | }); |
| 316 | pw.worker.postMessage({ type: 'recycle', id }); |
| 317 | }) |
| 318 | ) |
| 319 | ); |
| 320 | } |
| 321 | |
| 322 | async destroy(): Promise<void> { |
| 323 | await Promise.all( |
no test coverage detected