Repository navigation
Use per-thread JDBC connections in AINode concurrent forecast IT - #19360
JackieTien97 wants to merge 2 commits into
Conversation
JackieTien97
left a comment
There was a problem hiding this comment.
Giving each worker its own JDBC connection and statement addresses the shared ResultSet failure. The inline findings cover worker shutdown, the test’s effective concurrency, cleanup of a queued model load, and failure reporting. I recommend addressing them before merging.
| if (remainingNanos > 0) { | ||
| thread.join(Math.max(1L, TimeUnit.NANOSECONDS.toMillis(remainingNanos))); | ||
| } | ||
| if (thread.isAlive()) { | ||
| fail("Thread timeout after 10 minutes"); | ||
| for (Thread activeThread : threads) { | ||
| activeThread.interrupt(); | ||
| } |
There was a problem hiding this comment.
[P2] Wait for the inference workers before unloading the model. An interrupt of the test thread escapes join() without signalling the workers. On the deadline path, the test interrupts them and immediately calls fail(). Either path lets the caller run UNLOAD MODEL while workers are still using the model. With the PR’s scheduling code and a simulated JDBC backend, all 10 workers survived an interrupted join and issued 90 more queries after the caller received InterruptedException. Please stop new iterations on cancellation, bound in-flight JDBC calls, and wait for the workers to exit before starting model cleanup.
| try { | ||
| // JDBC Statements cannot be shared concurrently because executing a new query | ||
| // closes any previously open ResultSet on that Statement. | ||
| try (Connection connection = EnvFactory.getEnv().getConnection(sqlDialect); |
There was a problem hiding this comment.
[P2] Exercise all ten concurrent forecast requests. In AIEnv, this overload creates a ClusterTestConnection even when AIClusterIT sets ReadAndVerifyWithMultiNode=false. It routes the underlying executeQuery calls through the five threads in RequestThreadPool. With 10 workers and 100 queries against a simulated JDBC backend, the peak was 5 concurrent calls. The single-node connection path reached 10 with the same workload. Please use the overload that honors the profile, such as getConnection(Constant.Version.V_1_0, sqlDialect), so failures that require six or more simultaneous requests are covered.
| statement.execute( | ||
| String.format( | ||
| "UNLOAD MODEL %s FROM DEVICES '%s'", modelInfo.getModelId(), devices)); | ||
| checkModelNotOnSpecifiedDevice(statement, modelInfo.getModelId(), devices); |
There was a problem hiding this comment.
[P2] Account for a queued model load during cleanup. LOAD MODEL returns once the load is queued. If the readiness check throws before either device has registered a model pool, AINode acknowledges UNLOAD MODEL without queuing an unload. The following SHOW can see zero instances and pass. In a queue-level simulation, resuming the loader after that check left sundial visible on both devices with zero unload tasks executed. Please wait for the submitted load to complete or fail on this path, then unload any instances and verify removal before the next test reuses the cluster.
| for (Thread activeThread : threads) { | ||
| activeThread.interrupt(); | ||
| } | ||
| fail("Thread timeout after 10 minutes: " + thread.getName()); |
There was a problem hiding this comment.
[P3] Preserve the first worker failure on timeout. If one worker records a SQLException or row-count mismatch and another worker times out, this fail() skips the firstFailure check below. The JUnit failure then shows only the timeout and thread name. Please attach the recorded failure as the cause or a suppressed exception on the timeout assertion so the report preserves the original stack trace.
|




Description
Problem & Trigger Scenario
AINodeSharedClusterIT.concurrentForecastTestfailed in theCluster IT - 1C1D1AGPU job (e.g., PR #19355 run 45011571306) aftersundialloaded successfully onto GPU devices0,1.AINodeSharedClusterIT.concurrentGPUForecastTestpassed a single JDBCStatementtoAINodeTestUtils.concurrentInference, which spawned 10 worker threads each running 10FORECAST(...)queries concurrently on that sharedStatement.IoTDBStatementwith the JDBC specification (closing the currentResultSetbefore executing the next query on the sameStatement), a thread executing its next query closed theResultSetstill being iterated by another thread, causing multiple worker threads to fail with:AINodeSharedClusterIT.concurrentForecastTest:527->concurrentGPUForecastTest:548.Fix
Keep JDBC driver behavior unchanged and fix the test concurrency setup:
AINodeTestUtils.concurrentInferenceto take the targetsqlDialect(BaseEnv.TABLE_SQL_DIALECT) instead of a sharedStatement, so each of the 10 worker threads opens and closes its own JDBCConnectionandStatementvia try-with-resources.sundial,timer_xl), verifying512forecast rows per request.Throwablein anAtomicReferenceand rethrow it from the test thread with full cause/message instead of dropping workerAssertionErrordetails, and enforce a shared 10-minute join deadline.LOAD MODEL/concurrentInferenceinAINodeSharedClusterIT.concurrentGPUForecastTestwithtry/finallyso loaded models are unloaded even if a failure occurs, without masking the primary failure.Validation
dd450f7ede:python3 .github/scripts/check-it-selection.py(all 847 test classes verified)mvn spotless:apply -pl integration-test -P with-integration-testsmvn test-compile -pl integration-test -am -P with-integration-tests -DskipTests(Checkstyle: 0 violations, Spotless: clean, test compilation succeeded)AINodeSharedClusterIT) is not available locally and will be validated by theCluster IT - 1C1D1Aworkflow on this PR.This PR has:
Key changed/added files in this PR
integration-test/src/test/java/org/apache/iotdb/ainode/utils/AINodeTestUtils.javaintegration-test/src/test/java/org/apache/iotdb/ainode/it/AINodeSharedClusterIT.java