fuyou001 commented on PR #10828:
URL: https://github.com/apache/rocketmq/pull/10828#issuecomment-5216008222

   Follow-up on the P1 lock-wait issue: Thread.yield() cannot provide the 
progress guarantees this loop relies on.
   
   The JDK contract defines Thread.yield() only as a scheduler hint, and the 
scheduler is free to ignore it. It does not park the waiter, guarantee that the 
current lock holder will run, provide fairness, or impose any upper bound on 
acquisition time. Consequently, while (!tryLock(...)) { Thread.yield(); } can 
keep a pullMessageExecutor worker RUNNABLE indefinitely; with multiple 
same-attemptId retries, the scheduler may simply rotate among spinning waiters 
while they continue consuming CPU. It also adds no deadline, cancellation, 
interruption, disconnect, or shutdown handling.
   
   Please do not use yield as the synchronization/progress mechanism here. 
Prefer an explicit asynchronous unlock notification/handoff, or at minimum a 
bounded timed acquisition tied to the request deadline and lifecycle 
cancellation, followed by state revalidation after acquisition. A regression 
test should hold the lock beyond the request deadline and assert that the 
request completes without occupying the worker indefinitely and cannot mutate 
POP/OrderInfo state after expiration; a multi-waiter test should also verify 
that the shared executor is not exhausted.


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