Skip to content

Fail Fast on Misconfigured SPANNER_EMULATOR_HOST  #326

@thiagotnunes

Description

@thiagotnunes

The problem:
If the SPANNER_EMULATOR_HOST is set to an unreachable url when trying to create a database, the client hangs for 1 hour. This is how long we keep retrying, without any feedback to the caller.
This causes confusion, usually, making the caller think that the Spanner client is stuck.

To reproduce the problem:
Set the SPANNER_EMULATOR_HOST environment variable to http://localhost:<any port>. Make sure the emulator is NOT running on this url. Run the following:

SpannerOptions options = SpannerOptions.newBuilder().build();
Spanner spanner = options.getService();
DatabaseAdminClient adminClient = spanner.getDatabaseAdminClient();
DatabaseId id = DatabaseId.of("project-name", "instance-name", "database-name");

// Hangs on this call
OperationFuture<Database, CreateDatabaseMetadata> op = adminClient.createDatabase(
    id.getInstanceId().getInstance(),
    id.getDatabase(),
    Collections.<String>emptyList()
);

The proposed solution:
We should quickly fail if the SPANNER_EMULATOR_HOST is misconfigured instead of retrying. We could check for this environment variable's value and verify that the host is not reachable. If the host is not reachable we should present a message to the caller indicating that the variable has been misconfigured. To be on the safe side, we could do this only if the host is localhost.

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the googleapis/java-spanner API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions