apurtell commented on PR #2694:
URL: https://github.com/apache/phoenix/pull/2694#issuecomment-7068580387

   ```
   UpsertSelectIT.testUpsertSelectForAgg[allowServerSideMutations=true]  33.34 
s  FAILURE
   java.lang.AssertionError: expected:<0> but was:<-1>
     at UpsertSelectIT.waitForOpenConnectionsToSettle(UpsertSelectIT.java:128)
     at UpsertSelectIT.assertNoConnLeak(UpsertSelectIT.java:113)
   ```
   
   The counter is **-1**, so this is not a leak. A connection that was already 
open when the counter was reset closed after the reset.
   
   **Mechanism**
   
   1. `UpsertSelectIT.doSetup` sets 
`TASK_HANDLING_INTERVAL_MS`/`INITIAL_DELAY_MS = Long.MAX_VALUE` and 
`PHOENIX_INDEX_CDC_CONSUMER_ENABLED=false` to keep background server threads 
from touching `GLOBAL_OPEN_PHOENIX_CONNECTIONS`. These are server-side 
settings. `BaseTest.setUpTestDriver` → `checkClusterInitialized` applies 
`serverProps` only when it starts a new mini cluster. In this fork an earlier 
class had already started the shared cluster, so the overrides were silently 
dropped. The output log has no minicluster startup, and the RS runs 
`TaskRegionObserver` at BaseTest's 10 s interval and starts 
`IndexCDCConsumer-*` threads.
   2. `TaskRegionObserver.SelfHealingTask` opens a server connection on every 
tick through `QueryUtil.getConnectionOnServer` and closes it a few ms later. In 
the same JVM that connection is non-internal, so it increments and decrements 
`GLOBAL_OPEN_PHOENIX_CONNECTIONS`.
   3. `@Before setup()` resets every global metric to 0. If a tick's connection 
is open at that moment, its close drives the counter to -1. The PHOENIX-7952 
poll waits for `== 0`, so it cannot recover. Its only way out is a 100 ms poll 
that happens to land inside the next tick's few-ms open window.
   
   **Timeline from the failsafe output log (RS-local time)**
   
   | time | event |
   |---|---|
   | 11:44:01.300 | task tick opens conn (pool-1858-thread-1) |
   | ~11:44:01.31 | `testParallelUpsertSelect` @After reads 0 → 
`testLengthLimitedVarchar` @Before resets to 0 while the tick conn is open → 
close → **-1** |
   | 11:44:01–:21 | `testLengthLimitedVarchar` (a trivial test) sits in its 
@After poll at -1. The :11.348 tick is missed. |
   | 11:44:21.353 | tick opens conn → counter 0 → poll catches it and @After 
passes. **Elapsed 20.033 s** = :21.35 − :01.31 |
   | ~11:44:21.36 | `testUpsertSelectForAgg` @Before resets to 0 while the 
:21.353 conn is open → close → **-1** |
   | :31, :41, :51 ticks | missed by the poll |
   | ~11:44:54.7 | 30 s settle timeout → `expected:<0> but was:<-1>`. **Elapsed 
33.34 s** ≈ 3 s body + 30 s poll |
   
   `IndexCDCConsumer` threads also open server connections on the same counter: 
one at region open and another after a 10 s startup delay. That is a second 
source of the same race. The task tick alone accounts for this failure.
   
   **Why it is not this PR:** the diff only bumps `snappy-java` 1.1.10.8 → 
1.1.10.9. Nothing in the failure path uses compression.
   
   **Related:** #2446 (PHOENIX-7829) disables the `SelfHealingTask` schedule 
for all mini-cluster ITs in `BaseTest`, which removes the source that caused 
this failure. The `IndexCDCConsumer` source and the reset race in the leak 
check are still open.
   
   Posted by Claude Code on behalf of Andrew Purtell.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to