-
Notifications
You must be signed in to change notification settings - Fork 1k
samples(spanner): PITR samples backup fix #1293
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
samples(spanner): PITR samples backup fix #1293
Conversation
Instead of using the earliest version time of the database, uses the current time (from spanner). If we used the earliest version time of the database instead we would be creating an empty backup, since the database we are backing up is not 1 hour old (default version retention period).
This reverts commit 5d4bc29.
DateTime does not support nanoseconds, so we have to truncate the timestamp to microseconds.
larkee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
spanner/src/create_backup.php
Outdated
| $instance = $spanner->instance($instanceId); | ||
| $database = $instance->database($databaseId); | ||
|
|
||
| $results = $database->execute("SELECT TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), MICROSECOND) as Timestamp"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jdpedrie The timestamp is being truncated because DateTime does not support nanosecond precision. Is there an alternative that does support nanosecond precision?
6c89023 to
f10beef
Compare
Instead of using the earliest version time of the database, uses the current time (from spanner). If we used the earliest version time of the database instead we would be creating an empty backup, since the database we are backing up is not 1 hour old (default version retention period).