Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,68 @@
// under the License.
import java.sql.SQLException

suite("too_many_versions_detection") {
sql """ DROP TABLE IF EXISTS t """

sql """
create table t(a int)
DUPLICATE KEY(a)
DISTRIBUTED BY HASH(a)
BUCKETS 10 PROPERTIES("replication_num" = "1", "disable_auto_compaction" = "true");
"""

for (int i = 1; i <= 2000; i++) {
sql """ INSERT INTO t VALUES (${i}) """
suite("too_many_versions_detection", "nonConcurrent") {
def backendId_to_backendIP = [:]
def backendId_to_backendHttpPort = [:]
getBackendIpHttpPort(backendId_to_backendIP, backendId_to_backendHttpPort);

def set_be_config = { key, value ->
for (String backend_id: backendId_to_backendIP.keySet()) {
def (code, out, err) = update_be_config(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), key, value)
logger.info("update config: code=" + code + ", out=" + out + ", err=" + err)
}
}

try {
sql """ INSERT INTO t VALUES (2001) """
assertTrue(false, "Expected TOO_MANY_VERSION error but none occurred")
} catch (SQLException e) {
logger.info("Exception caught: ${e.getMessage()}")
def expectedError = "failed to init rowset builder. version count: 2001, exceed limit: 2000, tablet:"
assertTrue(e.getMessage().contains(expectedError),
"Expected TOO_MANY_VERSION error with message containing '${expectedError}', but got: ${e.getMessage()}")
def get_be_param = { paramName ->
def paramValue = ""
for (String id in backendId_to_backendIP.keySet()) {
def beIp = backendId_to_backendIP.get(id)
def bePort = backendId_to_backendHttpPort.get(id)
def (code, out, err) = curl("GET", String.format("http://%s:%s/api/show_config?conf_item=%s", beIp, bePort, paramName))
logger.info("get config: code=" + code + ", out=" + out + ", err=" + err)
assertTrue(code == 0)
assertTrue(out.contains(paramName))
def resultList = parseJson(out)[0]
assertTrue(resultList.size() == 4)
paramValue = resultList[2]
break // only need to get from one BE
}
return paramValue
}

sql """ DROP TABLE IF EXISTS t """
// Read and save original config value
def originalMaxTabletVersionNum = get_be_param("max_tablet_version_num")
logger.info("Original max_tablet_version_num: ${originalMaxTabletVersionNum}")

try {
set_be_config("max_tablet_version_num", "200")

sql """ DROP TABLE IF EXISTS t """

sql """
create table t(a int)
DUPLICATE KEY(a)
DISTRIBUTED BY HASH(a)
BUCKETS 10 PROPERTIES("replication_num" = "1", "disable_auto_compaction" = "true");
"""

for (int i = 1; i <= 200; i++) {
sql """ INSERT INTO t VALUES (${i}) """
}

try {
sql """ INSERT INTO t VALUES (201) """
assertTrue(false, "Expected TOO_MANY_VERSION error but none occurred")
} catch (SQLException e) {
logger.info("Exception caught: ${e.getMessage()}")
def expectedError = "failed to init rowset builder. version count: 201, exceed limit: 200, tablet:"
assertTrue(e.getMessage().contains(expectedError),
"Expected TOO_MANY_VERSION error with message containing '${expectedError}', but got: ${e.getMessage()}")
}

sql """ DROP TABLE IF EXISTS t """
} finally {
// Restore original config
set_be_config("max_tablet_version_num", originalMaxTabletVersionNum)
}
}
Loading