0

Running a simple query like a select against a small table and I get results back; executing the same code using a more complex query and it errors out with a Task Canceled Exception.

        var executeSqlRequest = service.Projects.Instances.Databases.Sessions.ExecuteStreamingSql(
            new Google.Apis.Spanner.v1.Data.ExecuteSqlRequest()
                { Sql = sql_text, QueryMode= "NORMAL" },
            session);

        PartialResultSet resultSet = await executeSqlRequest.ExecuteAsync();

more info from debugging through the lib - looks like the socket was disposed while still in use and accessing it caused the task to be cancelled:

System.ObjectDisposedException occurred Message: Exception thrown: 'System.ObjectDisposedException' in System.dll Additional information: Cannot access a disposed object.

System.IO.IOException occurred Message: Exception thrown: 'System.IO.IOException' in System.dll Additional information: Unable to read data from the transport connection: Cannot access a disposed object. Object name: 'System.Net.Sockets.Socket'..

from client code debugging:

A task was canceled. { "ClassName": "System.Threading.Tasks.TaskCanceledException", "Message": "A task was canceled.", "Data": null, "InnerException": null, "HelpURL": null, "StackTraceString": " at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Google.Apis.Requests.ClientServiceRequest1.<ExecuteUnparsedAsync>d__30.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Google.Apis.Requests.ClientServiceRequest
1.d__27.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Google.Apis.Requests.ClientServiceRequest1.<ExecuteAsync>d__26.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()\r\n at Discovery.ListAPIs.Program.d__10.MoveNext() in C:\Users\Dave\Documents\Visual Studio 2015\Projects\SpannerConsoleApp\SpannerConsoleApp\Program.cs:line 257", "RemoteStackTraceString": null, "RemoteStackIndex": 0,
"ExceptionMethod": "8\nThrowForNonSuccess\nmscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.Runtime.CompilerServices.TaskAwaiter\nVoid ThrowForNonSuccess(System.Threading.Tasks.Task)", "HResult": -2146233029, "Source": "mscorlib", "WatsonBuckets": null }---

dr3x
  • 917
  • 2
  • 14
  • 26
  • 1
    It looks like you're trying to use the REST-based APIs to talk to Spanner. While I'd expect it to work, we're focusing on the gRPC-based API. That's not ready yet, because we're working on a layer over the top of the raw RPCs... the intention is that users shouldn't need to use the low-level abstraction. – Jon Skeet May 30 '17 at 08:58
  • So what is the current approved way to access Spanner programmatically, preferably via .NET or python? Or should I wait for the gRPC based API framework to be done? Thanks – dr3x May 30 '17 at 15:48
  • 2
    I don't know about Python, but yes, for C# I would wait for the ADO.NET abstraction to be done. Keep an eye on https://github.com/GoogleCloudPlatform/google-cloud-dotnet... – Jon Skeet May 30 '17 at 15:48
  • @dr3x as Jon says, the preferred way to use Cloud Spanner is to use the client libraries. We have released libraries for Java, Go, Node.js, Python, and PHP here: https://cloud.google.com/spanner/docs/reference/libraries C# and Ruby are coming. These client libraries are all gRPC based. – Albert Cui Jun 02 '17 at 15:17
  • Yes not able to execute the query via the Python lib either; issue writeup here: https://github.com/GoogleCloudPlatform/python-docs-samples/issues/975 There I am getting StatusCode.DEADLINE_EXCEEDED – dr3x Jun 02 '17 at 23:57

0 Answers0