question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

KeyError in thread completion_refresh

See original GitHub issue

Description

I get this error occasionally here and there. I ^C and things work again.

Exception in thread completion_refresh:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/local/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/site-packages/pgcli/completion_refresher.py", line 65, in _bg_refresh
    refresher(completer, executor)
  File "/usr/local/lib/python2.7/site-packages/pgcli/completion_refresher.py", line 105, in refresh_tables
    completer.extend_columns(executor.table_columns(), kind='tables')
  File "/usr/local/lib/python2.7/site-packages/pgcli/pgcompleter.py", line 158, in extend_columns
    metadata[schema][relname][colname] = column
KeyError: u'_stmp_3fc53b90_a'

Your environment

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
j-bennetcommented, Feb 21, 2022

This version of pgcli (1.10.3) is very old. Issue was fixed in 3.0.0, in https://github.com/dbcli/pgcli/pull/1145. Latest released pgcli version is 3.1.0, I’d recommend updating to that.

1reaction
kennethkalmercommented, Jun 19, 2019

I just encountered a very similar issue after adding foreign keys to a partitioned table. Without the foreign keys partitioned tables work like a charm in pgcli. Turns out it can be reproduced quite easily:

$ createdb dev
$ pgcli dev
Server: PostgreSQL 11.3
Version: 2.1.1
Chat: https://gitter.im/dbcli/pgcli
Mail: https://groups.google.com/forum/#!forum/pgcli
Home: http://pgcli.com
kenneth@/tmp:dev> create table cities (id serial primary key not null, "name" text);
CREATE TABLE
Time: 0.009s
kenneth@/tmp:dev> CREATE TABLE measurement (
     city_id         bigint references cities (id),
     logdate         date not null,
     peaktemp        int,
     unitsales       int
 ) PARTITION BY RANGE (logdate);
CREATE TABLE
Time: 0.006s
kenneth@/tmp:dev> Exception in thread completion_refresh:
Traceback (most recent call last):
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 865, in runompletions...
    self._target(*self._args, **self._kwargs)
  File "/usr/local/Cellar/pgcli/2.1.1/libexec/lib/python3.7/site-packages/pgcli/completion_refresher.py", line 65, in _bg_refresh
    refresher(completer, executor)
  File "/usr/local/Cellar/pgcli/2.1.1/libexec/lib/python3.7/site-packages/pgcli/completion_refresher.py", line 110, in refresh_tables
    completer.extend_foreignkeys(executor.foreignkeys())
  File "/usr/local/Cellar/pgcli/2.1.1/libexec/lib/python3.7/site-packages/pgcli/pgcompleter.py", line 278, in extend_foreignkeys
    childcolmeta = meta[childschema][childtable][childcol]
KeyError: 'measurement'

kenneth@/tmp:dev> \d measurement;
+-----------+---------+-------------+
| Column    | Type    | Modifiers   |
|-----------+---------+-------------|
| city_id   | bigint  |             |
| logdate   | date    |  not null   |
| peaktemp  | integer |             |
| unitsales | integer |             |
+-----------+---------+-------------+
Partition key: RANGE (logdate)

Time: 0.024s

Note the output doesn’t show the foreign key, where psql displays it:

$ ~ psql dev
psql (11.3)
Type "help" for help.

dev=# \d measurement
              Table "public.measurement"
  Column   |  Type   | Collation | Nullable | Default
-----------+---------+-----------+----------+---------
 city_id   | bigint  |           |          |
 logdate   | date    |           | not null |
 peaktemp  | integer |           |          |
 unitsales | integer |           |          |
Partition key: RANGE (logdate)
Foreign-key constraints:
    "measurement_city_id_fkey" FOREIGN KEY (city_id) REFERENCES cities(id)
Number of partitions: 0
Read more comments on GitHub >

github_iconTop Results From Across the Web

"Exception in thread" error when updating key-value pair in a ...
When the migration is complete, you will access your Teams at stackoverflowteams.com, and they will no longer appear in the left sidebar on ......
Read more >
Exception KeyError in module threading - Google Groups
I have a Django app running that *appears* to work fine (from a user's perspective). But the error_log is constantly filled with these...
Read more >
Error Messages - SQLAlchemy 1.4 Documentation
Solution is to make sure ORM sessions if using the ORM, or engine-bound Connection objects if using Core, are explicitly closed at the...
Read more >
Changelog — Python 3.11.1 documentation
Cursor.rowcount when a DML statement has run to completion. This fixes the row count for SQL queries like UPDATE ... RETURNING . Patch...
Read more >
errors – Exceptions raised by the pymongo package
Raised when an insert or update fails due to a duplicate key error. exception pymongo.errors.ExceededMaxWaiters¶. Raised when a thread tries to get a ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found