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

proposal: spanner.CommitTimestamp check #33

Open
sinmetal opened this issue Apr 21, 2020 · 2 comments
Open

proposal: spanner.CommitTimestamp check #33

sinmetal opened this issue Apr 21, 2020 · 2 comments
Assignees

Comments

@sinmetal
Copy link
Member

WHAT

Detect that CommitTimestamp contains time.Now () in TIMESTAMP column with allow_commit_timestamp = true

WHY

Unless there are special circumstances, set the commit_timestamp column to
spanner.CommitTimestamp.
If time.Now () is included, Transaction will fail if a future time is set due to the time difference of the execution environment.

It's hard to notice in Test that the time is a few ms in the future, so it would be nice to be able to find it by static analysis.

However, it is difficult to judge whether it is allow_commit_timestamp = true because it is time.Time type in Go source code.
yo will add a new tag to the allow_commit_timestamp column of the generated code.

I can't come up with a good way to determine if a TIMESTAMP column is an allow_commit_timestamp column if I'm still using google-cloud-go 🤔

@sinmetal
Copy link
Member Author

sinmetal commented Apr 21, 2020

Error returned from Spanner

spanner: code = "FailedPrecondition", desc = "Cannot write timestamps in the future 2020-04-20T23:38:33.823058386Z > 2020-04-20T23:38:33.821725Z (current time) because the allow_commit_timestamp column option is set to true for column {COLUMN_NAME}, or for a corresponding shared key column in this table's interleaved table hierarchy."

@vvakame
Copy link
Member

vvakame commented May 28, 2020

WE NEED THIS FEATURE

@tenntenn tenntenn self-assigned this May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants