JackieTien97 opened a new pull request, #18681:
URL: https://github.com/apache/iotdb/pull/18681

   ## Description
   
   Stopping or reloading the metric service currently clears the client pool 
registry. An in-flight gauge can then throw a NullPointerException, and 
rebinding cannot restore metrics for existing pools.
   
   This change preserves live pool registrations across metric unbind/bind and 
makes each gauge read its pool directly. Registration, binding, and unbinding 
share a lifecycle lock; collection and client borrow/return operations do not 
acquire it.
   
   Closing a client manager unregisters its pool by object identity, so a late 
close cannot remove a replacement pool's metrics. Replacing a closed pool also 
removes its old metrics before registration to refresh JMX. AutoGauge reads its 
weak reference once per sample, keeping the referent available throughout the 
callback.
   
   ### Validation
   
   - Added 9 ClientManagerMetrics tests covering repeated rebinds, metric 
service restarts and level changes, registration during unbind, concurrent 
sampling, closed-pool cleanup, same-name replacement, and JMX refresh.
   - Added 2 AutoGauge tests covering live/cleared references and deterministic 
reference clearing between reads.
   - All 12 selected JUnit tests passed, including the existing 
ClientManagerTest; the full 50-module English reactor build passed.
   - The full 50-module Chinese-locale test compilation passed.
   - Spotless and git diff whitespace checks passed.
   - As a regression control, running the new tests with the three original 
production classes produced 9 failures out of 11 tests.
   
   ```sh
   mvn test 
-Dtest=ClientManagerMetricsTest,ClientManagerTest,IoTDBAutoGaugeTest 
-Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false
   mvn test-compile -P with-zh-locale -DskipTests
   ```
   
   The unit tests use real Commons Pool instances, the metric manager, and JMX. 
Full cluster integration tests were not run.
   
   <hr>
   
   This PR has:
   - [x] been self-reviewed, including concurrent reads, writes, and lifecycle 
transitions.
   - [x] added comments explaining lifecycle and instance-identity handling.
   - [x] added regression unit tests for the changed behavior.
   - [x] included Apache license headers in new source files.
   
   ##### Key changed/added classes
   
   - ClientManagerMetrics
   - ClientManager
   - IoTDBAutoGauge
   - ClientManagerMetricsTest
   - IoTDBAutoGaugeTest
   


-- 
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