in reply to How to deal with data race issues with Perl?

One very useful concept that ought to be tossed-in to the design of such a system is that of generations.   Each time a change to a record is accepted, a new “generation” of that record is created, and if you ask for “the record” you are given the latest generation of it, but all of the generations are kept.

You also aggressively use the notion of “unique identifiers,” or as I like to call them, monikers.   Monikers are associated with the identity of the base-document, and other monikers are also associated with every generation.   So, when a particular user wants to synchronize, there is never any ambiguity to figure-out.   The client software can hand you an unambiguous list of exactly what he’s holding, and can likewise refer unambiguously both to “the thing being updated” and to “the update itself.”   (If you use a well-known algorithm such as UUID, notice that clients can generate monikers too, and those monikers will never “crash” against anybody else’s.   A provably-strong message digest algorithm, such as SHA1, provides a useful field-value that can be used to detect differences between the various stored items.)

I believe that these are two most-important elements of any data synchronization design:   retaining all copies of the information, and removing all sources of ambiguity.   Message-digests and UUID-based monikers are completely unambiguous, and they’re short-n-sweet.

Replies are listed 'Best First'.
Re^2: How to deal with data race issues with Perl?
by JavaFan (Canon) on Dec 30, 2010 at 14:35 UTC
    How does this help solve the problem the OP is describing: two users, each having a local copy, modify the data, and now want to resync?

      I think his suggestion was offered in the spirit of raising additional design issues for consideration. Does the client need only the merged view or both a history of changes and the merged view? It affects how the resync process is carried out and what data is stored after it is done.

      Full audit trails (who wanted to make what change when) are a legal and liability necessity in certain accounting and legal/corporate document editing systems. The OP has not stated the nature of the data nor the business process.

      Secondly, he is proposing an architecture that allows separation of concerns - (a) the making and tracking of changes (b) the merging of changes into a cohesive view. If each separate change request is recorded, the algorithm for merging them can be changed over time based on developing user requirements.

      Separation of concerns can make this an attractive base architecture when the user's requirements are in flux due to an internal learning curve for the business process in question or when needs are liable to change due to a fast changing business environment. On the other hand, it costs more to implement and increases data storage demands, so a base requirement for an audit trail in addition to the merged view is probably in order before pursuing such a design.