Alter() should make retryable errors discernible from other errors

Moved from GitHub dgo/56

Posted by F21:

I have a test suite that uses DropAll to clear out the database and then use Alter to update the schema. The tests are then executed. After each run, we drop the database and update the schema again.

Sometimes, Alter() returns rpc error: code = Unknown desc = Pending transactions found. Please retry operation. The error is retryable, but there doesn’t appear to be a way to tell that this is the case when using the client, other than trying to do a string match against the grpc error.

Ideally, there should be a Retryable interface that is implemented by all classes of retryable errors returned by the client. This would enable us to generalize the code required for retrying transactions by type asserting on the interface. See Assert errors for behaviour, not type in this article: error handling – The acme of foolishness

stevenayers commented :

I have an issue with the same thing.

stevenayers commented :

I found a workaround, if you run each test package by itself you won’t run into this issue.
Instead of:
go test -v ./...

go test -v ./server/...
go test -v ./client/...

martinmr commented :

@stevenayers Your problem is that you are probably using the same cluster for all the tests. Go test might run multiple tests at once. To ensure this does not happen you can use the -parallel 1 argument to ensure all your tests are run sequentially.