fix(gateway): close kanban DB connection after dispatch tick#33113
Closed
cookily wants to merge 1 commit into
Closed
fix(gateway): close kanban DB connection after dispatch tick#33113cookily wants to merge 1 commit into
cookily wants to merge 1 commit into
Conversation
The kanban dispatcher's _tick_once_for_board() opens a SQLite connection via _kb.connect() but never closes it, leaking one file descriptor per 60-second tick. Over time this accumulates 50+ concurrent connections, causing SQLite 'disk I/O error' and eventual database corruption. Fix: wrap the connection in contextlib.closing() so it is reliably closed on both normal return and exception paths. Also removes the now-redundant finally: conn.close() block. This mirrors the same pattern already used in kanban_db.py's dispatch loop (line 5475).
Collaborator
|
Related to #29610 (root issue for kanban dispatcher SQLite connection/FD leak). This PR applies |
Collaborator
|
Closing as already fixed on main. The dispatcher tick now closes the connection via a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The kanban dispatcher's
_tick_once_for_board()ingateway/run.pyopens a SQLite connection via_kb.connect()on every 60-second dispatch tick, but never closes it. Over time (hours to days), this accumulates 50+ concurrent file descriptors tokanban.db, causing:disk I/O errorwhen too many connections contend for file locksdatabase disk image is malformed)Root Cause
The same function in
kanban_db.pyline 5475 already uses the correct pattern:Fix
Wrap the connection in
contextlib.closing()so it is reliably closed on both normal return and exception paths. Also removes the now-redundantfinally: conn.close()block.Changes: 1 file, +16/-21 lines
Verification
Reproduced in production (Hermes gateway running 2+ hours):