|Sent on:||Saturday, March 16, 2013 12:52 PM|
The problem is how to ensure that the UI maintains a consistent view
of the DB. By consistent, I mean that if no changes occur to the DB
for a sufficiently long period, the UI should eventually come to
reflect the current state of the DB.This is termed "eventual consistency". I mention the name because gify more easily applies if you know it!If the UI receives "DB contains A, B, C" followed by "B removed" then
it will show a correct view of the DB; but if it receives "B removed"
followed by "DB contains A, B, C", it will incorrectly show that the
DB contains item B - and the view will remain incorrect indefinitely.
There's an obvious but heavy solution: poll the database for its
entire contents periodically. That achieves the goal of eventual
consistency, but I'm wondering whether there's a lighter solution -
this seems like a problem people must run into quite often.
I think the simplest way to address the problem that you mention is to define an ordering for your events - this might be a unique index for each event which gets updated, or it might be a timestamp. Be wary of usual time related caveats with the timestamp based approach: ie different machines may be out of sync, and it may go backwards. If you have properly synchronised time then don't worry - but that isn't usually the case.A more sophisticated approach to order based conflict resolution, which you may also want to look at, is a vector clock .As to whether this is a common problem - who's to say, no one does proper empirical research on what concurrency problems developers face. All I can offer is the anecdote that its a problem I've encountered more than once.This message was sent by Richard Warburton ([address removed]) from LJC - London Java Community.
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
To learn more about Richard Warburton, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages
Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]