* 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
()
| 398 | * covers the rest of the run. |
| 399 | */ |
| 400 | async recycleWorkers(): Promise<void> { |
| 401 | if (this.failed) throw this.failed; |
| 402 | await Promise.all( |
| 403 | this.workers.map( |
| 404 | (pw) => |
| 405 | new Promise<void>((resolve, reject) => { |
| 406 | const id = this.nextId++; |
| 407 | const t = setTimeout(() => { |
| 408 | if (this.recycleWaiters.delete(id)) { |
| 409 | const err = new Error('resolver worker recycle timed out'); |
| 410 | this.fail(err); |
| 411 | reject(err); |
| 412 | } |
| 413 | }, 10_000); |
| 414 | this.recycleWaiters.set(id, () => { |
| 415 | clearTimeout(t); |
| 416 | resolve(); |
| 417 | }); |
| 418 | pw.worker.postMessage({ type: 'recycle', id }); |
| 419 | }) |
| 420 | ) |
| 421 | ); |
| 422 | } |
| 423 | |
| 424 | /** |
| 425 | * Ask every worker to close; each collects garbage and exits by itself (see |
no test coverage detected