taklwu commented on PR #11102: URL: https://github.com/apache/ozone/pull/11102#issuecomment-5497261001
> Do we really need to support concurrent read/seek from multiple threads? and what would be the guarantees from the InputStream perspective? > @taklwu what is the use case in Hbase for concurrent seek/read access to InputStream from multiple threads in Hbase, it seems like an error-prone implementation, lets assume that 2 threads are doing: Thread 1 > > 1. seek(1000) - t1.1 > 2 read(1000) - t1.2 > > > Thread 2 > > 1. seek(0) - t2.1 > > 2. read(100) t2.2 > > > if they perform both perform operations without synchronizations between threads it can lead to the following execution sequence: > > 1. seek(1000) - t1.1 > > 2. seek(0) - t2.1 > > 3. read(1000) - t1.2 > > 4. read(100) t2.2 > > > And both threads would read data at the wrong offset. > > And its true for any client. So if client does internal synchronization between readers' treads, InputThread itself can remain non-thread safe. yeah, you found the problem of what HBase has been using Hadoop's `DFSInputStream` that implemented `ByteBufferReadable` and `ByteBufferPositionedReadable` that `DFSInputStream` and `FSInputStream` are thread-safe for concurrent-read by multiple threads. So, if we need to support HBase on Ozone especially the positional read of HFile that has been using by HBase, we will need this feature and also better to be stateless pread that does not come with much performance penalty. > Do we really need to support concurrent read/seek from multiple threads? and what would be the guarantees from the InputStream perspective? I don't have good judgement on this, but HBase is not the only one ask for this feature, you can see use case in [HDDS-15734](https://issues.apache.org/jira/browse/HDDS-15734) also want this thread-safe positional read. -- 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]
