Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compose db:drop db:create db:migrate in single call against Spanner Cloud #272

Open
abachman opened this issue Nov 6, 2023 · 0 comments
Assignees
Labels
api: spanner Issues related to the googleapis/ruby-spanner-activerecord API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@abachman
Copy link

abachman commented Nov 6, 2023

When trying to do a database reset in a multi-database Rails app with bin/rails db:drop:spanner db:create:spanner db:schema:load:spanner, drop and create succeed but schema:load fails with Database not found from Spanner.

The problem is consistent when connected to Cloud Spanner projects, but does not occur when connected to the Spanner local emulator.

Environment details

  • Programming language: Ruby
  • OS: macos 14, Linux 31ff6731e7e0 6.4.16-linuxkit (in docker image)
  • Language runtime version: 3.0.5
  • Package version: activerecord-spanner-adapter (1.4.4)

Steps to reproduce

Have a cloud spanner project + instance set up.

development: 
  primary: 
    adapter: sqlite
    database: db/development.sqlite3
    pool: 5
    timeout: 5000

  spanner:
    adapter: spanner
    pool: 2
    project: dev-project
    instance: ourapp
    database: myapp_dev
    credentials: config/credentials/shared-service-account.json
    migrations_paths: db/spanner/migrate
  1. Run bin/rails db:drop:spanner db:create:spanner db:migrate:spanner against the project + instance.

Full trace

Dropped database 'myapp_test'
Created database 'myapp_test'
rails aborted!
Google::Cloud::NotFoundError: 5:Database not found: projects/dev-project/instances/ourapp/databases/myapp_test. debug_error_string:{UNKNOWN:Error received from peer ipv4:172.111.11.11:443 {grpc_message:"Database not found: projects/dev-project/instances/ourapp/databases/myapp_test", grpc_status:5, created_time:"2023-11-06T20:09:22.197355469+00:00"}}

Caused by:
GRPC::NotFound: 5:Database not found: projects/dev-project/instances/ourapp/databases/myapp_test. debug_error_string:{UNKNOWN:Error received from peer ipv4:172.111.11.11:443 {grpc_message:"Database not found: projects/dev-project/instances/ourapp/databases/myapp_test", grpc_status:5, created_time:"2023-11-06T20:09:22.197355469+00:00"}}

Expected outcome

Drop, create, load schema on Cloud Spanner without errors in one shot like in MySQL, Postgres, or Sqlite.

@abachman abachman added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Nov 6, 2023
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/ruby-spanner-activerecord API. label Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/ruby-spanner-activerecord API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants