[ https://issues.apache.org/jira/browse/ROCKETMQ-107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15881953#comment-15881953 ]
ASF GitHub Bot commented on ROCKETMQ-107: ----------------------------------------- Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/68 [![Coverage Status](https://coveralls.io/builds/10308981/badge)](https://coveralls.io/builds/10308981) Coverage increased (+0.2%) to 31.72% when pulling **57c2c6893b3fe1173aa7a68c15d63f309bd89138 on Jaskey:ROCKETMQ-107-synchroization-on-ServiceState** into **573b22c37806a21543b90707bcce6022243a62da on apache:master**. > 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)