This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.2
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.2 by this push:
new eeaa0d9051e branch-4.2: [test](jdbc) Verify schema reload after
catalog refresh (#71276)
eeaa0d9051e is described below
commit eeaa0d9051e05914bf9cd67bf0329ffe285e520b
Author: Socrates <[email protected]>
AuthorDate: Fri Dec 4 10:10:45 2026 +0800
branch-4.2: [test](jdbc) Verify schema reload after catalog refresh (#71276)
### What problem does this PR solve?
Issue Number: None
Related PR: #64705
Problem Summary:
The JDBC manual miss-load regression assumed that disabling the
configuration made catalog refresh block for at least eight seconds.
Whether a refresh traverses a contended Caffeine hash bin depends on
the cache implementation and timing.
Verify the JDBC behavior directly with manual miss loading enabled.
After a schema change in MySQL, the cached schema remains visible until
REFRESH CATALOG. Refresh clears the cache and the next DESCRIBE loads
the
new schema. MetaCacheEntryTest retains deterministic latch-based
coverage
of invalidation racing an in-flight load, including catalog-wide
invalidation.
The branch-4.2 regression framework and FE compiled on Fedora.
An isolated run using the branch-4.2 FE and MySQL 5.7.44 verified that
DESCRIBE returns the old schema before REFRESH CATALOG and the new
schema afterward. The schema cache size changed from 1 to 0 to 1.
The local run used MySQL Connector/J 8.4.0 from Maven Central and read
statistics directly from the FE RPC. The available master BE requests
the EVICTION_RATE column, which the 4.2 FE does not expose. The exact
suite still needs to run with matching branch-4.2 FE and BE.
### Release note
None
### Check List (For Author)
- Test
- [x] Manual test. Groovy parsing, a mocked suite control-flow check,
and git diff --check passed.
- Behavior changed:
- [x] No.
- Does this need documentation?
- [x] No.
### AI Disclosure
- Tool: OpenAI Codex (GPT-6)
- Generated: regression test and PR description
- Human review: Not yet performed.
---
...st_jdbc_refresh_catalog_manual_miss_load.groovy | 197 +++------------------
1 file changed, 20 insertions(+), 177 deletions(-)
diff --git
a/regression-test/suites/external_table_p0/jdbc/test_jdbc_refresh_catalog_manual_miss_load.groovy
b/regression-test/suites/external_table_p0/jdbc/test_jdbc_refresh_catalog_manual_miss_load.groovy
index 916dce15ea4..03f51318327 100644
---
a/regression-test/suites/external_table_p0/jdbc/test_jdbc_refresh_catalog_manual_miss_load.groovy
+++
b/regression-test/suites/external_table_p0/jdbc/test_jdbc_refresh_catalog_manual_miss_load.groovy
@@ -15,13 +15,8 @@
// specific language governing permissions and limitations
// under the License.
-import java.util.UUID
-
-// This case depends on JDBC regression configs, FE debug points, and a
reachable
-// external MySQL environment. Those prerequisites may be unavailable in the
-// default Apache Doris CI pipeline, so the case can be skipped or may not run
-// end-to-end there. That is expected. The case still serves as a valuable
-// reference for manual validation of the MetaCacheEntry refresh blocking fix.
+// MetaCacheEntryTest covers in-flight load invalidation with latches.
Exercise the JDBC
+// cache contract here without relying on contention in a particular Caffeine
hash bin.
suite("test_jdbc_refresh_catalog_manual_miss_load",
"p0,external,nonConcurrent") {
String enabled = context.config.otherConfigs.get("enableJdbcTest")
if (enabled == null || !enabled.equalsIgnoreCase("true")) {
@@ -30,87 +25,13 @@ suite("test_jdbc_refresh_catalog_manual_miss_load",
"p0,external,nonConcurrent")
String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
String mysqlPort = context.config.otherConfigs.get("mysql_57_port")
- String s3Endpoint = getS3Endpoint()
- String bucket = getS3BucketName()
- String driverUrl =
"https://${bucket}.${s3Endpoint}/regression/jdbc_driver/mysql-connector-j-8.4.0.jar"
+ String driverUrl =
"https://${getS3BucketName()}.${getS3Endpoint()}/regression/jdbc_driver/mysql-connector-j-8.4.0.jar"
String nameSuffix = UUID.randomUUID().toString().replace("-", "")
String catalogName = "jdbc_manual_miss_load_" + nameSuffix
String remoteDbName = "jdbc_manual_miss_load_db_" +
nameSuffix.substring(0, 12)
- String slowTableName = "slow_probe_000000"
- int collisionTableCount = 80
- int hashMod = 512
- int slowSleepMs = 15000
- int refreshDelayMs = 5000
- String schemaSleepDebugPoint = "JdbcExternalTable.initSchema.sleep"
-
- def mysqlJdbcUrl = "jdbc:mysql://${externalEnvIp}:${mysqlPort}"
- def configRows = sql """ADMIN SHOW FRONTEND CONFIG LIKE
'enable_external_meta_cache_manual_miss_load';"""
+ String mysqlJdbcUrl = "jdbc:mysql://${externalEnvIp}:${mysqlPort}"
+ def configRows = sql """ADMIN SHOW FRONTEND CONFIG LIKE
'enable_external_meta_cache_manual_miss_load'"""
String originalManualMissLoadValue = configRows[0][1].toString()
- def debugPointRows = sql """ADMIN SHOW FRONTEND CONFIG LIKE
'enable_debug_points';"""
- // Skip the case when FE debug points are not enabled in the regression
environment.
- if (!"true".equalsIgnoreCase(debugPointRows[0][1].toString())) {
- logger.info("skip ${catalogName} because enable_debug_points is not
true")
- return
- }
-
- def jint = { long value ->
- long result = value & 0xffffffffL
- if (result >= 0x80000000L) {
- result -= 0x100000000L
- }
- return (int) result
- }
-
- def javaStringHash = { String value ->
- int hash = 0
- for (int i = 0; i < value.length(); i++) {
- hash = jint(31L * hash + (int) value.charAt(i))
- }
- return hash
- }
-
- def javaLongHash = { long value ->
- return jint(value ^ (value >>> 32))
- }
-
- def objectsHash = { List<Object> values ->
- int hash = 1
- values.each { value ->
- int elementHash
- if (value instanceof Number) {
- elementHash = javaLongHash(((Number) value).longValue())
- } else {
- elementHash = javaStringHash(value.toString())
- }
- hash = jint(31L * hash + elementHash)
- }
- return hash
- }
-
- def spread = { int hash ->
- return jint(hash ^ (((long) hash & 0xffffffffL) >>> 16))
- }
-
- // Compute collision table names that land in the same Caffeine hash bin
as the slow key.
- def findCollisionTableNames = { long catalogId ->
- def calcIndex = { String tableName ->
- int hash = objectsHash([catalogId, remoteDbName, tableName,
remoteDbName, tableName])
- return spread(hash) & (hashMod - 1)
- }
- int targetIndex = calcIndex(slowTableName)
- def tableNames = []
- for (int i = 0; i < 300000; i++) {
- String candidate = String.format("collide_%06d", i)
- if (calcIndex(candidate) == targetIndex) {
- tableNames.add(candidate)
- if (tableNames.size() >= collisionTableCount) {
- break
- }
- }
- }
- assertEquals(collisionTableCount, tableNames.size())
- return tableNames
- }
def executeOnRemoteMysql = { String statement ->
connect("root", "123456", mysqlJdbcUrl) {
@@ -118,87 +39,19 @@ suite("test_jdbc_refresh_catalog_manual_miss_load",
"p0,external,nonConcurrent")
}
}
- // Recreate the remote schema so every run starts from the same cache and
metadata state.
- def recreateRemoteObjects = { List<String> collisionTableNames ->
- executeOnRemoteMysql("""DROP DATABASE IF EXISTS ${remoteDbName}""")
- executeOnRemoteMysql("""CREATE DATABASE ${remoteDbName}""")
- executeOnRemoteMysql("""CREATE TABLE ${remoteDbName}.${slowTableName}
(k INT)""")
- collisionTableNames.each { tableName ->
- executeOnRemoteMysql("""CREATE TABLE ${remoteDbName}.${tableName}
(k INT)""")
- }
- }
-
- // Read the current schema cache size for this catalog from
information_schema.
def getSchemaCacheSize = {
def statRows = sql """
- SELECT ESTIMATED_SIZE
- FROM information_schema.catalog_meta_cache_statistics
- WHERE CATALOG_NAME = '${catalogName}'
- AND ENTRY_NAME = 'schema'
- """
+ SELECT ESTIMATED_SIZE
+ FROM information_schema.catalog_meta_cache_statistics
+ WHERE CATALOG_NAME = '${catalogName}' AND ENTRY_NAME = 'schema'
+ """
return ((Number) statRows[0][0]).intValue()
}
- def preheatSchemaCache = { List<String> collisionTableNames ->
- sql """REFRESH CATALOG ${catalogName}"""
- collisionTableNames.each { tableName ->
- sql """DESC ${catalogName}.${remoteDbName}.${tableName}"""
- }
- assertEquals(collisionTableCount, getSchemaCacheSize())
- }
-
- // Run the blocking reproduction once and assert the refresh latency
profile.
- def runRefreshRace = { boolean manualMissLoadEnabled, long minRefreshMs,
long maxRefreshMs ->
- sql """ADMIN SET FRONTEND CONFIG
('enable_external_meta_cache_manual_miss_load' = '${manualMissLoadEnabled}')"""
- try {
- GetDebugPoint().enableDebugPointForAllFEs(
- schemaSleepDebugPoint,
- ["sleepMs": String.valueOf(slowSleepMs)])
-
- def descElapsedMs = -1L
- def descFailure = null
- def descThread = Thread.start {
- try {
- long descStart = System.currentTimeMillis()
- connect(context.config.jdbcUser,
context.config.jdbcPassword, context.config.jdbcUrl) {
- sql """DESC
${catalogName}.${remoteDbName}.${slowTableName}"""
- }
- descElapsedMs = System.currentTimeMillis() - descStart
- } catch (Throwable t) {
- descFailure = t
- }
- }
-
- // Delay the refresh long enough so the DESC path can enter the
injected slow schema load.
- Thread.sleep(refreshDelayMs)
-
- long refreshStart = System.currentTimeMillis()
- sql """REFRESH CATALOG ${catalogName}"""
- long refreshElapsedMs = System.currentTimeMillis() - refreshStart
-
- descThread.join(slowSleepMs + 15000)
- if (descThread.isAlive()) {
- throw new IllegalStateException("desc thread does not finish
in time")
- }
- if (descFailure != null) {
- throw new IllegalStateException("desc thread failed",
descFailure)
- }
-
- logger.info("manualMissLoadEnabled=${manualMissLoadEnabled},
refreshElapsedMs=${refreshElapsedMs}, descElapsedMs=${descElapsedMs}")
- assertTrue(descElapsedMs >= slowSleepMs - 1000)
- assertTrue(refreshElapsedMs >= minRefreshMs)
- assertTrue(refreshElapsedMs <= maxRefreshMs)
- assertTrue(refreshElapsedMs < descElapsedMs)
- return [refreshElapsedMs, descElapsedMs]
- } finally {
- GetDebugPoint().disableDebugPointForAllFEs(schemaSleepDebugPoint)
- }
- }
-
try {
- executeOnRemoteMysql("""DROP DATABASE IF EXISTS ${remoteDbName}""")
+ sql """ADMIN SET FRONTEND CONFIG
('enable_external_meta_cache_manual_miss_load' = 'true')"""
executeOnRemoteMysql("""CREATE DATABASE ${remoteDbName}""")
- sql """DROP CATALOG IF EXISTS ${catalogName}"""
+ executeOnRemoteMysql("""CREATE TABLE ${remoteDbName}.refresh_probe (k
INT)""")
sql """CREATE CATALOG ${catalogName} PROPERTIES(
"type" = "jdbc",
"user" = "root",
@@ -210,35 +63,25 @@ suite("test_jdbc_refresh_catalog_manual_miss_load",
"p0,external,nonConcurrent")
"include_database_list" = "${remoteDbName}"
)"""
- def catalogRows = sql """SHOW CATALOGS LIKE '${catalogName}'"""
- long catalogId = ((Number) catalogRows[0][0]).longValue()
- def collisionTableNames = findCollisionTableNames(catalogId)
-
- recreateRemoteObjects(collisionTableNames)
- preheatSchemaCache(collisionTableNames)
- def blockedResult = runRefreshRace(false, 8000L, slowSleepMs + 5000L)
+ def initialSchema = sql """DESC
${catalogName}.${remoteDbName}.refresh_probe"""
+ assertEquals(1, getSchemaCacheSize())
- recreateRemoteObjects(collisionTableNames)
- preheatSchemaCache(collisionTableNames)
- def manualLoadResult = runRefreshRace(true, 0L, 5000L)
+ executeOnRemoteMysql("""ALTER TABLE ${remoteDbName}.refresh_probe ADD
COLUMN refreshed_value INT""")
+ assertEquals(initialSchema, sql("""DESC
${catalogName}.${remoteDbName}.refresh_probe"""))
- // Verify the invalidated slow load did not write back the stale key
into schema cache.
+ sql """REFRESH CATALOG ${catalogName}"""
assertEquals(0, getSchemaCacheSize())
- sql """DESC ${catalogName}.${remoteDbName}.${slowTableName}"""
+
+ def refreshedSchema = sql """DESC
${catalogName}.${remoteDbName}.refresh_probe"""
+ assertTrue(refreshedSchema.any { it[0] == "refreshed_value" })
assertEquals(1, getSchemaCacheSize())
- assertTrue(((Number) blockedResult[0]).longValue() > ((Number)
manualLoadResult[0]).longValue() + 5000L)
} finally {
try_sql("""ADMIN SET FRONTEND CONFIG
('enable_external_meta_cache_manual_miss_load' =
'${originalManualMissLoadValue}')""")
- try {
- GetDebugPoint().disableDebugPointForAllFEs(schemaSleepDebugPoint)
- } catch (Throwable t) {
- logger.warn("failed to disable debug point during cleanup", t)
- }
try_sql("""DROP CATALOG IF EXISTS ${catalogName}""")
try {
executeOnRemoteMysql("""DROP DATABASE IF EXISTS ${remoteDbName}""")
} catch (Throwable t) {
- logger.warn("failed to drop remote database during cleanup", t)
+ logger.warn("failed to drop remote test database during cleanup",
t)
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]