Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should unlock queue sending unlock(42) request to brokers where orderly consumer shutdown #994

Closed
qshuai opened this issue Feb 9, 2023 · 5 comments · Fixed by #1015
Closed
Labels
bug Something isn't working

Comments

@qshuai
Copy link
Contributor

qshuai commented Feb 9, 2023

No description provided.

@francisoliverlee francisoliverlee added the question Further information is requested label Feb 14, 2023
@qshuai
Copy link
Contributor Author

qshuai commented Feb 14, 2023

所以,go客户端需要在consumer关闭的时候主动向broker发起unlock请求,是这样的吗?

@francisoliverlee
Copy link
Member

所以,go客户端需要在consumer关闭的时候主动向broker发起unlock请求,是这样的吗?

是的

@SchopenhauerZhang
Copy link

如果是正常退出可以考虑加上unlock;
比如

trylock()
defer unlock()
xxxx

但是如果是异常或者程序interrupt,broker会在到期后强制转移使用权;

if (lockEntry.isExpired()) {
                            lockEntry.setClientId(clientId);
                            lockEntry.setLastUpdateTimestamp(System.currentTimeMillis());
                            log.warn(
                                "tryLockBatch, message queue lock expired, I got it. Group: {} OldClientId: {} NewClientId: {} {}",
                                group,
                                oldClientId,
                                clientId,
                                mq);
                            lockedMqs.add(mq);
                            continue;
 }

isExpired后,会强制将锁给到此时的请求者,完成所有权转换。

@cserwen
Copy link
Member

cserwen commented Mar 10, 2023

@qshuai @SchopenhauerZhang Hi, I have fixed it, please help me to review.

@cserwen cserwen added bug Something isn't working and removed question Further information is requested labels Mar 10, 2023
francisoliverlee pushed a commit that referenced this issue Mar 20, 2023
[ISSUE #994] Fix: unlock all queues when consumer shutdown in orderly model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants