Re: [GENERAL] Updates, ShareLocks, RowExclusiveLocks, and deadlocks

2012-04-25 Thread Tom Lane
Martijn van Oosterhout writes: > I think what you're missing here is that RowExclusiveLocks are taken by > marking the row itself. More specifically: row-level locks are not reflected in pg_locks at all. A RowExclusiveLock entry in pg_locks reflects a *table* level lock, which is taken by any INS

Re: [GENERAL] Updates, ShareLocks, RowExclusiveLocks, and deadlocks

2012-04-25 Thread Ben Chobot
On Apr 25, 2012, at 1:31 PM, Tom Lane wrote: > I don't have all the details in my head, but if you deliberately provoke > a deadlock by making two transactions update the same two rows in > opposite orders, you'll soon find out what it looks like in the log. Heh, duh. Looks like your first guess

Re: [GENERAL] Updates, ShareLocks, RowExclusiveLocks, and deadlocks

2012-04-25 Thread Martijn van Oosterhout
On Wed, Apr 25, 2012 at 01:12:37PM -0600, Ben Chobot wrote: > So, if I understand what you're saying, if I have two connections > each transactionally updating many rows, then each transaction will > need to acquire a RowExclusiveLock for each row (as documented), and > also (as not documented?) ea

Re: [GENERAL] Updates, ShareLocks, RowExclusiveLocks, and deadlocks

2012-04-25 Thread Tom Lane
Ben Chobot writes: > So, if I understand what you're saying, if I have two connections each > transactionally updating many rows, then each transaction will need to > acquire a RowExclusiveLock for each row (as documented), and also (as not > documented?) each acquisition will temporarily acqui

Re: [GENERAL] Updates, ShareLocks, RowExclusiveLocks, and deadlocks

2012-04-25 Thread Ben Chobot
On Apr 25, 2012, at 12:35 PM, Tom Lane wrote: > Ben Chobot writes: >> We have a few daemon process that constantly pull batches of logs from a >> work queue and then insert into or update a single table in a single >> transaction, ~1k rows at a time. I've been told the transaction does nothing

Re: [GENERAL] Updates, ShareLocks, RowExclusiveLocks, and deadlocks

2012-04-25 Thread Tom Lane
Ben Chobot writes: > We have a few daemon process that constantly pull batches of logs from a work > queue and then insert into or update a single table in a single transaction, > ~1k rows at a time. I've been told the transaction does nothing other than > insert and update on that table, and I

[GENERAL] Updates, ShareLocks, RowExclusiveLocks, and deadlocks

2012-04-25 Thread Ben Chobot
We have a few daemon process that constantly pull batches of logs from a work queue and then insert into or update a single table in a single transaction, ~1k rows at a time. I've been told the transaction does nothing other than insert and update on that table, and I can verify the table in que