VCNC / haeinsa

Haeinsa is linearly scalable multi-row, multi-table transaction library for HBase
Apache License 2.0
158 stars 42 forks source link

2 Different clients (2 different machines ) with different clock! #43

Closed ehudl closed 9 years ago

ehudl commented 9 years ago

Hello, We are running 2 different clients (on different machines) that have difference in their System.currentmillis. Does this may cause problems in the correctness of the transactions?

Also, without using your API, it caused us the following problem: When client A gets an update on item X, he calls Put(row, ts). The ts is taken from the client's machine local timestamp (synced by NTP). Lets assume it was ts = 3. Now client B (on different machine) gets after 1ms an update on the same item. The ts here is 2 (on client A machine the ts is now 4).

Both updates succeeded. If I will call get, I will get the first update instead of the second one. The reason is that the second update is with younger ts (due to miss time syncronization between machine). The solution was not to set the ts on clients machine and let the region server to set it.

I am concerned we will have the same problem with your library.

What do you think?

Ehud

eincs commented 9 years ago

If you use Haeinsa, there can't be problem like that.

Haeinsa uses commit timestamp of the transaction when executing `HaeinsaPut. (See HaeinsaTable.java#L510)

But, in Haeinsa, commit timestamp is determined by Math.max(System.currentTimeMillis(), rowLock.commitTImestamp()). (See HaeinsaTransaction.java#L210-L232) This means Haeinsa ensures that using bigger timestamp than previous operation when writing data. So, problem that you worry about never happens.

ehudl commented 9 years ago

Thanks you very much.