align-toparrow-leftarrow-rightbackbellblockcalendarcamerachatcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-crosscrosseditfacebookglobegoogleimagesinstagramlocation-pinmagnifying-glassmailmoremuplabelShape 3 + Rectangle 1outlookpersonplusImported LayersImported LayersImported Layersshieldstartwitteryahoo

Re: [ljc] Maintaining a consistent view

From: Martijn V.
Sent on: Saturday, March 16, 2013 12:52 PM
In fact Richard and John solved this problem recently at jClarity, it was an interesting discussion, espeically around the time vs id ordering - as it turns out you just can't trust clocks :-).


On 15 March[masked]:47, Richard Warburton <[address removed]> wrote:

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 [0].

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.

Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Richard Warburton ([address removed]) from LJC - London Java Community.
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]

Our Sponsors

  • Our Blog

    Read the latest news from the LJC

  • RecWorks Ltd

    Fixing Tech Recruitment using the Power of Community

  • jClarity

    Java/JVM Performance Analysis Tools & mentoring for Java related matters

  • LJC Aggrity

    Our LJC Aggrity site contains blog posts from our members

  • LJC Book Club

    Our Book club with book reviews from our members

  • Devoxx UK

    Java Community Conference in collaboration with the LJC, 8-10th June 16

  • SkillsMatter

    "Host, help organise, promote, film many of our meetings."

  • IBM

    Build Enterprise-grade apps at start-up speed.

  • New Relic

    New Relic makes sense of billions of metrics a day in real time.

  • Hazelcast

    Hazelcast is the leader in operating in-memory computing.

  • Java.Net

    We are an official Java User Group recognised by Oracle's JUG program

  • JRebel

    Free 3 month J-Rebel license.

  • O'Reilly

    40% discount on printed books and 50% on e-books.

  • Craft Rebellion

    Your choice of fresh craft beer, delivered. For 10% off use ‘LJC'

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy