KKcorps commented on PR #18733:
URL: https://github.com/apache/pinot/pull/18733#issuecomment-6336601328

   This comes from a model of upsert thread orders that StarTree runs on upsert 
PRs.
   
   **This clears none of the model's known bad orders and adds one: the row 
with a lower comparison value that `doAddRecord` now accepts for an expired key 
is undone when its segment is committed or loaded again.**
   
   I replayed the model's 45 known bad orders with and without the change, and 
none changed. A 62 minute search, 402 runs over 10 metadataTTL table shapes, 
then found 44 runs that break only with the change. All but one are this order, 
and the last is a smaller merge edge after a consuming segment is reset.
   
   **The order it adds.** Only the consuming path has the new branch. 
`doAddOrReplaceSegment` still compares, so at commit the expired row takes the 
key back. It needs no race, only a late row for a key that is already past 
metadataTTL.
   
   ```mermaid
   sequenceDiagram
       participant S as Stream
       participant C as Consuming replica
       participant L as Server loading N1
       S->>C: A at 4, watermark is now 4
       S->>C: B at 1, doc 0 of segment N1
       S->>C: B at 0, doc 1 of N1
       C->>C: B at 1 is below 4 minus metadataTTL 2, so doc 1 wins with no 
compare
       Note over C: serves B at 0
       C->>L: N1 commits, then replaceSegment or addSegment walks its docs
       L->>L: doc 0, B at 1, takes the key
       L->>L: doc 1, B at 0, loses the compare to doc 0
       Note over L: serves B at 1 again
   ```
   
   In the new test the late row lands in a later segment, so the commit keeps 
it. A new replica, or a restart that does not preload from an up to date 
snapshot, still serves the expired row, and replicas disagree until the key 
gets a newer row.
   
   <details><summary>Model history</summary>
   
   ```
   ('append', 'A', (4,), 0, {'v': 0}, False)
   ('commit_remote', 0, 0)
   ('append', 'B', (1,), 1, {'v': 0}, False)
   ('append', 'B', (0,), 2, {'v': 0}, False)
   ('commit_remote', 1, 2)
   ('add_immutable', 'N0')
   ('step', 'add_immutable', 'N0', 'start_add')
   ('step', 'add_immutable', 'N0', 'add_row:A@0')
   ('add_immutable', 'N1')
   ('append', 'A', (0,), 3, {'v': 0}, False)
   ('step', 'add_immutable', 'N0', 'register')
   ('step', 'add_immutable', 'N1', 'start_add')
   ('step', 'add_immutable', 'N1', 'add_row:B@1')
   ('step', 'add_immutable', 'N1', 'add_row:B@2')
   ('step', 'add_immutable', 'N1', 'register')
   ```
   
   </details>
   
   The model covers one replica and the handoff slice of one partition, and it 
searched only metadataTTL tables.
   
   <!-- upsert-model-check head=5085afb0e358ca0a8f783eff120124ae54a83847 -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to