Repository navigation
fix(storage-postgres): send table creation times to the millisecond - #1212
LeeroyHannigan wants to merge 3 commits into
Conversation
On PostgreSQL, CreateTable, DescribeTable and UpdateTable sent CreationDateTime as epoch seconds with microseconds, for example 1794835907.194914. DescribeTable sent the same value as BillingModeSummary.LastUpdateToPayPerRequestDateTime. Amazon DynamoDB sent each of these members with three decimal places, for example 1.794674022596E9, when measured in us-east-1 on 2026-11-14 and 2026-11-16. The catalog column keeps microseconds. The reads of CreateTable, DescribeTable, UpdateTable and DeleteTable now truncate it to the millisecond. The backup's source creation time is truncated too, so DescribeBackup and DeleteBackup send SourceTableDetails.TableCreationDateTime equal to CreationDateTime, as DynamoDB did on 2026-11-20. A table created before this change answers the same way, because the value is truncated when it is read. Fixes #1036.
navareamol
left a comment
There was a problem hiding this comment.
I think backups taken before this change still report six decimals. On a catalog built on main (222d80a) with a filesystem backup store, I created an on demand table and a backup, then started a build of this branch merged with main on the same catalog. DescribeTable answered CreationDateTime 1796027244.587, while DescribeBackup and DeleteBackup of the old backup answered SourceTableDetails.TableCreationDateTime 1796027244.587888. On main the two were equal. The description says a table created before the change answers the same way and that TableCreationDateTime equals CreationDateTime. For a store backed backup that time comes from the catalog row written at CreateBackup (snapshot.rs line 429, read by BackupRow::description), which none of the changed queries read. The same holds for a legacy backup that an earlier build moved with extenddb backup migrate-legacy: 1796029160.425746 against 1796029160.425. Could the time be cut to the millisecond where DescribeBackup reads the row, with a test that stores a row with a microsecond remainder? If you would rather leave old rows as they are, could the description say so?
The change to the restore_source query in backup_engine.rs has no test. With only that change reverted, date_members_carry_at_most_milliseconds and the new wire rows still pass. That query is what backup migrate-legacy copies into the catalog row: a backup migrated by this branch reports 1796029141.976, one migrated by main reports 1796029160.425746. The description names the two queries as the DescribeBackup and DeleteBackup reads. Could it name the migration, and could a test migrate a legacy backup whose table time has a microsecond remainder and check TableCreationDateTime?
Small: the description says #1166 is open. It merged on 26 November and main's backup_engine.rs already uses sqlx::AssertSqlSafe, so the reason given for keeping three copies of the expression no longer reads true. Either choice is fine with me; I think the sentence should match main.
Small: in tests/test_table_operations.py, class TestListTables: now follows the new test with no blank line between them.
I will approve once old store backed and migrated backups report the same TableCreationDateTime as their table (or the description says they keep six decimals), and the restore_source change has a test.
Main made TableDescription::creation_date_time an Option<f64> in #1411. The value is None only for a DELETING table. The test date_members_carry_at_most_milliseconds formats the field in three places: after CreateTable, after DescribeTable and after the PostgreSQL DeleteTable. After the merge of main, the test did not compile. Each place now takes the time out of the Option with expect before it formats it. The PostgreSQL DeleteTable result still holds the time. The engine removes it later, when it prepares the DELETING answer.
What
On PostgreSQL, CreateTable, DescribeTable, UpdateTable and DeleteTable sent
CreationDateTimeas epoch seconds with microseconds, for example1794835907.194914. DescribeTable sent the same value asBillingModeSummary.LastUpdateToPayPerRequestDateTime. DynamoDB sends these members with three decimal places. They now carry milliseconds:1794835907.194.The catalog column keeps microseconds. Each read of it truncates the value in SQL with
date_trunc('milliseconds', creation_date_time): the CreateTableRETURNING,build_table_description_onintable_helpers.rs, and the DeleteTable query. So a table created before this change answers the same way.DescribeBackup and DeleteBackup of an in-catalog backup read the source table's creation time in
backup_engine.rs. Those two queries truncate it too, soSourceTableDetails.TableCreationDateTimeequals the table'sCreationDateTime, as on DynamoDB.The truncation is the same SQL expression in three reads.
pg_timestamp_to_epochkeeps the sub-millisecond digits, so these reads do not use it. A shared constant would needformat!queries, which open PR #1166 wraps insqlx::AssertSqlSafe, so the three copies stay.Why
DynamoDB's answers, measured in us-east-1:
CreationDateTimeof CreateTable, DescribeTable and UpdateTable (14 and 16 November 2026)1.794674022596E91794835907.194914BillingModeSummary.LastUpdateToPayPerRequestDateTimeof DescribeTableCreationDateTimeCreationDateTime, six decimalsSourceTableDetails.TableCreationDateTimeof DescribeBackup and DeleteBackup (20 November 2026, twice)CreationDateTime, three decimalsCreationDateTime, six decimalsThe other backends already send at most three decimals: SQLite and MongoDB send whole seconds, and Cassandra sends milliseconds.
Fixes #1036
Testing done
cargo test -p extenddb-storage-postgresagainst a PostgreSQL 16 container on 127.0.0.1: 454 passed. On this host 5 tests fail on every branch at the filesystem backup store's ownership check, because uid 65534 owns/local/home.date_members_carry_at_most_millisecondsincrates/storage-postgres/tests/backup_restore.rsstores a creation time of.194914. It reads the time back as1794835907.194from DescribeTableCreationDateTime,LastUpdateToPayPerRequestDateTime, DeleteTable and DescribeBackupTableCreationDateTime. With the two backup queries reverted, the DescribeBackup check fails with1794835907.194914.cargo test -p extenddb-core --lib: 1146 passed.cargo test -p extenddb-engine --lib: 870 passed.cargo +1.97.0 clippy -p extenddb-storage-postgres --all-targets -- -D warningsandcargo +1.97.0 fmt --all -- --checkare clean.tests/test_table_operations.py,tests/test_backup_restore_fidelity.pyandtests/python/test_tables.pypassed 86 tests. The new rows oftests/test_table_operations.pycheck three decimals or fewer in CreateTable, DescribeTable, CreateBackup and UpdateTable.Line counts: production +11 -5, tests +145.
Not in this PR, each in an open issue:
LastUpdateToPayPerRequestDateTime, and a restored on-demand table reports its creation time there.CreationDateTimeand other members that DynamoDB leaves out.This PR adds no conflict with an open PR.
Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: n/a
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.