Skip to content

Commit e7803ce

Browse files
authored
[fix](regression) wait for version headroom before schema change (#65373)
Related PR: #65233 Problem Summary: `test_schema_change_with_empty_rowset` needs cumulative compaction to leave enough version headroom before starting schema change and 20 additional inserts. Waiting on generic cumulative run/status metadata can return before that case-specific postcondition is true. Trigger cumulative compaction for every tablet, then poll `SHOW TABLETS` until every `VersionCount` is below the calculated safe threshold. This directly verifies the condition required by the remainder of the case and leaves the shared compaction helper and BE product code unchanged.
1 parent 35f9812 commit e7803ce

1 file changed

Lines changed: 41 additions & 3 deletions

File tree

‎regression-test/suites/schema_change_p0/test_schema_change_with_empty_rowset.groovy‎

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,42 @@ suite("test_schema_change_with_empty_rowset", "p0,nonConcurrent") {
3131
return jobStateResult[0][9]
3232
}
3333

34+
def backendIdToHost = [:]
35+
def backendIdToHttpPort = [:]
36+
getBackendIpHttpPort(backendIdToHost, backendIdToHttpPort)
37+
38+
def triggerCumulativeAndWaitForVersionCount = { tbl, int targetVersionCount ->
39+
def tablets = sql_return_maparray """ SHOW TABLETS FROM ${tbl} """
40+
for (def tablet in tablets) {
41+
def host = backendIdToHost["${tablet.BackendId}"]
42+
def port = backendIdToHttpPort["${tablet.BackendId}"]
43+
def (code, out, err) = be_run_cumulative_compaction(host, port, tablet.TabletId)
44+
assert code == 0: "trigger cumulative compaction failed, tablet=${tablet.TabletId}, " +
45+
"code=${code}, stdout=${out}, stderr=${err}"
46+
def triggerStatus = parseJson(out.trim())
47+
assert triggerStatus.status?.equalsIgnoreCase("Success"):
48+
"trigger cumulative compaction failed, tablet=${tablet.TabletId}, stdout=${out}"
49+
}
50+
51+
// The rowsets returned by the BE are the active versions used by its load admission check.
52+
Awaitility.await().atMost(300, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until {
53+
def versionCounts = [:]
54+
for (def tablet in tablets) {
55+
def host = backendIdToHost["${tablet.BackendId}"]
56+
def port = backendIdToHttpPort["${tablet.BackendId}"]
57+
def (code, out, err) = be_show_tablet_status(host, port, tablet.TabletId)
58+
assert code == 0: "get compaction status failed, tablet=${tablet.TabletId}, " +
59+
"code=${code}, stdout=${out}, stderr=${err}"
60+
def tabletStatus = parseJson(out.trim())
61+
assert tabletStatus.rowsets instanceof List:
62+
"invalid compaction status, tablet=${tablet.TabletId}, stdout=${out}"
63+
versionCounts[tablet.TabletId] = tabletStatus.rowsets.size()
64+
}
65+
logger.info("waiting for ${tbl} BE version count <= ${targetVersionCount}, current=${versionCounts}")
66+
return versionCounts.values().every { it <= targetVersionCount }
67+
}
68+
}
69+
3470
sql """ DROP TABLE IF EXISTS ${tableName} """
3571

3672
sql """
@@ -64,12 +100,14 @@ suite("test_schema_change_with_empty_rowset", "p0,nonConcurrent") {
64100
}
65101

66102

67-
// trigger compactions for all tablets in ${tableName}
68-
trigger_and_wait_compaction(tableName, "cumulative")
103+
// Leave enough version headroom for the schema change and the following inserts.
104+
int insertCountAfterCompaction = 20
105+
int targetVersionCount = custoBeConfig.max_tablet_version_num - insertCountAfterCompaction - 1
106+
triggerCumulativeAndWaitForVersionCount(tableName, targetVersionCount)
69107

70108
sql """ alter table ${tableName} modify column k4 string NULL"""
71109

72-
for (int i = 100; i < 120; i++) {
110+
for (int i = 100; i < 100 + insertCountAfterCompaction; i++) {
73111
sql """ insert into ${tableName} values ($i, 2, 3, 4, 5, 6.6, 1.7, 8.8,
74112
'a', 'b', 'c', '2021-10-30', '2021-10-30 00:00:00') """
75113
sleep(20)

0 commit comments

Comments
 (0)