I am using Postgres 9.3.
I have 2 tables : authn_session and customer. Every authn_session belongs to a customer (and hence has a customer_id as a column which is a FK to customer’s id).
Now, I start 2 different transactions which do the following in the below mentioned order :
BEGIN; UPDATE customer SET customer__created_by = (case when customer__created_by = 1 then 5 else customer__created_by end), customer__modified_by = (case when customer__modified_by = 1 then 5 else customer__modified_by end); UPDATE authn_session SET authn_session__created_by = (case when authn_session__created_by = 1 then 5 else authn_session__created_by end), authn_session__modified_by = (case when authn_session__modified_by = 1 then 5 else authn_session__modified_by end);
Tx : 2
BEGIN; DELETE FROM authn_session WHERE authn_session__guid IN ('abc3344-ab12-4444-9fdd-f4c5a6f7f210'); DELETE FROM customer WHERE customer__id != 0 AND customer__id = 3 AND customer__name = 'C2' AND customer__domain_name = 'a2.com';
Now, When I look at the locks, using the query mentioned below, one particular row interests me :
locktype | relation |mode |tid| vtid| pid | granted tuple | authn_session|AccessExclusiveLock | | 11/5| 47894| TRUE
SELECT locktype, relation::regclass, mode, transactionid AS tid, virtualtransaction AS vtid, pid, granted FROM pg_catalog.pg_locks l LEFT JOIN pg_catalog.pg_database db ON db.oid = l.database WHERE (db.datname = 'mY-db' OR db.datname IS NULL) AND NOT pid = pg_backend_pid();
Now, according to the postgres documentation AccessExclusiveLocks are granted only in case of :
Acquired by the ALTER TABLE, DROP TABLE, TRUNCATE, REINDEX, CLUSTER, and VACUUM FULL commands. This is also the default lock mode for LOCK TABLE statements that do not specify a mode explicitly.
I am not doing any of those things explicitly. Then why is my second process (running the second transaction – I checked it’s value in DB) getting an AccessExclusiveLock?. And why does the pg_activities_blocked view say that the second process (Delete) is blocked by the first (UPDATE)?
BTW, the result of running these two queries simultaneously leads to a deadlock. Am I missing anything that could lead to the second process getting an AccessExclusiveLock on the tuple?
✓ Extra quality
ExtraProxies brings the best proxy quality for you with our private and reliable proxies
✓ Extra anonymity
Top level of anonymity and 100% safe proxies – this is what you get with every proxy package
✓ Extra speed
1,ooo mb/s proxy servers speed – we are way better than others – just enjoy our proxies!
USA proxy location
We offer premium quality USA private proxies – the most essential proxies you can ever want from USA
Our proxies have TOP level of anonymity + Elite quality, so you are always safe and secure with your proxies
Use your proxies as much as you want – we have no limits for data transfer and bandwidth, unlimited usage!
Superb fast proxy servers with 1,000 mb/s speed – sit back and enjoy your lightning fast private proxies!
99,9% servers uptime
Alive and working proxies all the time – we are taking care of our servers so you can use them without any problems
No usage restrictions
You have freedom to use your proxies with every software, browser or website you want without restrictions
Perfect for SEO
We are 100% friendly with all SEO tasks as well as internet marketing – feel the power with our proxies
Buy more proxies and get better price – we offer various proxy packages with great deals and discounts
We are working 24/7 to bring the best proxy experience for you – we are glad to help and assist you!