Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#17688] DocDB: Do not make redundant intentsdb seeks in conflict res…
…olution Summary: This commit addresses an inefficiency in the conflict resolution logic for single-shard operations. Previously, in conflict resolution, YugabyteDB performed redundant seeks in the IntentsDB for non-transactional single shard operations. YugabyteDB would perform redundant lookups of the relation, hash, and range components of the full primary doc key multiple times. This commit optimizes the logic to ensure lookups for the ancestral columns will only occur once. Consider an insert to table C: ```sql CREATE TABLE t(k1 int, k2 int, r1 int, r2 int, v1 int, v2 int, PRIMARY KEY((k1, k2) HASH, r1, r2)); INSERT INTO t VALUES(1,1,1,1,1,1); ``` Prior to this patch, there would be four redundant seeks for the ancestral keys: ``` I0605 11:48:21.675853 465439 conflict_resolution.cc:1257] ResolveOperationConflicts: conflict_management_policy=2, initial_resolution_ht: { days: 19513 time: 11:48:21.675843 } I0605 11:48:21.675994 465439 conflict_resolution.cc:1152] Operation Context: ReadConflicts: Doc path: SubDocKey(DocKey(0x97c0, [1, 1], [1, 1]), [ColumnId(14)]) I0605 11:48:21.676195 465439 conflict_resolution.cc:201] Operation Context: ReadIntentConflicts: Check conflicts in intents DB; Seek: 210D04 for type [kWeakRead, kWeakWrite] I0605 11:48:21.676232 465439 conflict_resolution.cc:201] Operation Context: ReadIntentConflicts: Check conflicts in intents DB; Seek: 4797C04880000001488000000121210D04 for type [kWeakRead, kWeakWrite] I0605 11:48:21.676249 465439 conflict_resolution.cc:201] Operation Context: ReadIntentConflicts: Check conflicts in intents DB; Seek: 4797C048800000014880000001214880000001210D04 for type [kWeakRead, kWeakWrite] I0605 11:48:21.676263 465439 conflict_resolution.cc:201] Operation Context: ReadIntentConflicts: Check conflicts in intents DB; Seek: 4797C0488000000148800000012148800000014880000001210D04 for type [kWeakRead, kWeakWrite] I0605 11:48:21.676280 465439 conflict_resolution.cc:201] Operation Context: ReadIntentConflicts: Check conflicts in intents DB; Seek: 4797C0488000000148800000012148800000014880000001214B8E0D for type [kStrongRead, kStrongWrite] I0605 11:48:21.676293 465439 conflict_resolution.cc:1152] Operation Context: ReadConflicts: Doc path: SubDocKey(DocKey(0x97c0, [1, 1], [1, 1]), [ColumnId(15)]) I0605 11:48:21.676316 465439 conflict_resolution.cc:201] Operation Context: ReadIntentConflicts: Check conflicts in intents DB; Seek: 210D04 for type [kWeakRead, kWeakWrite] I0605 11:48:21.676330 465439 conflict_resolution.cc:201] Operation Context: ReadIntentConflicts: Check conflicts in intents DB; Seek: 4797C04880000001488000000121210D04 for type [kWeakRead, kWeakWrite] I0605 11:48:21.676344 465439 conflict_resolution.cc:201] Operation Context: ReadIntentConflicts: Check conflicts in intents DB; Seek: 4797C048800000014880000001214880000001210D04 for type [kWeakRead, kWeakWrite] I0605 11:48:21.676357 465439 conflict_resolution.cc:201] Operation Context: ReadIntentConflicts: Check conflicts in intents DB; Seek: 4797C0488000000148800000012148800000014880000001210D04 for type [kWeakRead, kWeakWrite] I0605 11:48:21.676373 465439 conflict_resolution.cc:201] Operation Context: ReadIntentConflicts: Check conflicts in intents DB; Seek: 4797C0488000000148800000012148800000014880000001214B8F0D for type [kStrongRead, kStrongWrite] I0605 11:48:21.676388 465439 conflict_resolution.cc:310] Operation Context: Conflicts: [] ``` ``` localhost:9000 tablet 77c80b63456d4796a23adeba6e7ffff0 yugabyte.t intentsdb_rocksdb_number_db_seek 10 ``` After this patch, lookups for the ancestral columns will only occur once. ``` I0605 11:44:16.212149 457368 conflict_resolution.cc:1263] ResolveOperationConflicts: conflict_management_policy=2, initial_resolution_ht: { days: 19513 time: 11:44:16.212133 } I0605 11:44:16.212280 457368 conflict_resolution.cc:1142] Operation Context: ReadConflicts: Doc path: SubDocKey(DocKey(0x97c0, [1, 1], [1, 1]), [ColumnId(14)]) I0605 11:44:16.212467 457368 conflict_resolution.cc:1142] Operation Context: ReadConflicts: Doc path: SubDocKey(DocKey(0x97c0, [1, 1], [1, 1]), [ColumnId(15)]) I0605 11:44:16.212563 457368 conflict_resolution.cc:201] Operation Context: ReadIntentConflicts: Check conflicts in intents DB; Seek: 210D04 for type [kWeakRead, kWeakWrite] I0605 11:44:16.212592 457368 conflict_resolution.cc:201] Operation Context: ReadIntentConflicts: Check conflicts in intents DB; Seek: 4797C04880000001488000000121210D04 for type [kWeakRead, kWeakWrite] I0605 11:44:16.212607 457368 conflict_resolution.cc:201] Operation Context: ReadIntentConflicts: Check conflicts in intents DB; Seek: 4797C048800000014880000001214880000001210D04 for type [kWeakRead, kWeakWrite] I0605 11:44:16.212620 457368 conflict_resolution.cc:201] Operation Context: ReadIntentConflicts: Check conflicts in intents DB; Seek: 4797C0488000000148800000012148800000014880000001210D04 for type [kWeakRead, kWeakWrite] I0605 11:44:16.212635 457368 conflict_resolution.cc:201] Operation Context: ReadIntentConflicts: Check conflicts in intents DB; Seek: 4797C0488000000148800000012148800000014880000001214B8E0D for type [kStrongRead, kStrongWrite] I0605 11:44:16.212649 457368 conflict_resolution.cc:201] Operation Context: ReadIntentConflicts: Check conflicts in intents DB; Seek: 4797C0488000000148800000012148800000014880000001214B8F0D for type [kStrongRead, kStrongWrite] I0605 11:44:16.212667 457368 conflict_resolution.cc:310] Operation Context: Conflicts: [] I0605 11:44:16.226545 457210 tablet.cc:1512] T e6bc3150021840938ebcb0ee4606bae1 P db14a0242bb ``` ``` localhost:9000 tablet 77c80b63456d4796a23adeba6e7ffff0 yugabyte.t intentsdb_rocksdb_number_db_seek 6 ``` Jira: DB-6796 Test Plan: ./yb_build.sh --java-test org.yb.pgsql.TestPgFastpathIntentdbSeeks I ran featurebench update_1000_cols with a concurrent transaction to the table, and I see roughly ~10% increase in throughput. featurebench update_1000_cols on master: ``` { "scalefactor": null, "Current Timestamp (milliseconds)": 1687283416124, "Benchmark Type": "featurebench", "isolation": "TRANSACTION_REPEATABLE_READ", "DBMS Version": "PostgreSQL 11.2-YB-2.19.1.0-b0 on x86_64-pc-linux-gnu, compiled by clang version 15.0.7 (https://github.com/yugabyte/llvm-project.git 6b9d30d80f5cebc66c9fa46013d18f125ea8ec0e), 64-bit", "Goodput (requests/second)": 128.31150986042474, "terminals": "1", "DBMS Type": "YUGABYTE", "Latency Distribution": { "95th Percentile Latency (microseconds)": 11829, "Maximum Latency (microseconds)": 1252227, "Median Latency (microseconds)": 10970, "Minimum Latency (microseconds)": 10042, "25th Percentile Latency (microseconds)": 10791, "90th Percentile Latency (microseconds)": 11499, "99th Percentile Latency (microseconds)": 14679, "75th Percentile Latency (microseconds)": 11178, "Average Latency (microseconds)": 11429 }, "Throughput (requests/second)": 87.4426464284535 } ``` featurebench update_1000_cols on D25987: ``` { "scalefactor": null, "Current Timestamp (milliseconds)": 1687293443889, "Benchmark Type": "featurebench", "isolation": "TRANSACTION_REPEATABLE_READ", "DBMS Version": "PostgreSQL 11.2-YB-2.19.1.0-b0 on x86_64-pc-linux-gnu, compiled by clang version 15.0.7 (/opt/yb-build/llvm/yb-llvm-v15.0.7-yb-1-1680596282-6b9d30d8-centos7-x86_64-build/src/llvm-project/clang 6b9d30d80f5cebc66c9fa46013d18f125ea8ec0e), 64-bit", "Goodput (requests/second)": 147.1163357113059, "terminals": "1", "DBMS Type": "YUGABYTE", "Latency Distribution": { "95th Percentile Latency (microseconds)": 11012, "Maximum Latency (microseconds)": 1186189, "Median Latency (microseconds)": 10094, "Minimum Latency (microseconds)": 8627, "25th Percentile Latency (microseconds)": 9549, "90th Percentile Latency (microseconds)": 10822, "99th Percentile Latency (microseconds)": 11578, "75th Percentile Latency (microseconds)": 10478, "Average Latency (microseconds)": 10344 }, "Throughput (requests/second)": 96.61644931669201 } ``` Reviewers: pjain, sergei, rsami Reviewed By: pjain, sergei Subscribers: dmitry, rsami, rthallam, qhu, smishra, bogdan, ybase Differential Revision: https://phorge.dev.yugabyte.com/D25987
- Loading branch information