You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
completion_refresh thread crashes with KeyError #1590
You can reproduce this by creating a table in between the calls to extend_relations and extend_columns in completion_refresher.py. The dict keyed on relname doesn't get created, and then after the table is created extend_columns looks up the new table and gets KeyError.
I repro this consistently due to another process programmatically creating tables often.
I can confirm this on my side. Same KeyError in the background completion_refresh thread, triggered when a relation is created in the window between extend_relations and extend_columns (we have external processes creating tables frequently, so it reproduces consistently).
The fix in #1591 resolves it by guarding the writes in extend_columns with setdefault instead of assuming the relation key already exists:
I've been running this patch in my fork (DiegoDAF/pgcli.daf) for a few weeks across daily use and the crash is gone, with no side effects on completion behavior.
The only thing blocking it is that #1591 currently shows merge conflicts. @shgol, would you be able to rebase it on current main? Happy to help get it over the line if useful. It would be great to land this, since the crash is easy to hit on busy databases.
Activity
shgol commentedon Jun 26, 2026
Sure, PR is ready again. Maintainers, feel free to merge when you'd like.
DiegoDAF commentedon Jun 29, 2026
I can confirm this on my side. Same
KeyErrorin the backgroundcompletion_refreshthread, triggered when a relation is created in the window betweenextend_relationsandextend_columns(we have external processes creating tables frequently, so it reproduces consistently).The fix in #1591 resolves it by guarding the writes in
extend_columnswithsetdefaultinstead of assuming the relation key already exists:I've been running this patch in my fork (DiegoDAF/pgcli.daf) for a few weeks across daily use and the crash is gone, with no side effects on completion behavior.
The only thing blocking it is that #1591 currently shows merge conflicts. @shgol, would you be able to rebase it on current
main? Happy to help get it over the line if useful. It would be great to land this, since the crash is easy to hit on busy databases.