spanner: code = "InvalidArgument", desc = "invalid session pool"
h6ah4i opened this issue · 0 comments
h6ah4i commented
Hi. I noticed an issue with the Spanner database integration of runn.
The runn implementation creates database client object for each runbooks to make the database connections are not shared between runbooks. However, the go-sql-spanner driver reuses the same connection internally when the specified DSN is identical.
Actual behavior
An error occurs when trying to use the same Spanner database in multiple runbooks.
❯ SPANNER_EMULATOR_HOST=localhost:9010 runn run spanner_1.yml spanner_2.yml
..
1) spanner_2.yml 0e14c3d7ebcfe48aa13335c5d31fbd1681e0f4fb
Failure/Error: db query failed on "Test using Spanner".steps[0]: spanner: code = "InvalidArgument", desc = "invalid session pool"
Failure step (spanner_2.yml):
5 - db:
6 query: SELECT 1;
2 scenarios, 0 skipped, 1 failure
Reproduction
- Launch Spanner emulator
docker run -p 9010:9010 -p 9020:9020 gcr.io/cloud-spanner-emulator/emulator
- Setup the database
docker run -eSPANNER_EMULATOR_HOST=localhost:9010 --network=host google/cloud-sdk:slim bash -c 'gcloud config configurations create emulator && gcloud config set auth/disable_credentials true && gcloud config set project test-project && gcloud config set api_endpoint_overrides/spanner http://localhost:9020/ && gcloud spanner instances create test-instance --config=emulator-config --description="Test Instance" --nodes=1 && gcloud spanner databases create test-database --instance=test-instance'
- runn run
SPANNER_EMULATOR_HOST=localhost:9010 runn run spanner_1.yml spanner_2.yml
spanner_1.yml
desc: Test using Spanner
runners:
db: spanner://test-project/test-instance/test-database
steps:
- db:
query: SELECT 1;
spanner_2.yml
desc: Test using Spanner
runners:
db: spanner://test-project/test-instance/test-database
steps:
- db:
query: SELECT 1;