[v1.5] fix: add primary keys and indexes to metadata tables for concurrent write safety#14
Open
fuziontech wants to merge 2 commits into
Open
[v1.5] fix: add primary keys and indexes to metadata tables for concurrent write safety#14fuziontech wants to merge 2 commits into
fuziontech wants to merge 2 commits into
Conversation
…rite safety When using PostgreSQL as the metadata catalog with multiple concurrent writers (e.g., Kafka Connect tasks), UPDATE/DELETE statements on tables without primary keys cause postgres_scanner to use ctid (physical row ID) for row identification. This leads to serialization failures because ctid changes when rows are updated due to PostgreSQL's MVCC. Tables that previously had no primary key now have one: | Table | Primary Key | |-------|-------------| | ducklake_table_stats | table_id | | ducklake_table_column_stats | (table_id, column_id) | | ducklake_file_column_stats | (data_file_id, column_id) | | ducklake_partition_info | partition_id | | ducklake_partition_column | (partition_id, partition_key_index) | | ducklake_file_partition_value | (data_file_id, partition_key_index) | | ducklake_files_scheduled_for_deletion | data_file_id | | ducklake_inlined_data_tables | (table_id, schema_version) | | ducklake_column_mapping | mapping_id | | ducklake_name_mapping | (mapping_id, column_id) | | ducklake_macro_impl | (macro_id, impl_id) | | ducklake_macro_parameters | (macro_id, impl_id, column_id) | For frequently queried columns (especially table_id lookups): - idx_data_file_table_snapshot: (table_id, begin_snapshot, end_snapshot) - idx_delete_file_table_snapshot: (table_id, begin_snapshot, end_snapshot) - idx_column_table: (table_id, end_snapshot) - idx_file_column_stats_table: (table_id, column_id) - idx_partition_info_table: (table_id) - idx_partition_column_table: (table_id) - idx_file_partition_value_table: (table_id) This eliminates "could not serialize access due to concurrent update" errors and improves query performance for table-scoped operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
Cherry-picked from #1 to v1.5-variegata