Multi-user operation (was Re: Query for splits)

Derek Atkins warlord at MIT.EDU
Wed Nov 15 13:33:07 EST 2006


Phil Longstaff <plongstaff at rogers.com> writes:

> On Sun, 2006-12-11 at 15:18 -0500, Derek Atkins wrote:
>
>> Not only that -- you need to check whether the transaction content in the
>> DB is "newer" than the cache in the engine.  E.g. in a multi-user situation
>> one user may have modified the contents of a transaction, so when another
>> user performs a 'refresh' you DO have to load the new contents into the
>> engine.
>> 
>> So.. "loaded" is not a sufficient check for "should I refresh the engine
>> cache"...  I'll note that we might need to modify QOF to also maintain
>> an internal "last modified" tag in order to help us here.
>
> qof_begin_edit() and qof_commit_edit() are used around a number of
> operations which modify the same object.  For multi-user operation, if I
> edit an account, the backend should be told so that it can lock that
> object.  Then, if another person tries to edit it, their lock attempt
> will find out that the object is locked and will only allow the person
> to view the object.  Otherwise, we will have synchronization problems
> with people stomping on other people's changes.  This also means that
> when the backend attempts to lock an object, it should also refresh it.

Yes.  Keep in mind that once you get to the point of getting told
"object is locked", it's already too late..  There's no error code
returned from begin_edit() that could get displayed to the user.  In
this case I think it's "last writer wins", but I think that's okay.
You could make begin_edit() block until the other client commits the
edit on the same object, but that might impose some usability issues.

As for the refresh, yes, you could refresh on begin_edit, but you
really should refresh more often than that.  The current PG Backend
uses NOTIFY() and events to inform multiple clients that changes have
been made.  This isn't portable, so we can't use this method directly.
BUT we should periodically poll the database and ask something like:

  select * from Changes where change_time > [last_poll]

> Phil

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list