On Tue, 2002-11-05 at 10:15, Roger Haase wrote:

> In Jason's paper and elsewhere in the MiddleKit docs there is some
> advice on avoiding concurrency issues:

> During some stress testing a few days ago I found that if two servlets
> are updating or inserting different records at the same time using a
> single store, then a store.saveChanges() from either of the servlets
> writes all updated records in the store to the database.

I have also run into this problem.  I fixed it locally by modifying
SQLObjectStore to keep track of updated, created and deleted objects on
a per-thread basis.  So when you call store.saveChanges(), only the
objects which were "touched" by that thread are committed -- all other
objects are left alone.  

Note that this doesn't prevent two threads from modifying the same
object -- we'd need per-object locks for that.

The requirement in terms of user code are:

   - for WebKit applications, make sure you call saveChanges before the
current request is completed.  I put a this into my SitePage.sleep() to
catch programming errors:
        assert not self.store().hasChangesForCurrentThread()

   - for standalone Python programs, you have to call saveChanges() with
the same thread which created/modified/deleted the objects.  Probably
most standalone programs are single-threaded (mine are), so there is no
issue.

If these requirements are general enough, I'll document this and commit
the fix to CVS.  What do you think, Chuck?

In any case, it would be a good first step to see if it solves your
problem, Roger.  I can send you a patch, just let me know if you use the
0.7 release or CVS.

-- 
Jason D. Hildebrand
[EMAIL PROTECTED]



-------------------------------------------------------
This sf.net email is sponsored by: See the NEW Palm 
Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to