Considerations for bitemporal data in a distributed data store – Part 1

I’m calling this Part 1 of what may be an ongoing theme in this blog: considerations for storing bitemporal in a distributed data store. In my particular case, that data store is Oracle’s Coherence.

Standard three-timestamp or four-timestamp bitemporal data makes use of a Transaction or Transaction Start time to give distinguish entries with partially or fully overlapping Valid Time ranges. In fact, the Transaction Start time should be unique for all entries which refer to a given atomic unit of data in the data store (a particular object, if your datastore records objects, or a particular attribute if that is what it records). In some RDBMS, the uniqueness of Transaction Start is accomplished automatically. In others, it may be easily accomplished by virtue of having a single centralized transaction point and system clock. However, in distributed environment, one must make a little extra effort due to the distributed nature of transactions and the probable differences in system clocks among the members of the system.

The solution I have used is to write a so-called “sequential now” timestamp generator. This is a service provider which behaves very similarly to a distributed ID generator. It transactionally ensures that, when demanded, the client receives a timestamp that represents “now” except in the case that “now” is equal to the previously provided “now”, in which case it increments the previous “now” by the smallest possible increment (defined by the granularity of the system or chronon) and then provides it. Provided that the granularity of your system or chronon is small, ie. on the order of nanoseconds, this is likely to be an acceptable approach. If, on the other hand, your granularity is on the order of seconds, minutes, or hours, increasing transaction rates will cause an undesirable situation where the “sequential now” creeps further and further away from system now or realtime now. In such a situation, another approach is likely to be required.

In Coherence, such a generator can be easily implemented as an EntryProcessor. That is left as an excercise for the reader.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.