Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
A mechanism for managing concurrent access to shared data or resources by granting temporarily exclusive access to the processes requesting the lock.
0
votes
Can I set the maximum locking level that a transaction can acquire?
In the case of ACCESS SHARE, you could do that with
SET default_transaction_read_only = on;
That will cause an error as soon as anybody wants to take a lock higher than ACCESS SHARE.
But it seems tha …
0
votes
In postgres, is using a lock better than transaction when reading data?
I think that you can prevent this problem by putting FOR UPDATE at the end of your SELECT statements. I am not sure because your description is somewhat confusing.
To avoid deadlocks, add an ORDER BY …
1
vote
Are race conditions possible in SQL?
What the SQL standard has to say about concurrency is the definition of transaction isolation levels. Depending on which one you choose, you get certain guarantees. I won't quote the standard, since t …
0
votes
Accepted
What are disadvantages of using locktable?
The idea to synchronize application threads via regular row locks in a special table is a bad one. The reason is that you need to keep a database transaction open as long as you want to hold the lock, …
0
votes
Explicit locks in RedShift
Assuming that it works like PostgreSQL in this case:
This is a serialization error that you get because you are using the SERIALIZABLE transaction isolation level.
That is nothing to worry about, ju …
0
votes
Does Postgresql apply the same type of locks on UPDATE with range condition and on UPDATE wi...
Yes, both statements will take a UPDATE lock on all the modified rows.
See the documentation on row locks:
The FOR UPDATE lock mode is also acquired by any DELETE on a row, and also by an UPDATE …
1
vote
CREATE TABLE in Postgres locks pg_class forever
Normal operations don't place a persistent lock on pg_class.
There must be a DDL command (CREATE TABLE, DROP TABLE or similar) that is blocked because of a lock, so that it cannot complete the operat …
0
votes
Is there a way to see what locks a stored procedure obtains?
You can query pg_locks after the procedure is done, but before the transaction ends. Since locks are held until the end of the transaction, you should see all locks taken by statements in the procedur …
3
votes
How to lock entire Postgres table but allow reads
Explicitly locking tables is almost always the wrong thing to do. If you describe the use case in more detail, I am confident that a better solution can be found. … Locking tables frequently will keep autovacuum from doing its important work on the table, and eventually an anti-wraparound autovacuum job will come along and block you, bringing processing to a standstill …
2
votes
Accepted
How to simulate FOR UPDATE lock on UPDATE on PostgreSQL?
Locks are not taken when the statement starts, but when the row is found. Since you are using pg_sleep(5) in the WHERE condition, it take five seconds before the row is found and PostgreSQL attempts t …
4
votes
Accepted
Advisory locks: private to connected database or shared across cluster?
That is indeed not clear from the documentation, but a simple experiment shows that advisory locks are local to the database. That is, you can take the same advisory lock in two different databases wi …
1
vote
Accepted
Postgres - How to prevent locking when parent table is updated whenever an insert/delete occ...
My advice is to use a “deferred constraint trigger” to update the "Products" table whenever "Items" is modified.
Such triggers are AFTER triggers that are not run immediately after the statement, but …
0
votes
SELECT FOR UPDATE (NOWAIT) on auxilliary table for serializing updates?
You could use transaction level advisory locks to serialize your operations:
BEGIN;
-- take an advisory lock for the duration of the session
SELECT pg_advisory_xact_lock(4711);
SELECT * FROM inventory …
0
votes
Does UPDATE FROM VALUES lock rows in the order they are listed?
The order in which rows are locked is not guaranteed. You could use EXPLAIN to see the execution plan, which will reveal what the database does. But don't rely on an execution plan: changes in the dat …
2
votes
Accepted
Zabbix partitioning autovacuum causes locking
A normal autovacuum process will succumb silently if it blocks another transaction, but if that happens all the time and autovacuum can never finish, you will eventually have old table rows that have …