hangc0276 edited a comment on pull request #3110: URL: https://github.com/apache/bookkeeper/pull/3110#issuecomment-1067827283
> close @lhotari For example 1. there is a read request for ledger 1, entryId request range is [1, 100]. When entryId [1, 10] read requests has been sent out and entryId 1 's response come back. If this response doesn't return OK, such as `Too many requests to the same Bookie error` it will close all the following ReadEntryRequests, and `LedgerEntryImpl` object will be recycled. https://github.com/apache/bookkeeper/blob/d750afca90d532d500d8f4598c92d1198c41b57c/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingReadOp.java#L389-L395 https://github.com/apache/bookkeeper/blob/d750afca90d532d500d8f4598c92d1198c41b57c/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingReadOp.java#L644 2. There is another read request for ledger 2, entryId request range is [1, 2]. It will get `LedgerEntryImpl` object, which may be the ref is the previous one. For example, ReadRequest 2:1 used the same `LedgerEntryImpl` object with ReadRequest 1:2. Then send entryId 1 request to the bookkeeper server 3. Read request 2:1 response came back, and run into `readEntryComplete` callback. It will call `entry.complete(rctx.bookieIndex, rctx.to, buffer)` to put the buffer into entryImpl's EntryBuf. And then put it into seq list to wait for complete https://github.com/apache/bookkeeper/blob/d750afca90d532d500d8f4598c92d1198c41b57c/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingReadOp.java#L595-L600 4. Read request 1:2 response came back. It will run into `readEntryComplete` callback. It will call `entry.complete(rctx.bookieIndex, rctx.to, buffer)` to put the buffer into entryImpl's EntryBuf. https://github.com/apache/bookkeeper/blob/d750afca90d532d500d8f4598c92d1198c41b57c/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingReadOp.java#L595 https://github.com/apache/bookkeeper/blob/d750afca90d532d500d8f4598c92d1198c41b57c/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingReadOp.java#L153 However, the entry has been hold by read request 2:1. **This operation will put entry (1:2) bytebuf into entry (2:1) bytebuf**. when run into `submitCallback(BKException.Code.OK);` logic, it will be filtered by the complete flag of PendingReadOP. https://github.com/apache/bookkeeper/blob/d750afca90d532d500d8f4598c92d1198c41b57c/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingReadOp.java#L600 https://github.com/apache/bookkeeper/blob/d750afca90d532d500d8f4598c92d1198c41b57c/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingReadOp.java#L620-L622 5. When ledger 2 's read request [1, 2] complete and all the response came back, it will return the data to client. 6. However, the entry (2:1) 's data has been tampered by step 4. This is the root cause. -- 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]
