- Notifications
You must be signed in to change notification settings - Fork 135
Labels
🚨This issue needs some love.This issue needs some love.api: spannerIssues related to the googleapis/java-spanner API.Issues related to the googleapis/java-spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
I noticed that calling Spanner.getDatabaseClient
with a non-existent database and then trying to read from the database can cause new client IDs to appear in the OpenCensus session metrics. The client IDs for the non-existent database seem problematic because they can cause the size of the metrics to grow.
Here is a simplified reproduction:
google-cloud-spanner version: 1.54.0
opencensus-java version: 0.26.0
import com.google.cloud.spanner.DatabaseId; import com.google.cloud.spanner.InstanceConfigId; import com.google.cloud.spanner.InstanceId; import com.google.cloud.spanner.InstanceInfo; import com.google.cloud.spanner.Key; import com.google.cloud.spanner.Spanner; import com.google.cloud.spanner.SpannerOptions; import io.opencensus.exporter.stats.stackdriver.StackdriverStatsExporter; import java.util.Arrays; import org.junit.Test; public class ClientIdTest { @Test public void testClientId() throws Exception { StackdriverStatsExporter.createAndRegister(); Spanner spanner = SpannerOptions.getDefaultInstance().getService(); String projectId = spanner.getOptions().getProjectId(); InstanceId instanceId = InstanceId.of(projectId, "my-instance"); InstanceConfigId instanceConfigId = InstanceConfigId.of(projectId, "regional-us-central1"); spanner .getInstanceAdminClient() .createInstance( InstanceInfo.newBuilder(instanceId) .setInstanceConfigId(instanceConfigId) .setDisplayName("my-instance") .setNodeCount(1) .build()) .get(); DatabaseId databaseId = DatabaseId.of(instanceId, "my-database"); for (int i = 0; i < 100; i++) { try { spanner .getDatabaseClient(databaseId) .singleUse() .readRow("MyTable", Key.of(0), Arrays.asList("MyColumn")); } catch (Exception e) { // ignore } } Thread.sleep(300_000); } }
The metrics exported to Stackdriver contain 100 client IDs. For example, here is in_use_sessions
:
Metadata
Metadata
Assignees
Labels
🚨This issue needs some love.This issue needs some love.api: spannerIssues related to the googleapis/java-spanner API.Issues related to the googleapis/java-spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.