![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
Are the plans to implement row level exclusive locking that prevents readers and writers in future versions of PostgreSQL? |
#2
| |||
| |||
|
|
I'd like to do exclusive row level locking that blocks readers as well as writers. It seems impossible to do in PostgreSQL 8.4 based on this documentation: [...] It is very undesirable to lock the whole table because that prevents concurrent clients that would need locks to only their "own" rows. Are the plans to implement row level exclusive locking that prevents readers and writers in future versions of PostgreSQL? |
#3
| |||
| |||
|
|
I'd like to do exclusive row level locking that blocks readers as well as writers. It seems impossible to do in PostgreSQL 8.4 based on this documentation: I am sure that this is never going to happen, as it is considered one of the most desirable features of PostgreSQL that a reader is (almost) never blocked. I'd be curious to know your problem: what makes you want to block readers? Maybe there is some other way to achieve your goal. There is an integer column that needs to be read-and-updated in exclusive mode. If I get two instances trying to do this without exclusive locking, there exists the classic race condition where, for instance, the following is possible: client A reads an INT column, getting, say, 7 client B reads the same INT, also getting 7 client A increments INT value, making it 8 client B increments INT value, making it 8 I could have lots of clients, so creating SEQUENCE objects for each of them sounds undesirable. What is more, the integer progression is not always monotonically increasing (e.g. 1, 2, 3), it could be 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 21, 22, 23). Anyway, this case may well be an instance of the "premature optimization is the root of all evil" problem. I discussed the issue with a colleague and he thinks the table level locking will not harm performance here. |
![]() |
| Thread Tools | |
| Display Modes | |
| |