CheckAndMutate uses timestamps inconsistently
See original GitHub issueSteps to reproduce
@Test
void testCantReadMyOwnWrites() throws IOException {
Table table = // TODO
byte[] row = Bytes.toBytes(System.currentTimeMillis());
byte[] q = Bytes.toBytes("q");
byte[] f = Bytes.toBytes("f");
byte[] A = Bytes.toBytes("aaa");
byte[] B = Bytes.toBytes("bbb");
boolean success = table
.checkAndMutate(row, f).qualifier(q).ifNotExists()
.thenPut(new Put(row).addColumn(f, q, A));
assertThat(success).isTrue();
table.put(new Put(row).addColumn(f, q, B));
byte[] value = table.get(new Get(row)).getValue(f, q);
assertThat(value).isEqualTo(B); // 👈 this fails
}
This (generally) works when setting a breakpoint on table.put(new Put(row).addColumn(f, q, B)); - i.e. slowing down the operation with the breakpoint seems to “fix” it.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
CheckAndMutate methods should not set client-side timestamps
If a user doesn't set timestamps, Put operations get client-side timestamps. ... CheckAndMutate uses timestamps inconsistently #2898.
Read more >Issues Fixed in CDH 5.3.x | 5.x - Cloudera Documentation
If the connection with ZooKeeper is inconsistent, the ReplicationCleaner may abort, and the following event is logged by the HMaster:
Read more >The HBase CheckAndMutate is atomic is it also consistent?
Let's say I have: a cell with value 5. 2 workers simultaneously want to change the value of the cell (using checkAndMutate )...
Read more >Ensuring transactional consistency with DDD
We use Entity Framework and EF6 uses read_commited_snapshot by default, so two consecutive reads from repository can give us inconsistent ...
Read more >The Definitive Guide, 2nd Edition HBase Guide Second Early ...
The architecture used underneath is well researched and has not changed ... the time where the cache and the database views are inconsistent...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@kolea2 excellent feedback, thank you for the additional testing!
Hi @aditanase - the Put call in HBase without a timestamp passed in will use the existing timestamp, see https://github.com/apache/hbase/blob/master/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java#L179, so I do not believe that will not work as is, as the existing timestamp will end up being the server side timestamp. I believe calling setTimestamp first will work. Here’s what I tried:
Example using setTimestamp last with custom timestamp:
Output (via cbt tool). Custom timestamp ignored:
Example using custom timestamp first:
Output:
Hope that helps!