fix(partitioning): render chunk names from the UTC instant#49
Merged
Conversation
_ensure_partitions built chunk_name via to_char(range_start, 'YYYYMMDD_HH24MISS')
in the session timezone, but range_start is an absolute timestamptz. Running
under different session timezones (job in UTC vs client in UTC+2) named the same
chunk differently, desyncing chunk_name from range_start and tripping the
chunk_name unique index ('duplicate key ... idx_chunk_metadata_chunk_name')
that ON CONFLICT (chronotable_id, range_start) cannot absorb.
Render the name from v_start AT TIME ZONE 'UTC' so chunk_name is 1:1 with
range_start regardless of session timezone.
Release 0.1.3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The partition-manager job failed:
_ensure_partitionsbuildschunk_namewithto_char(range_start, 'YYYYMMDD_HH24MISS')in the session timezone, butrange_startis an absolutetimestamptz. When the function runs under different session timezones — the scheduled job in UTC vs a client in UTC+2 — the same chunk gets named differently, sochunk_namestops being 1:1 withrange_start. A later run then computes a name that collides with a stale row whoserange_startdiffers, andON CONFLICT (chronotable_id, range_start)can't absorb achunk_namecollision → the insert throws.Observed on
lakets-demo: a row created under UTC+2 stored…_040000forrange_start = 02:00 UTC; the UTC job computing…_040000for the real04:00 UTCchunk collided.Fix
Render the name from the instant in UTC:
to_char(v_start AT TIME ZONE 'UTC', 'YYYYMMDD_HH24MISS')(both theCREATE TABLEpartition name and the_chunk_metadata.chunk_name).chunk_nameis now 1:1 withrange_startregardless of session timezone.Test plan
make buildclean (14 modules, version 0.1.3)chunk_namecollision; names matchrange_startin UTCShips as v0.1.3. Reinstall
dist/lakets.sql.