Environment details
- OS: Alpine Linux, MacOS
- Java version: 1.8
- google-cloud-java version(s): 0.38.0
Steps to reproduce
- Please see code snippet below
Code snippet
Spanner spanner = null;
try{
spanner = SpannerOptions.newBuilder()
.setProjectId(project)
.setCredentials(creds)
.build().getService();
Map<String, Map<String, String>> propsByID = new HashMap<>();
Page<Instance> instances = spanner.getInstanceAdminClient().listInstances();
for (Instance instance : instances.iterateAll()) {
Map<String, String> props = new HashMap<>();
String instanceId = instance.getId().getInstance();
// Do stuff
}
} catch(SpannerException e) {
throw new GCPException("GCP Exception fetching spanner properties", e);
} finally {
if (spanner != null) {
spanner.close();
}
}
Any additional information below
I see that daemon threads are spawned on initializing the Spanner client in this and are not stopped when the Spanner client itself is closed which is leaking threads.
From thread dump:
"Cloud-Spanner-WatchdogInterceptor-0" #642 daemon prio=5 os_prio=0 tid=0x00007fe80c508000 nid=0x293 waiting on condition [0x00007fe6fdf29000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000006f6841bd8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Please let me know if I could provide more information to help debug and TIA!
Environment details
Steps to reproduce
Code snippet
Any additional information below
I see that daemon threads are spawned on initializing the Spanner client in this and are not stopped when the Spanner client itself is closed which is leaking threads.
From thread dump:
Please let me know if I could provide more information to help debug and TIA!