yihua opened a new issue, #20848:
URL: https://github.com/apache/hudi/issues/20848

   ### Bug Description
   
   **What happened:**
   
   With the global record level index, `insert` does not look up the index, so 
inserting a key that an earlier commit already wrote (for example into another 
partition) adds a second copy of the row and moves the key's index entry to the 
new file group. The older copy is no longer reachable through the index: a 
later `delete` or `upsert` of that key, which tags through the record level 
index, only touches the newer copy, and the older one stays in the table.
   
   `GLOBAL_SIMPLE` tags both copies in the same sequence, so the delete removes 
both.
   
   **What you expected:**
   
   A global index should not lose track of a row. Either the insert should 
detect that the key is already mapped to another file group and fail (or route 
it as an update), or the docs should state that `insert` into a table with a 
global record level index requires keys that are new to the table. Detecting it 
needs an index lookup on the insert path, which `insert` skips today by design, 
so this is a contract question as much as a code change.
   
   **Steps to reproduce:**
   1. `create table t (id int, name string, dt string) using hudi partitioned 
by (dt) tblproperties (primaryKey = 'id', 'hoodie.record.merge.mode' = 
'COMMIT_TIME_ORDERING')` with `hoodie.index.type=RECORD_INDEX` and 
`hoodie.metadata.global.record.level.index.enable=true`.
   2. `insert into t values (1, 'a', 'p1'), (2, 'b', 'p1')`, then `insert into 
t values (1, 'c', 'p2'), (3, 'd', 'p2')`.
   3. `delete from t where id = 1`.
   4. `select * from t` still returns `(1, 'a', 'p1')`. With 
`hoodie.index.type=GLOBAL_SIMPLE` it returns only ids 2 and 3.
   
   ### Environment
   
   **Hudi version:** master (1.3.0-SNAPSHOT)
   **Query engine:** Spark 3.5
   **Relevant configs:** `hoodie.index.type=RECORD_INDEX`, 
`hoodie.metadata.global.record.level.index.enable=true`
   
   ### Logs and Stack Trace
   
   No error; the delete succeeds and leaves the older copy.
   


-- 
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]

Reply via email to