Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Cloud Spanner client incorrectly handles NOT_FOUND error returned by create database #4071

Copy link
Copy link
@vkedia

Description

@vkedia
Issue body actions

While creating a database, is the backend returns NOT_FOUND error, the client assumes it to indicate that instance is not found and thus returns "Instance not found" error message:
https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/spanner/google/cloud/spanner_v1/database.py#L213

This is not always the case as cloud spanner can return NOT_FOUND in other scenarios. For eg in the "CREATE INDEX ... " ddl statement that table that the index is being created on does not exist it would return a NOT_FOUND. I think the fix would be to just pass the error message returned by the rpc to the user.

This can be reproduced using:

from google.cloud import spanner

"""Creates a database and tables for pattern 1 sample data."""

spanner_client = spanner.Client()

instance = spanner_client.instance("test-instance")



database = instance.database("bitemporal_pattern1", ddl_statements=[

    """CREATE TABLE MyTable (

        Id        String(36) NOT NULL,

        Field1  STRING(36) NOT NULL

) PRIMARY KEY (Id)"""

,

"""CREATE INDEX IDX ON yTable (Field1)"""

])



operation = database.create()



print('Waiting for operation to complete...')

operation.result()

Metadata

Metadata

Labels

api: spannerIssues related to the Spanner API.Issues related to the 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

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.