oneby-wang commented on PR #25144:
URL: https://github.com/apache/pulsar/pull/25144#issuecomment-3752583473

   I am not familiar with mockito or bytecode manipulation technology, but 
after some deeper debug on this test, I'd suggest that we should avoid spying 
an instance that contains volatile fields in tests, especially when these 
volatile fields are not accessed using setter and getter methods.
   
   Here is the debug details:
   
   All fields of `originalLedger` and `ledger` are identical after 
initialization.
   
   <img width="1920" height="1030" alt="image" 
src="https://github.com/user-attachments/assets/de796b92-17b5-4ae2-ae73-c3bf4083fe20";
 />
   
   `lastConfirmedEntry` is also identical.
   
   <img width="1920" height="1030" alt="image" 
src="https://github.com/user-attachments/assets/36f42c61-45d4-494a-a3fb-5762d0cff92b";
 />
   
   Except `entryCahce.ml` field: 
   - `entryCahce.ml` is `originalLedger` in `originalLedger`.
   - `entryCahce.ml` is `originalLedger` in `ledger`.
   
   This is the inconsistency root cause.
   
   <img width="1920" height="1030" alt="image" 
src="https://github.com/user-attachments/assets/e869850f-ec9b-4d35-b01c-4d51801a2090";
 />
   
   After adding 10 entries, `lastConfirmedEntry` in `ledger` is updated to 
`12:0`, but in `originalLedger`, `lastConfirmedEntry` is still `3:-1`, which is 
not updated.
   
   <img width="1920" height="1030" alt="image" 
src="https://github.com/user-attachments/assets/a12ed7c1-eae7-4307-928f-c72c4d08375c";
 />
   
   After adding 10 entries, `currentLedger` in `originalLedger` is also not 
updated.
   
   <img width="1920" height="1030" alt="image" 
src="https://github.com/user-attachments/assets/36089ed6-cd95-4e22-bf52-d367eb21a216";
 />
   
   Here comes the `ManagedLedgerException`.
   
   <img width="1920" height="1030" alt="image" 
src="https://github.com/user-attachments/assets/8656a0e2-d725-40f0-a24a-c313bfd61f4c";
 />


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