I have the following SQL query and error:
File "/home/pchong/anaconda3/envs/jobserveee/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 608, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.InternalError: (psycopg2.errors.ReadOnlySqlTransaction) cannot execute LOCK TABLE during recovery
CONTEXT: SQL statement "lock table id in exclusive mode"
PL/pgSQL function soft_batch_allocate_id(character varying,character varying[],character varying) line 21 at SQL statement
[SQL: select * from soft_batch_allocate_id(%(source)s, array[%(i0)s,%(i1)s,%(i2)s,%(i3)s,%(i4)s,%(i5)s,%(i6)s,%(i7)s,%(i8)s,%(i9)s,%(i10)s,%(i11)s], %(class)s)]
[parameters: {'source': 'CCCC', 'i0': 'cccc-xsto_equity-O-BOTC', 'i1': 'cccc-xsto_equity-O-TQEX', 'i2': 'cccc-xsto_equity-O-AQXE', 'i3': 'cccc-xsto_equity-O-CHIX', 'i4': 'cccc-xsto_equity-O-SGMX', 'i5': 'cccc-xsto_equity-O-XEQT', 'i6': 'cccc-xsto_equity-O-CEUX', 'i7': 'cccc-xsto_equity-O-BATE', 'i8': 'bccccll-xsto_equity-O-AQEU', 'i9': 'cccc-xsto_equity-O-XSTO', 'i10': 'cccc-xsto_equity-O-TRQX', 'i11': 'cccc-xsto_equity-O-SGMU', 'class': 'IndexMarket'}]
Any ideas why I am getting this error?
You are connected to a server that is in recovery mode (probably a streaming replication standby server). You cannot modify or lock tables on such a server.
To see for yourself, run
SELECT pg_is_in_recovery();
If the result is TRUE
or t
, that's the reason why you are seeing this error.