Hi Mike,
The problem I describe is a general problem that is independent from the amount of data, number of threads, number of servers, etc. When the number of threads is large, then you would increase the size of N. I thought my post would be a hard read. I just realized that I assumed implicitly knowledge of Java (thread local variables) and hibernate whereas this seems to be a pure DB-only forum. To explain the issue without the Java/hibernate stuff:
The locking table has a field with a counter that is used to implement optimistic locking (this is called version field in hibernate). When an update is done and the counter in the meanwhile has been incremented the update statement returns 0 rows (because the where clause fails when the counter has been changed meanwhile by another update statement) indiciating to the caller that the data has been changed in the meanwhile by someone else. This is called merge in hibernate.
Quote:
|
Problem here is that there can be races conditions in between the change over from the initial entry to the follow-up entry.
|
Do you understand that there is a problem here with a possible race condition (glitch)? If not, the whole problem and the sketched solution is hard to understand. The idea here with 2 entries that are updated at the same time for a certain time is to create a time window that is large enough that operations that still hold on to a reference to the first entry will have terminated long before N has become 0 and the first entry is deleted.
I'm using Oracle. Maybe there is an oracle trick to handle this problem. Unhappily, I don't know Oracle that well. But it is anyway about finding a general solution :-).
Regards, Oliver