[
https://issues.apache.org/jira/browse/ARTEMIS-2257?focusedWorklogId=212475&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-212475
]
ASF GitHub Bot logged work on ARTEMIS-2257:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 13/Mar/19 16:13
Start Date: 13/Mar/19 16:13
Worklog Time Spent: 10m
Work Description: michaelandrepearce commented on pull request #2558:
ARTEMIS-2257 Race condition when calling shutdownGracefully in
SharedEventLoopGroup
URL: https://github.com/apache/activemq-artemis/pull/2558#discussion_r265210254
##########
File path:
artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/SharedEventLoopGroup.java
##########
@@ -84,30 +84,32 @@ public ThreadFactory run() {
@Override
public Future<?> shutdownGracefully(final long l, final long l2, final
TimeUnit timeUnit) {
- if (channelFactoryCount.decrementAndGet() == 0) {
- shutdown.compareAndSet(null, next().scheduleAtFixedRate(new
Runnable() {
- @Override
- public void run() {
- synchronized (SharedEventLoopGroup.class) {
- if (shutdown.get() != null) {
- Future<?> future =
SharedEventLoopGroup.super.shutdownGracefully(l, l2, timeUnit);
- future.addListener(new FutureListener<Object>() {
- @Override
- public void operationComplete(Future<Object> future)
throws Exception {
- if (future.isSuccess()) {
- terminationPromise.setSuccess(null);
- } else {
- terminationPromise.setFailure(future.cause());
+ synchronized (SharedEventLoopGroup.class) {
Review comment:
Thats a good point there is risk especially where you may run two seperate
clients to different brokers or have multiple embedded brokers. Sync on class
or static sharing isnt always safe
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 212475)
Time Spent: 1.5h (was: 1h 20m)
> Synchronize SharedEventLoopGroup shutdownGracefully to prevent race conditions
> ------------------------------------------------------------------------------
>
> Key: ARTEMIS-2257
> URL: https://issues.apache.org/jira/browse/ARTEMIS-2257
> Project: ActiveMQ Artemis
> Issue Type: Bug
> Components: Broker
> Affects Versions: 2.6.4
> Reporter: yangwei
> Priority: Critical
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
> While thread a shutdowns shared event loop, between schedulingĀ a task and set
> the shutdown reference thread b calls getInstance() and retrieves ready
> shutting down instance. Add synchronized block to fix the problem.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)