Skip to content

Commit

Permalink
[BACKPORT 2.14][#12327] YSQL: Workaround for FK constraint violation …
Browse files Browse the repository at this point in the history
…in case of dynamic table split

Summary:
Original commit: D17142 / 17f7b80

In context of the change D16751 / 4e11189 redundant sorting of ybctids (before calling of the `PgDocOp::PopulateDmlByYbctidOps` method) was removed. But this change highlighted the problem that in case ybctids is not sorted read result might be incomplete in case of dynamic table split. The issue #12648 is created to solve the problem and create unit tests.
Current change restores code with ybctids sorting as a workaround to unblock TPC-C benchmark.

Test Plan:
Jenkins

Unit test will be added withing the context of fix for #12648

Reviewers: dmitry, hbhanawat, rthallam

Reviewed By: rthallam

Subscribers: yql, smishra

Differential Revision: https://phabricator.dev.yugabyte.com/D17251
  • Loading branch information
d-uspenskiy authored and lnguyen-yugabyte committed May 28, 2022
1 parent acc2e7b commit 3d8e055
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/yb/yql/pggate/pggate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,13 @@ Status FetchExistingYbctids(PgSession::ScopedRefPtr session,
uint64_t read_time) {
// Group the items by the table ID.
std::sort(ybctids->begin(), ybctids->end(), [](const auto& a, const auto& b) {
// TODO(dmitry): By design it is only necessary to group ybctids by table, sorting of ybctids
// itself is not required. But due to problem described in #12648 unsorted ybctids may produce
// incomplete result. Remove ybctid comparision once #12648 is fixed.
if (a.table_id != b.table_id) {
return a.table_id < b.table_id;
}
return a.ybctid < b.ybctid;
});

auto arena = std::make_shared<Arena>();
Expand Down

0 comments on commit 3d8e055

Please sign in to comment.