1. Version Stamps
Dr. Dipali Meher
MCS, M.Phil,NET, Ph.D
Assistant Professor
Modern College of Arts Science and Commerce, Ganeshkhind, Pune 16
mailtomeher@gmail.com
3. Collected by Dr. Dipali Meher
Source: NoSQL Distilled:
Introduction
Lack of transaction in NoSQL
database. But they have
aggregates
Basically transactions are useful
tool for programmers to support
consistency
Aggregate oriented NoSQL
DB support atomic updates
with aggregates.
Transactional needs are
something to take into
account when you decide
what database to use.
But transactions have
limitations
In transactional system user
has to deal with updates with
human intervention which may
hold the transaction too long.
Above is done using Version
Stamps
4. Collected by Dr. Dipali Meher
Source NoSQL Distilled by
Business & System Transactions
Business Transaction: A business transaction may be something like
Browsing a product catalog
Choosing a bottle of Milton at a good price,
Filling in credit card information, and
Confirming the order
Locks are held for short period of time.
5. Collected by Dr. Dipali Meher
Source NoSQL Distilled
System Transactions
System Transaction: applications only begin a system transaction at
the end of the interaction with the user.
Locks are held for short period of time.
6. Collected by Dr. Dipali Meher
Source NoSQL Distilled
As locks are held for long period of time in business transactions and
short period of time in system transactions…
so calculations and decisions may have been made based on data
that’s changed.
Queries should be fired according to changes in data.
Example:
price list may have updated the price of the Milton,
updated the customer’s address,
changing the shipping charges.
7. Collected by Dr. Dipali Meher
Source NoSQL Distilled
Version Stamp
A field that changes every time the underlying data in
the record changes.
When you read the data you keep a note of the version
stamp, so that when you write data you can check to
see if the version has changed.
8. Collected by Dr. Dipali Meher
Source NoSQL Distilled
Example Version Stamps
updating resources with HTTP using etag system
Whenever you get a resource, the server responds with an etag in
the header.
etag(opaque string that indicates the version of the resource)
If you then update that resource, you can use a conditional
update by supplying the etag that you got from your last GET.
If the resource has changed on the server, the etags won’t match
and the server will refuse the update,
returning a 412 (Precondition Failed) response.
9. Collected by Dr. Dipali Meher
Source NoSQL Distilled by
Ways of creating Version Stamps
Counter GUID hash Timestamp
You can use
a counter
always
incrementing
it when you
update the
resource.
A large
random
number
that’s
guaranteed
to be unique.
hash of the
contents of
the
resource
timestamp
of the last
update
10. Collected by Dr. Dipali Meher
Source NoSQL Distilled
Ways of creating Version Stamps
Counter
You can use a counter always incrementing it when you
update the resource.
Counters are useful since they make it easy to tell if one
version is more recent than another.
They require the server to generate the counter value,
They need a single master to ensure the counters aren’t
duplicated.
11. Collected by Dr. Dipali Meher
Source NoSQL Distilled
Ways of creating Version Stamps
GUID
A large random number that’s guaranteed to be unique.
These use some combination of dates, hardware
information, and whatever other sources of randomness
they can pick up.
The nice thing about GUIDs is that they can be generated
by anyone and you’ll never get a duplicate;
A disadvantage is that they are large and can’t be
compared directly for recentness.
12. Collected by Dr. Dipali Meher
Source NoSQL Distilled
Ways of creating Version Stamps
Hash
To make a hash of the contents of the resource.
With a big enough hash key size, a content hash can be
globally unique like a GUID
Generated by anyone
Advantage: deterministic any node will generate the same
content hash for same resource data.
Disadvantages: like GUIDs they can’t be directly compared
for recentness, and they can be lengthy.
13. Collected by Dr. Dipali Meher
Source NoSQL Distilled
Ways of creating Version Stamps
Timestamp
To use the timestamp of the last update
Like counters, they are reasonably short and can be directly
compared for recentness.
Advantage: doesnot need a single master, Multiple machines can
generate timestamps( their clocks can be kep in synchronization
way)
Disadvantage :One node with a bad clock can cause all sorts of
data corruptions.
too granular you can get duplicates i.e. it’s no good using timestamps
of a millisecond precision if you get many updates per millisecond.
14. Collected by Dr. Dipali Meher
Source NoSQL Distilled
blend the advantages of these different version stamp
schemes by using more than one of them to create a
composite stamp example CouchDB uses a combination of
counter and content hash.
version stamps are also useful for providing
Session consistency