horizonzy commented on issue #10150: URL: https://github.com/apache/pulsar/issues/10150#issuecomment-1112380074
### The metrics come from: https://github.com/apache/pulsar/blob/24d4d76bb9e39010bae3f4cbd8ddba6422570b4e/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/BrokerOperabilityMetrics.java#L74-L82 ### The invoke chain: 1. https://github.com/apache/pulsar/blob/24d4d76bb9e39010bae3f4cbd8ddba6422570b4e/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java#L338 2. https://github.com/apache/pulsar/blob/24d4d76bb9e39010bae3f4cbd8ddba6422570b4e/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PulsarStats.java#L245-L247 3. https://github.com/apache/pulsar/blob/24d4d76bb9e39010bae3f4cbd8ddba6422570b4e/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/BrokerOperabilityMetrics.java#L144-L147 So we can get info, when channel inactive, it will decrease `connectionActive`. ### At the tests. https://github.com/apache/pulsar/blob/24d4d76bb9e39010bae3f4cbd8ddba6422570b4e/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentTopicE2ETest.java#L1570 It judge `brk_active_connections == 0`, but at the same time, we can't guarantee the channel inactive be invoked. So the problem occur. ### Reproduce It can be reproduce by change location3 code to ``` public void recordConnectionClose() { try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } this.connectionTotalClosedCount.increment(); this.connectionActive.decrement(); } ``` ### Conclusion: So we need guarantee the `assert` after `channel inactive`. -- 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]
