You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@rocketmq.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/02/23 03:20:44 UTC
[jira] [Commented] (ROCKETMQ-107) Access ServiceState is not thread
safe when start() or shutdown()
[ https://issues.apache.org/jira/browse/ROCKETMQ-107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15879784#comment-15879784 ]
ASF GitHub Bot commented on ROCKETMQ-107:
-----------------------------------------
GitHub user Jaskey opened a pull request:
https://github.com/apache/incubator-rocketmq/pull/68
[ROCKETMQ-107] fix possible concurrency problem on ServiceState when consumer start/shutdown
JIRA: https://issues.apache.org/jira/browse/ROCKETMQ-107
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/Jaskey/incubator-rocketmq ROCKETMQ-107-synchroization-on-ServiceState
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-rocketmq/pull/68.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #68
----
commit 91c41dae09405be95ed9ad8696959f79683dfd31
Author: Jaskey <li...@gmail.com>
Date: 2017-02-23T03:06:32Z
[ROCKETMQ-107] fix possible concurrency problem on ServiceState when consumer start/shutdown
----
> Access ServiceState is not thread safe when start() or shutdown()
> -----------------------------------------------------------------
>
> Key: ROCKETMQ-107
> URL: https://issues.apache.org/jira/browse/ROCKETMQ-107
> Project: Apache RocketMQ
> Issue Type: Bug
> Components: rocketmq-client
> Reporter: Jaskey Lam
> Assignee: Jaskey Lam
> Priority: Minor
>
> When start() or shutdown(), service's state is not thread safe which may break happen-before.
> For example:
> switch (this.serviceState) {
> case CREATE_JUST:
> log.info("the consumer [{}] start beginning. messageModel={}, isUnitMode={}", this.defaultMQPushConsumer.getConsumerGroup(),
> this.defaultMQPushConsumer.getMessageModel(), this.defaultMQPushConsumer.isUnitMode());
> this.serviceState = ServiceState.START_FAILED;
> ..// do some start job here
> this.serviceState = ServiceState.RUNNING;
> break;
> case RUNNING:
> case START_FAILED:
> case SHUTDOWN_ALREADY:
> throw new MQClientException("The PushConsumer service state not OK, maybe started once, "//
> + this.serviceState//
> + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
> null);
> default:
> break;
> }
> 1. If the user is start twice in two thread, the resources may initize twice.
> 2. if the user start in threadA and shutdown very quicky in another thread B, shutdown may not reclaim the resources.
> Though the sceniro is very uncommon, but it is indeed a bug here. Fix is actually quite trivial.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)