-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#16408] YSQL: add gflag TEST_generate_ybrowid_sequentially
Summary: Motivation: many ported regress tests have tables with no PK, and upstream PG often does SELECTs with no ORDER BY on these tables. Upstream PG's ordering is consistent in that rows allocate a ctid sequentially. YB, on the other hand, randomly generates a UUID for ybrowid, and furthermore, tables with no PK are HASH sorted. Fix those two differences via a new tserver gflag TEST_generate_ybrowid_sequentially. The ybrowids are generated using MonoTime::Now() serialized to 8 bytes compared to the usual 16 byte UUID. This works for regress tests as regress tests normally do not concurrently write to the same table or use connections across different nodes with clock skew. There is another unresolved difference between PG and YB's ctid/ybrowid allocation: in PG, UPDATEs reallocate ctid. Since doing the same would be very intrusive to the YB model of UPDATEs, leave this out. Most tests do not do selective UPDATEs anyway, and for the few cases that do, they can resort to using a ybsort column. Update a handful of tests, particularly changing those using the ybsort workaround to no longer use it. Of particular note is yb_pg_with, which still needs the ybsort column for some tables due to some UPDATEs. Ideally, all ported regress tests turn on this flag. But the current state of things makes it hard to separate ported tests from non-ported ones. Put that work off for later, particularly the pg15 branch, where this code is already in place in commit fedbdac. For here in master (currently based on PG 11), fix just the TestPgRegressIndex test using this flag. Split it to TestPgRegressIndex and TestPgRegressPgIndex for non-ported and ported tests respectively. For the ported test, set the flag. Also note that yb_pg_indexing's output changes for an error/hint message because the pk-less table now has ASC ybrowid instead of HASH ybrowid. This causes a new code path to get taken which ends up calling RelationGetIndexList: ATRewriteTables > make_new_heap > yb_copy_split_options > YbRelationSetNewRelfileNode > YbGetSplitOptions > RelationGetPrimaryKeyIndex > RelationGetIndexList So when entering FetchUniqueConstraintName for forming the message, it hits the else block because rd_pkindex is loaded since RelationIdGetRelation now finds the index in the scan unlike before. This is undesirable behavior since it differs from upstream PG, but dealing with it is out of scope. Jira: DB-5819 Test Plan: ./yb_build.sh fastdebug --gcc11 --java-test TestPgRegressIndex ./yb_build.sh fastdebug --gcc11 --java-test TestPgRegressPgIndex \ -n 10 --tp 1 Close: #16408 Reviewers: myang Reviewed By: myang Subscribers: tfoucher, yql Differential Revision: https://phorge.dev.yugabyte.com/D36599
- Loading branch information
Showing
13 changed files
with
89 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgRegressPgIndex.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) YugabyteDB, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
// in compliance with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed under the License | ||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// or implied. See the License for the specific language governing permissions and limitations | ||
// under the License. | ||
// | ||
package org.yb.pgsql; | ||
|
||
import java.util.Map; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.yb.util.YBTestRunnerNonTsanOnly; | ||
|
||
@RunWith(value=YBTestRunnerNonTsanOnly.class) | ||
public class TestPgRegressPgIndex extends BasePgRegressTest { | ||
@Override | ||
protected Map<String, String> getTServerFlags() { | ||
Map<String, String> flagMap = super.getTServerFlags(); | ||
flagMap.put("TEST_generate_ybrowid_sequentially", "true"); | ||
return flagMap; | ||
} | ||
|
||
@Test | ||
public void schedule() throws Exception { | ||
runPgRegressTest("yb_pg_index_schedule"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# src/test/regress/yb_index_schedule | ||
# This schedule is for non-ported tests only. | ||
test: yb_indexing_order | ||
test: yb_create_index | ||
test: yb_index_scan | ||
test: yb_reindex | ||
test: yb_secondary_index_scan | ||
|
||
test: yb_index_scan_null_create | ||
test: yb_index_scan_null_hash | ||
test: yb_index_scan_null_asc |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# src/test/regress/yb_pg_index_schedule | ||
# This schedule is for ported tests only. | ||
test: yb_pg_indexing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters