question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Spanner Emulator, CallInvoker is set, contrary to use of EmulatorDetection.EmulatorOnly

See original GitHub issue

Hi

I would like to use Spanner Emulator for integration tests but when I use it with C# I get CallInvoker is set error. The below is step by step to produce the error also I am attaching the simple code I have written in C#.

// for some reason C# doesn't find the environment variable so setting it manually
       Environment.SetEnvironmentVariable("SPANNER_EMULATOR_HOST", "localhost:9010");
           
           string projectId = "project-local-emulator";
           string instanceId = "test-instance";

           var builder = new SpannerConnectionStringBuilder
           {
               DataSource = $"projects/{projectId}/instances/{instanceId}",
               EmulatorDetection = EmulatorDetection.EmulatorOnly,
           };

           await using var connection = new SpannerConnection(builder);

           string createStatement = $"CREATE DATABASE `test-db`";
           var cmdcreate = connection.CreateDdlCommand(createStatement);
           await cmdcreate.ExecuteNonQueryAsync();

Environment details

  • OS: Mac OSX
  • .NET Core 3.1

Steps to reproduce

  1. Followed the instruction on this page: https://cloud.google.com/spanner/docs/emulator
  2. Created an instance and a database
  3. Trying to connect to the spanner emulator via C# and I am getting the following error

System.InvalidOperationException: CallInvoker is set, contrary to use of EmulatorDetection.EmulatorOnly

System.InvalidOperationException CallInvoker is set, contrary to use of EmulatorDetection.EmulatorOnly at Google.Api.Gax.GaxPreconditions.CheckState[T1,T2,T3](Boolean condition, String format, T1 arg0, T2 arg1, T3 arg2) at Google.Api.Gax.Grpc.ClientBuilderBase1.GetEmulatorEnvironment(IEnumerable1 requiredEmulatorEnvironmentVariables, IEnumerable1 allEmulatorEnvironmentVariables, Func2 environmentVariableProvider) at Google.Cloud.Spanner.Admin.Database.V1.DatabaseAdminClientBuilder.MaybeCreateEmulatorClientBuilder() at Google.Cloud.Spanner.Admin.Database.V1.DatabaseAdminClientBuilder.InterceptBuild(DatabaseAdminClient& client) at Google.Cloud.Spanner.Admin.Database.V1.DatabaseAdminClientBuilder.Build() at Google.Cloud.Spanner.Data.SpannerCommand.ExecutableCommand.ExecuteDdlAsync(CancellationToken cancellationToken) at Google.Cloud.Spanner.Data.SpannerCommand.ExecutableCommand.ExecuteDdlAsync(CancellationToken cancellationToken)

Would appreciate your help, as the error above doesn’t really tell much what is wrong!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
jskeetcommented, Oct 1, 2020

This has now been released as part of the 3.3.0 set of libraries.

1reaction
jskeetcommented, Sep 25, 2020

Hmmm… that’s definitely not what I’d expect. Will try to look into it this afternoon, but it may be Monday before I can get to it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Emulate Cloud Spanner locally
The gcloud CLI provides a local, in-memory emulator, which you can use to develop and test your applications for free without creating a...
Read more >
Google Spanner Emulator - HTTP 500 error on any query
I installed a spanner emulator yesterday and it was successfully returning me the results of my queries like gcloud spanner databases list ...
Read more >
Cloud Spanner Emulator
A local, in-memory, high-fidelity emulator of the Cloud Spanner service.
Read more >
Running the Local Emulator - Introduction to Google ...
So I am going to show you how you can run the Spanner emulator locally for free. You need to be aware that...
Read more >
Building Microservices with Google Cloud Spanner
Spanner Emulator is an in-memory database that you can use to develop and test your applications for free. Install and run the emulator ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found