![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Since database access is generally asynchronous, a map's keys may change while an iterator is running over it. |
|
Can anyone think of any other solution, which minimizes the work done by the server both to create and to increment the iterator? |
#3
| |||
| |||
|
|
Four possible approaches: (1) Read-back-in-time isolation between clients. Every transaction sees all objects in the state they were in when the transaction started. (2) Locking collections. When an iterator is running on a collection, lock it for updates. |

|
(3) Server-Side iterator failure. Throw an exception back at the client when the client tries to continue an iterator that does not work anymore, because the next element has been deleted. |

|
(4) Server-To-Client notification. Send a message to the client when changes to a Map are committed. |
#4
| |||
| |||
|
|
(1) Read-back-in-time isolation between clients. Every transaction sees all objects in the state they were in when the transaction started. |

#5
| |||||
| |||||
|
|
If you have a chance to look at this, be my guest. |
|
(1) Client A begins a transaction (2) Client A requests some info about object X (3) Client B begins a transaction (4) Client B requests that object X be mutated (5) Client B commits (6) Client A requests some more information about object X (7) Client A requests that object X be mutated (8) Client A commits Client A must see the same X in steps (2) and (6), despite the fact the B has mutated it. When client A commits, B's changes to X will be wiped out, but that's what we'd expect. OK, so that's the theory. How is it implemented in practice? |
|
If the transaction is committed, the server atomically *exchanges the identities of each of the key-value pairs in the SM*, and then clears the SM. |
|
So before B exchanges each pair of identities in its SM, it must show its SM to all other sessions with transactions in progress. |
|
Does all this seem familiar? Does it look right? |
#6
| |||||||||||
| |||||||||||
|
|
ODBMS usually offer none to three of the following isolation options: (1) Page locking If one transaction modifies objects on one page (a physical implementation detail), the page is locked for modifications by all other transactions until the transaction commits. (2) Object locking If one transaction modifies one object, the object is locked for modifications by all other transactions until the transaction commits. |
|
(3) Optimistic transactions If a transaction commits modified objects, the version number on all objects is checked, whether it is still the same as it was when the object was read. |
|
Furthermore some object databases provide notification handlers for committed objects. |
|
Typically all ODBMS implementations I know produce inconsistent objects in step (6) of your example unless they lock object X on read. |

|
In the long term I would like us to provide real "read-back-in-time" transactions for db4o also: That would mean that Client A would get information about object X in step (6) of your example exactly the way it was before the commit of Client B. |

|
So before B exchanges each pair of identities in its SM, it must show its SM to all other sessions with transactions in progress. This is prinicipally a nice idea but it may get you *lots* of network traffic if you have multiple clients connected. |
|
It also requires your clients to be able to handle pushed updates to objects... |
|
For db4o we get very frequent requests to provide this functionality (which we don't have yet) and we will build it. It will be very interesting to see it work live. |
|
Does all this seem familiar? Does it look right? All this looks very familiar. You may like to scan old entries in our db4o newsgroup with the search tool that we provide to read up some more of my thoughts in the past: http://www.db4odev.com/newsarchive/search.cmd Try the following two searches: Notification Locking AND design |
|
Is there anything already visible around your ODBMS project? |
.|
This is one of the most interesting discussions I have seen in this newsgroup for ages. Please keep us posted with your thoughts. |

#7
| |||
| |||
|
#8
| |||
| |||
|
#9
| |||
| |||
|
|
This is prinicipally a nice idea but it may get you *lots* of network traffic if you have multiple clients connected. |

![]() |
| Thread Tools | |
| Display Modes | |
| |