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.
The problem:
If the
SPANNER_EMULATOR_HOSTis 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_HOSTenvironment variable tohttp://localhost:<any port>. Make sure the emulator is NOT running on this url. Run the following:The proposed solution:
We should quickly fail if the
SPANNER_EMULATOR_HOSTis 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.