Skip to content

Commit

Permalink
yugabyte#1465 Fix EnumerateIntents and add a test to capture conflict…
Browse files Browse the repository at this point in the history
…s at hash key level in serializable isolation

Summary:
Fix EnumerateIntents to generate weak intents for all prefixes of a DocKey, starting with the hash part only, through every range key, and then through every subkey.
We only generate partial range key prefixes for YSQL, and don't generate them for YCQL. So for YCQL the only new weak intent generated would be the prefix consisting of the hash component.
This is needed e.g. for detecting a conflict between inserting a row and scanning all rows with a particular hash component that matches the inserted row at serializable isolation.
Also adding a test for this: testSerializableWholeHashVsScanConflict in TestPgTransactions.

Other fixes:
- Allow comparing DocKey values where one has a hash component and the other does not.
- Fix SubDocKey comparison in case two invalid DocHybridTimes are provided that have different write id values, and therefore would be considered unequal by DocHybridTime comparator functions. We could fix DocHybridTime comparison itself, but that raises the question of whether two invalid DocHybridTime values should be considered equal, like NULLs in a database.

Performance comparison to avoid performance regressions, using the CassandraTransactionalKeyValue sample app with the primary key with 50 subkeys:
https://gist.githubusercontent.com/mbautin/77b1ab98f43325f2a05d10d0e9c013bb/raw
There does not seem to be any significant performance difference on this workload with and without this patch.

Test Plan: Jenkins

Reviewers: mihnea, neil, neha, sergei

Reviewed By: sergei

Subscribers: yql

Differential Revision: https://phabricator.dev.yugabyte.com/D6759

Note:
This commit provides additional functionality that is logically related to
the earlier commit yugabyte@e0c2b61
and supersedes the commit yugabyte@24501a4
  • Loading branch information
mbautin committed Jul 16, 2019
1 parent 6700db4 commit 0b6ca31
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ent/src/yb/cdc/cdc_producer.cc
Expand Up @@ -250,7 +250,7 @@ Status CDCProducer::PopulateWriteRecord(const ReplicateMsgPtr& msg,
CDCRecordPB* record = nullptr;
for (const auto& write_pair : batch.write_pairs()) {
Slice key = write_pair.key();
const auto& key_sizes = VERIFY_RESULT(docdb::DocKey::EncodedSizes(key));
const auto& key_sizes = VERIFY_RESULT(docdb::DocKey::EncodedHashPartAndDocKeySizes(key));

Slice value = write_pair.value();
docdb::Value decoded_value;
Expand Down

0 comments on commit 0b6ca31

Please sign in to comment.