Skip to content

Conversation

@thiagotnunes
Copy link
Contributor

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).

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).
@thiagotnunes thiagotnunes requested a review from a team as a code owner March 1, 2021 03:48
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Mar 1, 2021
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Mar 1, 2021
@thiagotnunes thiagotnunes changed the title samples: PITR samples backup fix samples(spanner): PITR samples backup fix Mar 1, 2021
DateTime does not support nanoseconds, so we have to truncate the
timestamp to microseconds.
@thiagotnunes thiagotnunes requested review from jdpedrie and larkee March 1, 2021 05:49
Copy link
Contributor

@larkee larkee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

$instance = $spanner->instance($instanceId);
$database = $instance->database($databaseId);

$results = $database->execute("SELECT TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), MICROSECOND) as Timestamp");
Copy link
Contributor

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?

@thiagotnunes thiagotnunes force-pushed the pitr-samples-backup-fix branch from 6c89023 to f10beef Compare March 2, 2021 04:16
@bshaffer bshaffer merged commit dd253fe into GoogleCloudPlatform:master Mar 2, 2021
@thiagotnunes thiagotnunes deleted the pitr-samples-backup-fix branch March 2, 2021 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants