robbik opened a new issue, #12931: URL: https://github.com/apache/hudi/issues/12931
**_Tips before filing an issue_** - Have you gone through our [FAQs](https://hudi.apache.org/learn/faq/)? - Join the mailing list to engage in conversations and get faster support at [email protected]. - If you have triaged this as a bug, then file an [issue](https://issues.apache.org/jira/projects/HUDI/issues) directly. **Describe the problem you faced** I am doing upsert to existing hudi MOR table. When doing the upsert, an error / failure has occured with message java.lang.IllegalStateException: The current lookup key is less than the current position of the cursor, i.e., backward seekTo, which is not supported and should be avoided. **To Reproduce** I made simple java unit test to simulate this using my existing record_index file and new data to be upserted. ``` package org.apache.hudi.io.hfile; import bav.datalake.etl.spark.util.Files; import org.apache.hudi.common.util.io.ByteBufferBackedInputStream; import org.apache.hudi.io.ByteArraySeekableDataInputStream; import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; class HFileReaderImplTest { @Test void test() throws Exception { final byte[] contents = Files.toBytes("/abc/.hoodie/metadata/record_index/.record-index-0028-0_20250226192018634.log.1_102-49-7606"); final UTF8StringKey LASTKEY = new UTF8StringKey("hfile.LASTKEY"); try (HFileReaderImpl reader = new HFileReaderImpl(new ByteArraySeekableDataInputStream(new ByteBufferBackedInputStream(contents, 8036, 3944824)), 3944824)) { assertThat(reader.seekTo(), is(true)); assertThat(new Key(reader.getMetaInfo(LASTKEY).get()).getContentInString(), is("OurBranchID:9999,AccountID:9999NLP00001,LoanSeries:1,InstallmentNo:6")); System.out.println(reader.seekTo(new UTF8StringKey("OurBranchID:0324,AccountID:0324NT700001,LoanSeries:1,InstallmentNo:3"))); System.out.println(reader.seekTo(new UTF8StringKey("OurBranchID:0324,AccountID:0324NT700001,LoanSeries:1,InstallmentNo:30"))); } } } ``` I attach the record index file (zipped). **Expected behavior** No error occurred and the upsert is successful. **Environment Description** * Hudi version : 1.0.1 * Spark version : 3.5.2 (scala 2.12) * Hive version : - * Hadoop version : 2.7.1 * Storage (HDFS/S3/GCS..) : S3, Local file system (no difference) * Running on Docker? (yes/no) : yes and no (no difference) [.record-index-0028-0_20250226192018634.log.zip](https://github.com/user-attachments/files/19123040/default.record-index-0028-0_20250226192018634.log.zip) **Stacktrace** ``` java.lang.IllegalStateException: The current lookup key is less than the current position of the cursor, i.e., backward seekTo, which is not supported and should be avoided. key=UTF8StringKey{OurBranchID:0324,AccountID:0324NT700001,LoanSeries:1,InstallmentNo:30} cursor=HFilePosition{offset=3485859, keyValue=Option{val=KeyValue{key=Key{OurBranchID:0324,AccountID:0324REG00002,LoanSeries:1,InstallmentNo:5}}}} at org.apache.hudi.io.hfile.HFileReaderImpl.seekTo(HFileReaderImpl.java:173) at org.apache.hudi.io.hfile.HFileReaderImplTest.test(HFileReaderImplTest.java:29) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) ``` -- 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]
