You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Enhancement] Make the unsort SST writer op-aware for separate-sort-key mixed upsert/delete loads
When lake_enable_pk_preserve_txn_delete_order is on (now the default), a load that
carries a hidden __op column keeps DELETE and UPSERT rows distinct and relies on
the spill merge REPLACE-aggregating each PK to its latest op before splitting the
DELETEs into a del file. For a separate-sort-key table the merge is ordered by the
sort key, so same-PK rows are not adjacent and aggregation is disabled -- a DELETE
followed by a later UPSERT of the same key would then leak the DELETE to the del
file and erase the (correct) UPSERT.
Resolve op order in the unsort SST writer instead, using the per-row rssid_rowid
that already flows through this path as the ordering key:
- DELETE rows are fed via TabletWriter::append_pk_index_deletes ->
PkTabletUnsortSSTWriter::append_delete_records; they carry order but no segment
rowid (kDeleteRowid) and do not advance the rowid counter.
- reconcile_entry keeps the largest-order row per PK across upserts and deletes;
a losing UPSERT's rowid goes to the delete vector, a losing/superseded DELETE is
dropped.
- At flush, a PK whose latest op is a DELETE is written as a persistent-index
tombstone (rssid == rowid == UINT32_MAX), which ingest preserves through the
shared_rssid projection (is_index_tombstone) and publish applies as an erase --
no del file and no del-file key-format mismatch. Both the in-memory and the
intermediate-spill k-way-merge paths emit tombstones.
- The parallel-merge task routes deletes to the writer only for separate-sort-key
(sort-key == PK keeps the existing del-file split) and still writes a 0-row
anchor segment for a delete-only batch so the SST stays 1:1 with segments.
append_records now returns early on an empty chunk, so the 0-row anchor write no
longer trips the "requires per-row order keys" check.
Add a BE UT (test_unsort_sst_writer_op_aware_reconcile) covering delete-wins,
upsert-wins (superseded delete), delete-only and plain-upsert keys, asserting both
the delete vector and that delete-winners are tombstones in the SST.
Signed-off-by: luohaha <casey.luo@celerdata.com>
0 commit comments