yihua opened a new pull request, #17717:
URL: https://github.com/apache/hudi/pull/17717

   ### Describe the issue this Pull Request addresses
   
   Fixes #17716.
   
   This PR fixes a flaky test failure caused by 
`ConcurrentModificationException` in `RocksDBDAO` when multiple threads 
concurrently access the Timeline Service.
   
   The Timeline Service uses `RocksDbBasedFileSystemView` which internally uses 
`RocksDBDAO`. When multiple Spark executors send concurrent HTTP requests to 
the Timeline Service (e.g., to query file slices), multiple Jetty threads 
access the same `RocksDBDAO` instance simultaneously. This triggers concurrent 
calls to `getSerializerForColumnFamily()` which uses 
`HashMap.computeIfAbsent()` - a non-thread-safe operation that causes 
`ConcurrentModificationException`.
   
   Stacktrace:
   ```
     org.apache.hudi.exception.HoodieException: 
java.util.ConcurrentModificationException
         at 
org.apache.hudi.common.util.collection.RocksDBDAO.get(RocksDBDAO.java:360)
         ...
     Caused by: java.util.ConcurrentModificationException
         at java.util.HashMap.computeIfAbsent(HashMap.java:1135)
         at 
org.apache.hudi.common.util.collection.RocksDBDAO.getSerializerForColumnFamily(RocksDBDAO.java:520)
   ```
   
   ### Summary and Changelog
   
   Changed `columnFamilySerializers` in `RocksDBDAO` from `HashMap` to 
`ConcurrentHashMap` to ensure thread-safe access when multiple threads call 
`computeIfAbsent()` concurrently.
     - Changes field type from `Map<String, CustomSerializer<?>>` to 
`ConcurrentHashMap<String, CustomSerializer<?>>`
     - Updates default constructor to create `ConcurrentHashMap` directly
     - Updates parameterized constructor to copy input map into a new 
`ConcurrentHashMap`
     - Adds unit test `testConcurrentAccess()` to verify thread-safety
   
   ### Impact
   
   No public API changes. Internal implementation change only.
   
   ### Risk Level
   
   low
   
   ### Documentation Update
   
   none
   
   ### Contributor's checklist
   
   - [ ] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [ ] Enough context is provided in the sections above
   - [ ] Adequate tests were added if applicable
   


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