❓ PostgreSQL Insert Appears Stuck — No Error, Just Hanging / Deadlocking
Hi all,
I'm dealing with a persistent issue when trying to insert rows into my new PostgreSQL table (KeywordInsight). My insert statements don’t fail or throw any errors — they simply hang indefinitely. This behavior persists even for single-row inserts. It works on dev side and I deployed and the table is also visible on prod side but empty.
Setup Python app using psycopg2 and a connection pool (SimpleConnectionPool)
The database and other tables work fine
Insert uses this structure (note: it's string-interpolated, not parameterized):
model KeywordInsight { id Int @id @default(autoincrement()) keyword String @unique volume12m Int @default(0) volume12mNL Int @default(0) volume12mBE Int @default(0) volumeLastMonth Int @default(0) listings Int sponsoredListings Int medianPrice Float medianReview Float medianReviews Int extraFilterOptions String? // JSON string (geëncodeerd), consistent met rest van systeem updatedAt DateTime @updatedAt}
model KeywordInsight { id Int @id @default(autoincrement()) keyword String @unique volume12m Int @default(0) volume12mNL Int @default(0) volume12mBE Int @default(0) volumeLastMonth Int @default(0) listings Int sponsoredListings Int medianPrice Float medianReview Float medianReviews Int extraFilterOptions String? // JSON string (geëncodeerd), consistent met rest van systeem updatedAt DateTime @updatedAt}
Symptoms When this query runs, no result returns, and it never finishes.
I see the query listed in pg_stat_activity in state = 'active', but it stays there for hours.
Even if I forcibly kill the PID via pg_terminate_backend, it comes back on re-run.
This only happens on this table — other inserts (same connection style) work fine.
What I Tried Killing all lingering sessions using pg_stat_activity
Restarting the script, terminals, and the machine itself
Checking for locks via pg_locks, pg_stat_activity, etc.
Using ON CONFLICT DO NOTHING in hopes it would skip collisions gracefully
Similar Threads
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community
W
Wasp
Rails-like framework for React, Node.js and Prisma. Build your app in a day and deploy it with a single CLI command.