[ https://issues.apache.org/jira/browse/CASSANDRA-19457?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17824523#comment-17824523 ]
Bret McGuire edited comment on CASSANDRA-19457 at 3/7/24 8:19 PM: ------------------------------------------------------------------ I burned through several different hypotheses about what might actually be going on here: * Similar issue to JAVA-3051 (i.e. node reference in LBP was keeping nodes around and thus keeping metric writers around) * Straight weak reference to the node in MicrometerNodeMetricUpdater * Avoiding registering with the event bus in MicrometerMetricsFactory None of these approaches had any impact. So I thought perhaps I could try a more systematic approach... but I'm not sure if the results there make me feel better or worse: Can I recreate with: * Just node stats? ** Yes, can still repro in this case * Just session stats? ** Yes, can still repro in this case * MicroProfile metrics? ** Yes, can still repro in this case was (Author: JIRAUSER304104): I burned through several different hypotheses about what might actually be going on here: * Similar issue to JAVA-3051 (i.e. node reference in LBP was keeping nodes around and thus keeping metric writers around) * Straight weak reference to the node in MicrometerNodeMetricUpdater * Avoiding registering with the event bus in MicrometerMetricsFactory None of these approaches had any impact. So I thought perhaps I could try a more systematic approach... but I'm not sure if the results there make me feel better or worse: Can I recreate with: * Just node stats? * Yes, can still repro in this case * Just session stats? * Yes, can still repro in this case * MicroProfile metrics? * Yes, can still repro in this casef > Memory Leak of `DefaultSession` > ------------------------------- > > Key: CASSANDRA-19457 > URL: https://issues.apache.org/jira/browse/CASSANDRA-19457 > Project: Cassandra > Issue Type: Bug > Components: Client/java-driver > Reporter: Jane He > Assignee: Jane He > Priority: Normal > Attachments: Screenshot 2024-03-06 at 2.07.01 PM.png, Screenshot > 2024-03-06 at 2.07.13 PM.png > > > There is a memory leak of previous closed {{{}DefaultSession{}}}s. It can be > reproduced by this: > {code:java} > public static void main(String[] args) throws InterruptedException { > Semaphore sema = new Semaphore(20); > for (int i = 0; i < 10000; i++) { > new Thread(() -> { > try { > sema.acquire(); > try(CqlSession session = CqlSession.builder() > > .withCloudSecureConnectBundle(Paths.get("bundle.zip")) > .withAuthCredentials("token", "<some token here>") > .build()) { > // Do stuff > } > } catch (Exception e) { > System.out.println(e); > } finally { > sema.release(); > } > }).start(); > } > }{code} > On initial investigation, it seems like > {{MicrometerMetricUpdater.initializeGauge()}} uses > {{{}Gauge.{}}}{{{}_builder()_{}}} _using_ {{_Supplier_}} _._ This creates a > strong reference that is causing the issue. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org