[jira] [Work logged] (AMQNET-610) Race condition during consumer creation
[ https://issues.apache.org/jira/browse/AMQNET-610?focusedWorklogId=310793=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-310793 ] ASF GitHub Bot logged work on AMQNET-610: - Author: ASF GitHub Bot Created on: 11/Sep/19 16:37 Start Date: 11/Sep/19 16:37 Worklog Time Spent: 10m Work Description: michaelandrepearce commented on issue #29: AMQNET-610: Race conditions during consumer creation URL: https://github.com/apache/activemq-nms-amqp/pull/29#issuecomment-530462233 Ok. Just remember there will always be bugs. We do want to cut a release at somepoint. Once we have a release done we can always do another in a few more weeks. 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: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 310793) Time Spent: 2.5h (was: 2h 20m) > Race condition during consumer creation > --- > > Key: AMQNET-610 > URL: https://issues.apache.org/jira/browse/AMQNET-610 > Project: ActiveMQ .Net > Issue Type: Bug > Components: AMQP, NMS >Reporter: Krzysztof Porebski >Priority: Critical > Fix For: 1.8.0 > > Time Spent: 2.5h > Remaining Estimate: 0h > > Working on CI I found a race condition that reveals itself on slower machines > and may result in losing messages by consumers. > The race condition is a result of treating the creation of consumer resources > and starting them as an atomic operation: > {code:java} > public async Task Init() > { > await Session.Connection.CreateResource(Info); > await Session.Connection.StartResource(Info); > } > {code} > On slower boxes pending message may be delivered to the provider before above > code returns: > {code:java} > public IMessageConsumer CreateConsumer(IDestination destination, string > selector, bool noLocal) > { > CheckClosed();NmsMessageConsumer messageConsumer = new > NmsMessageConsumer(consumerIdGenerator.GenerateId(), this, destination, > selector, noLocal); > messageConsumer.Init().ConfigureAwait(false).GetAwaiter().GetResult(); > // here may be a race condition > consumers.TryAdd(messageConsumer.Info.Id, messageConsumer); > > return messageConsumer; > } > {code} > If message arrives before `Init` returns (which means before newly created > consumer is added to the list of available consumers), the message will be > ignored. > {code:java} > public void OnInboundMessage(InboundMessageDispatch envelope) > { > if (consumers.TryGetValue(envelope.ConsumerInfo.Id, out > NmsMessageConsumer messageConsumer)) > { > messageConsumer.OnInboundMessage(envelope); > } > } > {code} > > > -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Work logged] (AMQNET-610) Race condition during consumer creation
[ https://issues.apache.org/jira/browse/AMQNET-610?focusedWorklogId=310782=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-310782 ] ASF GitHub Bot logged work on AMQNET-610: - Author: ASF GitHub Bot Created on: 11/Sep/19 16:27 Start Date: 11/Sep/19 16:27 Worklog Time Spent: 10m Work Description: Havret commented on issue #29: AMQNET-610: Race conditions during consumer creation URL: https://github.com/apache/activemq-nms-amqp/pull/29#issuecomment-530458732 Yep. But it would be nice to have [this one](https://issues.apache.org/jira/projects/AMQNET/issues/AMQNET-611) included in the initial release as well. It will be a quick fix though. 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: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 310782) Time Spent: 2h 20m (was: 2h 10m) > Race condition during consumer creation > --- > > Key: AMQNET-610 > URL: https://issues.apache.org/jira/browse/AMQNET-610 > Project: ActiveMQ .Net > Issue Type: Bug > Components: AMQP, NMS >Reporter: Krzysztof Porebski >Priority: Critical > Time Spent: 2h 20m > Remaining Estimate: 0h > > Working on CI I found a race condition that reveals itself on slower machines > and may result in losing messages by consumers. > The race condition is a result of treating the creation of consumer resources > and starting them as an atomic operation: > {code:java} > public async Task Init() > { > await Session.Connection.CreateResource(Info); > await Session.Connection.StartResource(Info); > } > {code} > On slower boxes pending message may be delivered to the provider before above > code returns: > {code:java} > public IMessageConsumer CreateConsumer(IDestination destination, string > selector, bool noLocal) > { > CheckClosed();NmsMessageConsumer messageConsumer = new > NmsMessageConsumer(consumerIdGenerator.GenerateId(), this, destination, > selector, noLocal); > messageConsumer.Init().ConfigureAwait(false).GetAwaiter().GetResult(); > // here may be a race condition > consumers.TryAdd(messageConsumer.Info.Id, messageConsumer); > > return messageConsumer; > } > {code} > If message arrives before `Init` returns (which means before newly created > consumer is added to the list of available consumers), the message will be > ignored. > {code:java} > public void OnInboundMessage(InboundMessageDispatch envelope) > { > if (consumers.TryGetValue(envelope.ConsumerInfo.Id, out > NmsMessageConsumer messageConsumer)) > { > messageConsumer.OnInboundMessage(envelope); > } > } > {code} > > > -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Work logged] (AMQNET-610) Race condition during consumer creation
[ https://issues.apache.org/jira/browse/AMQNET-610?focusedWorklogId=310779=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-310779 ] ASF GitHub Bot logged work on AMQNET-610: - Author: ASF GitHub Bot Created on: 11/Sep/19 16:21 Start Date: 11/Sep/19 16:21 Worklog Time Spent: 10m Work Description: michaelandrepearce commented on issue #29: AMQNET-610: Race conditions during consumer creation URL: https://github.com/apache/activemq-nms-amqp/pull/29#issuecomment-530456020 Cool was this the only blocker for CI? Or more issues you want to fix. Just trying to gauge when to cut release 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: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 310779) Time Spent: 2h 10m (was: 2h) > Race condition during consumer creation > --- > > Key: AMQNET-610 > URL: https://issues.apache.org/jira/browse/AMQNET-610 > Project: ActiveMQ .Net > Issue Type: Bug > Components: AMQP, NMS >Reporter: Krzysztof Porebski >Priority: Critical > Time Spent: 2h 10m > Remaining Estimate: 0h > > Working on CI I found a race condition that reveals itself on slower machines > and may result in losing messages by consumers. > The race condition is a result of treating the creation of consumer resources > and starting them as an atomic operation: > {code:java} > public async Task Init() > { > await Session.Connection.CreateResource(Info); > await Session.Connection.StartResource(Info); > } > {code} > On slower boxes pending message may be delivered to the provider before above > code returns: > {code:java} > public IMessageConsumer CreateConsumer(IDestination destination, string > selector, bool noLocal) > { > CheckClosed();NmsMessageConsumer messageConsumer = new > NmsMessageConsumer(consumerIdGenerator.GenerateId(), this, destination, > selector, noLocal); > messageConsumer.Init().ConfigureAwait(false).GetAwaiter().GetResult(); > // here may be a race condition > consumers.TryAdd(messageConsumer.Info.Id, messageConsumer); > > return messageConsumer; > } > {code} > If message arrives before `Init` returns (which means before newly created > consumer is added to the list of available consumers), the message will be > ignored. > {code:java} > public void OnInboundMessage(InboundMessageDispatch envelope) > { > if (consumers.TryGetValue(envelope.ConsumerInfo.Id, out > NmsMessageConsumer messageConsumer)) > { > messageConsumer.OnInboundMessage(envelope); > } > } > {code} > > > -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Work logged] (AMQNET-610) Race condition during consumer creation
[ https://issues.apache.org/jira/browse/AMQNET-610?focusedWorklogId=310772=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-310772 ] ASF GitHub Bot logged work on AMQNET-610: - Author: ASF GitHub Bot Created on: 11/Sep/19 16:11 Start Date: 11/Sep/19 16:11 Worklog Time Spent: 10m Work Description: michaelandrepearce commented on pull request #29: AMQNET-610: Race conditions during consumer creation URL: https://github.com/apache/activemq-nms-amqp/pull/29 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: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 310772) Time Spent: 2h (was: 1h 50m) > Race condition during consumer creation > --- > > Key: AMQNET-610 > URL: https://issues.apache.org/jira/browse/AMQNET-610 > Project: ActiveMQ .Net > Issue Type: Bug > Components: AMQP, NMS >Reporter: Krzysztof Porebski >Priority: Critical > Time Spent: 2h > Remaining Estimate: 0h > > Working on CI I found a race condition that reveals itself on slower machines > and may result in losing messages by consumers. > The race condition is a result of treating the creation of consumer resources > and starting them as an atomic operation: > {code:java} > public async Task Init() > { > await Session.Connection.CreateResource(Info); > await Session.Connection.StartResource(Info); > } > {code} > On slower boxes pending message may be delivered to the provider before above > code returns: > {code:java} > public IMessageConsumer CreateConsumer(IDestination destination, string > selector, bool noLocal) > { > CheckClosed();NmsMessageConsumer messageConsumer = new > NmsMessageConsumer(consumerIdGenerator.GenerateId(), this, destination, > selector, noLocal); > messageConsumer.Init().ConfigureAwait(false).GetAwaiter().GetResult(); > // here may be a race condition > consumers.TryAdd(messageConsumer.Info.Id, messageConsumer); > > return messageConsumer; > } > {code} > If message arrives before `Init` returns (which means before newly created > consumer is added to the list of available consumers), the message will be > ignored. > {code:java} > public void OnInboundMessage(InboundMessageDispatch envelope) > { > if (consumers.TryGetValue(envelope.ConsumerInfo.Id, out > NmsMessageConsumer messageConsumer)) > { > messageConsumer.OnInboundMessage(envelope); > } > } > {code} > > > -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Work logged] (AMQNET-610) Race condition during consumer creation
[ https://issues.apache.org/jira/browse/AMQNET-610?focusedWorklogId=310766=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-310766 ] ASF GitHub Bot logged work on AMQNET-610: - Author: ASF GitHub Bot Created on: 11/Sep/19 15:59 Start Date: 11/Sep/19 15:59 Worklog Time Spent: 10m Work Description: Havret commented on issue #29: AMQNET-610: Race conditions during consumer creation URL: https://github.com/apache/activemq-nms-amqp/pull/29#issuecomment-530447174 I'm going to look at it tonight. 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: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 310766) Time Spent: 1h 50m (was: 1h 40m) > Race condition during consumer creation > --- > > Key: AMQNET-610 > URL: https://issues.apache.org/jira/browse/AMQNET-610 > Project: ActiveMQ .Net > Issue Type: Bug > Components: AMQP, NMS >Reporter: Krzysztof Porebski >Priority: Critical > Time Spent: 1h 50m > Remaining Estimate: 0h > > Working on CI I found a race condition that reveals itself on slower machines > and may result in losing messages by consumers. > The race condition is a result of treating the creation of consumer resources > and starting them as an atomic operation: > {code:java} > public async Task Init() > { > await Session.Connection.CreateResource(Info); > await Session.Connection.StartResource(Info); > } > {code} > On slower boxes pending message may be delivered to the provider before above > code returns: > {code:java} > public IMessageConsumer CreateConsumer(IDestination destination, string > selector, bool noLocal) > { > CheckClosed();NmsMessageConsumer messageConsumer = new > NmsMessageConsumer(consumerIdGenerator.GenerateId(), this, destination, > selector, noLocal); > messageConsumer.Init().ConfigureAwait(false).GetAwaiter().GetResult(); > // here may be a race condition > consumers.TryAdd(messageConsumer.Info.Id, messageConsumer); > > return messageConsumer; > } > {code} > If message arrives before `Init` returns (which means before newly created > consumer is added to the list of available consumers), the message will be > ignored. > {code:java} > public void OnInboundMessage(InboundMessageDispatch envelope) > { > if (consumers.TryGetValue(envelope.ConsumerInfo.Id, out > NmsMessageConsumer messageConsumer)) > { > messageConsumer.OnInboundMessage(envelope); > } > } > {code} > > > -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Work logged] (AMQNET-610) Race condition during consumer creation
[ https://issues.apache.org/jira/browse/AMQNET-610?focusedWorklogId=310764=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-310764 ] ASF GitHub Bot logged work on AMQNET-610: - Author: ASF GitHub Bot Created on: 11/Sep/19 15:57 Start Date: 11/Sep/19 15:57 Worklog Time Spent: 10m Work Description: michaelandrepearce commented on issue #29: AMQNET-610: Race conditions during consumer creation URL: https://github.com/apache/activemq-nms-amqp/pull/29#issuecomment-530446482 @HavretGC did we resolve the issue robbie raised in dev mail list re object msg 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: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 310764) Time Spent: 1h 40m (was: 1.5h) > Race condition during consumer creation > --- > > Key: AMQNET-610 > URL: https://issues.apache.org/jira/browse/AMQNET-610 > Project: ActiveMQ .Net > Issue Type: Bug > Components: AMQP, NMS >Reporter: Krzysztof Porebski >Priority: Critical > Time Spent: 1h 40m > Remaining Estimate: 0h > > Working on CI I found a race condition that reveals itself on slower machines > and may result in losing messages by consumers. > The race condition is a result of treating the creation of consumer resources > and starting them as an atomic operation: > {code:java} > public async Task Init() > { > await Session.Connection.CreateResource(Info); > await Session.Connection.StartResource(Info); > } > {code} > On slower boxes pending message may be delivered to the provider before above > code returns: > {code:java} > public IMessageConsumer CreateConsumer(IDestination destination, string > selector, bool noLocal) > { > CheckClosed();NmsMessageConsumer messageConsumer = new > NmsMessageConsumer(consumerIdGenerator.GenerateId(), this, destination, > selector, noLocal); > messageConsumer.Init().ConfigureAwait(false).GetAwaiter().GetResult(); > // here may be a race condition > consumers.TryAdd(messageConsumer.Info.Id, messageConsumer); > > return messageConsumer; > } > {code} > If message arrives before `Init` returns (which means before newly created > consumer is added to the list of available consumers), the message will be > ignored. > {code:java} > public void OnInboundMessage(InboundMessageDispatch envelope) > { > if (consumers.TryGetValue(envelope.ConsumerInfo.Id, out > NmsMessageConsumer messageConsumer)) > { > messageConsumer.OnInboundMessage(envelope); > } > } > {code} > > > -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Work logged] (AMQNET-610) Race condition during consumer creation
[ https://issues.apache.org/jira/browse/AMQNET-610?focusedWorklogId=310699=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-310699 ] ASF GitHub Bot logged work on AMQNET-610: - Author: ASF GitHub Bot Created on: 11/Sep/19 15:02 Start Date: 11/Sep/19 15:02 Worklog Time Spent: 10m Work Description: HavretGC commented on issue #29: AMQNET-610: Race conditions during consumer creation URL: https://github.com/apache/activemq-nms-amqp/pull/29#issuecomment-530422019 @michaelandrepearce It is ready to merge then. 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: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 310699) Time Spent: 1.5h (was: 1h 20m) > Race condition during consumer creation > --- > > Key: AMQNET-610 > URL: https://issues.apache.org/jira/browse/AMQNET-610 > Project: ActiveMQ .Net > Issue Type: Bug > Components: AMQP, NMS >Reporter: Krzysztof Porebski >Priority: Critical > Time Spent: 1.5h > Remaining Estimate: 0h > > Working on CI I found a race condition that reveals itself on slower machines > and may result in losing messages by consumers. > The race condition is a result of treating the creation of consumer resources > and starting them as an atomic operation: > {code:java} > public async Task Init() > { > await Session.Connection.CreateResource(Info); > await Session.Connection.StartResource(Info); > } > {code} > On slower boxes pending message may be delivered to the provider before above > code returns: > {code:java} > public IMessageConsumer CreateConsumer(IDestination destination, string > selector, bool noLocal) > { > CheckClosed();NmsMessageConsumer messageConsumer = new > NmsMessageConsumer(consumerIdGenerator.GenerateId(), this, destination, > selector, noLocal); > messageConsumer.Init().ConfigureAwait(false).GetAwaiter().GetResult(); > // here may be a race condition > consumers.TryAdd(messageConsumer.Info.Id, messageConsumer); > > return messageConsumer; > } > {code} > If message arrives before `Init` returns (which means before newly created > consumer is added to the list of available consumers), the message will be > ignored. > {code:java} > public void OnInboundMessage(InboundMessageDispatch envelope) > { > if (consumers.TryGetValue(envelope.ConsumerInfo.Id, out > NmsMessageConsumer messageConsumer)) > { > messageConsumer.OnInboundMessage(envelope); > } > } > {code} > > > -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Work logged] (AMQNET-610) Race condition during consumer creation
[ https://issues.apache.org/jira/browse/AMQNET-610?focusedWorklogId=310623=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-310623 ] ASF GitHub Bot logged work on AMQNET-610: - Author: ASF GitHub Bot Created on: 11/Sep/19 13:59 Start Date: 11/Sep/19 13:59 Worklog Time Spent: 10m Work Description: cjwmorgan-sol commented on issue #29: AMQNET-610: Race conditions during consumer creation URL: https://github.com/apache/activemq-nms-amqp/pull/29#issuecomment-530393632 Raised https://issues.apache.org/jira/browse/AMQNET-611, this PR looks fine to me. 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: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 310623) Time Spent: 1h 20m (was: 1h 10m) > Race condition during consumer creation > --- > > Key: AMQNET-610 > URL: https://issues.apache.org/jira/browse/AMQNET-610 > Project: ActiveMQ .Net > Issue Type: Bug > Components: AMQP, NMS >Reporter: Krzysztof Porebski >Priority: Critical > Time Spent: 1h 20m > Remaining Estimate: 0h > > Working on CI I found a race condition that reveals itself on slower machines > and may result in losing messages by consumers. > The race condition is a result of treating the creation of consumer resources > and starting them as an atomic operation: > {code:java} > public async Task Init() > { > await Session.Connection.CreateResource(Info); > await Session.Connection.StartResource(Info); > } > {code} > On slower boxes pending message may be delivered to the provider before above > code returns: > {code:java} > public IMessageConsumer CreateConsumer(IDestination destination, string > selector, bool noLocal) > { > CheckClosed();NmsMessageConsumer messageConsumer = new > NmsMessageConsumer(consumerIdGenerator.GenerateId(), this, destination, > selector, noLocal); > messageConsumer.Init().ConfigureAwait(false).GetAwaiter().GetResult(); > // here may be a race condition > consumers.TryAdd(messageConsumer.Info.Id, messageConsumer); > > return messageConsumer; > } > {code} > If message arrives before `Init` returns (which means before newly created > consumer is added to the list of available consumers), the message will be > ignored. > {code:java} > public void OnInboundMessage(InboundMessageDispatch envelope) > { > if (consumers.TryGetValue(envelope.ConsumerInfo.Id, out > NmsMessageConsumer messageConsumer)) > { > messageConsumer.OnInboundMessage(envelope); > } > } > {code} > > > -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Work logged] (AMQNET-610) Race condition during consumer creation
[ https://issues.apache.org/jira/browse/AMQNET-610?focusedWorklogId=310300=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-310300 ] ASF GitHub Bot logged work on AMQNET-610: - Author: ASF GitHub Bot Created on: 11/Sep/19 04:31 Start Date: 11/Sep/19 04:31 Worklog Time Spent: 10m Work Description: Havret commented on issue #29: AMQNET-610: Race conditions during consumer creation URL: https://github.com/apache/activemq-nms-amqp/pull/29#issuecomment-530123108 Hi Chris, I see where it may come from: https://github.com/apache/activemq-nms-amqp/blob/3c7ecd5c1b11d7211027293e4e4b38f05c21e0d9/src/NMS.AMQP/NmsMessageConsumer.cs#L399-L409 In line 405 we are using AcknowledgementMode property of a session, and there is a check which throws exception when connection is closed. In qpid jms they have this helper method ```isIndividualAcknowledge``` which circumvents the check that sits inside the getter. I remember asking myself during the implementation, why the heck they have this method when they can make the check directly. Apparently I've got my answer. ``` if (acknowledgementMode == Session.CLIENT_ACKNOWLEDGE) { envelope.getMessage().setAcknowledgeCallback(new JmsAcknowledgeCallback(session)); } else if (session.isIndividualAcknowledge()) { envelope.getMessage().setAcknowledgeCallback(new JmsAcknowledgeCallback(session, envelope)); } ``` https://github.com/apache/qpid-jms/blob/94822aced1380bae7935db6305250bf6bea7a9ac/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsMessageConsumer.java#L497-L501 @cjwmorgan-sol Could you be kind enough to file an issue, so it could be fixed in a separate PR? 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: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 310300) Time Spent: 1h 10m (was: 1h) > Race condition during consumer creation > --- > > Key: AMQNET-610 > URL: https://issues.apache.org/jira/browse/AMQNET-610 > Project: ActiveMQ .Net > Issue Type: Bug > Components: AMQP, NMS >Reporter: Krzysztof Porebski >Priority: Critical > Time Spent: 1h 10m > Remaining Estimate: 0h > > Working on CI I found a race condition that reveals itself on slower machines > and may result in losing messages by consumers. > The race condition is a result of treating the creation of consumer resources > and starting them as an atomic operation: > {code:java} > public async Task Init() > { > await Session.Connection.CreateResource(Info); > await Session.Connection.StartResource(Info); > } > {code} > On slower boxes pending message may be delivered to the provider before above > code returns: > {code:java} > public IMessageConsumer CreateConsumer(IDestination destination, string > selector, bool noLocal) > { > CheckClosed();NmsMessageConsumer messageConsumer = new > NmsMessageConsumer(consumerIdGenerator.GenerateId(), this, destination, > selector, noLocal); > messageConsumer.Init().ConfigureAwait(false).GetAwaiter().GetResult(); > // here may be a race condition > consumers.TryAdd(messageConsumer.Info.Id, messageConsumer); > > return messageConsumer; > } > {code} > If message arrives before `Init` returns (which means before newly created > consumer is added to the list of available consumers), the message will be > ignored. > {code:java} > public void OnInboundMessage(InboundMessageDispatch envelope) > { > if (consumers.TryGetValue(envelope.ConsumerInfo.Id, out > NmsMessageConsumer messageConsumer)) > { > messageConsumer.OnInboundMessage(envelope); > } > } > {code} > > > -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Work logged] (AMQNET-610) Race condition during consumer creation
[ https://issues.apache.org/jira/browse/AMQNET-610?focusedWorklogId=310128=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-310128 ] ASF GitHub Bot logged work on AMQNET-610: - Author: ASF GitHub Bot Created on: 10/Sep/19 21:21 Start Date: 10/Sep/19 21:21 Worklog Time Spent: 10m Work Description: Havret commented on issue #29: AMQNET-610: Race conditions during consumer creation URL: https://github.com/apache/activemq-nms-amqp/pull/29#issuecomment-530123108 Hi Chris, I see where it may come from: https://github.com/apache/activemq-nms-amqp/blob/3c7ecd5c1b11d7211027293e4e4b38f05c21e0d9/src/NMS.AMQP/NmsMessageConsumer.cs#L399-L409 In line 405 we are using AcknowledgementMode property of session, and there is a check there which throws exception when connection is closed. In qpid jms they have this helper method ```isIndividualAcknowledge``` which circumvents the check that sits inside the getter. I remember asking myself during the implementation, why the heck they have this method when they can make the check directly. Apparently I've got my answer. ``` if (acknowledgementMode == Session.CLIENT_ACKNOWLEDGE) { envelope.getMessage().setAcknowledgeCallback(new JmsAcknowledgeCallback(session)); } else if (session.isIndividualAcknowledge()) { envelope.getMessage().setAcknowledgeCallback(new JmsAcknowledgeCallback(session, envelope)); } ``` https://github.com/apache/qpid-jms/blob/94822aced1380bae7935db6305250bf6bea7a9ac/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsMessageConsumer.java#L497-L501 @cjwmorgan-sol Could you be kind enough to file an issue, so it could be fixed in a separate PR? 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: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 310128) Time Spent: 1h (was: 50m) > Race condition during consumer creation > --- > > Key: AMQNET-610 > URL: https://issues.apache.org/jira/browse/AMQNET-610 > Project: ActiveMQ .Net > Issue Type: Bug > Components: AMQP, NMS >Reporter: Krzysztof Porebski >Priority: Critical > Time Spent: 1h > Remaining Estimate: 0h > > Working on CI I found a race condition that reveals itself on slower machines > and may result in losing messages by consumers. > The race condition is a result of treating the creation of consumer resources > and starting them as an atomic operation: > {code:java} > public async Task Init() > { > await Session.Connection.CreateResource(Info); > await Session.Connection.StartResource(Info); > } > {code} > On slower boxes pending message may be delivered to the provider before above > code returns: > {code:java} > public IMessageConsumer CreateConsumer(IDestination destination, string > selector, bool noLocal) > { > CheckClosed();NmsMessageConsumer messageConsumer = new > NmsMessageConsumer(consumerIdGenerator.GenerateId(), this, destination, > selector, noLocal); > messageConsumer.Init().ConfigureAwait(false).GetAwaiter().GetResult(); > // here may be a race condition > consumers.TryAdd(messageConsumer.Info.Id, messageConsumer); > > return messageConsumer; > } > {code} > If message arrives before `Init` returns (which means before newly created > consumer is added to the list of available consumers), the message will be > ignored. > {code:java} > public void OnInboundMessage(InboundMessageDispatch envelope) > { > if (consumers.TryGetValue(envelope.ConsumerInfo.Id, out > NmsMessageConsumer messageConsumer)) > { > messageConsumer.OnInboundMessage(envelope); > } > } > {code} > > > -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Work logged] (AMQNET-610) Race condition during consumer creation
[ https://issues.apache.org/jira/browse/AMQNET-610?focusedWorklogId=310125=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-310125 ] ASF GitHub Bot logged work on AMQNET-610: - Author: ASF GitHub Bot Created on: 10/Sep/19 21:15 Start Date: 10/Sep/19 21:15 Worklog Time Spent: 10m Work Description: Havret commented on issue #29: AMQNET-610: Race conditions during consumer creation URL: https://github.com/apache/activemq-nms-amqp/pull/29#issuecomment-530123108 Hi Chris, I see where it may come from: https://github.com/apache/activemq-nms-amqp/blob/3c7ecd5c1b11d7211027293e4e4b38f05c21e0d9/src/NMS.AMQP/NmsMessageConsumer.cs#L399-L409 In line 405 we are using AcknowledgementMode property of session, and there is a check there which throws exception when connection is closed. In qpid jms they have this helper method ```isIndividualAcknowledge``` which circumvents the check that sits inside the getter. I remember asking myself during the implementation, why the heck they have this method when they can make the check directly. Apparently I've got my answer. ``` if (acknowledgementMode == Session.CLIENT_ACKNOWLEDGE) { envelope.getMessage().setAcknowledgeCallback(new JmsAcknowledgeCallback(session)); } else if (session.isIndividualAcknowledge()) { envelope.getMessage().setAcknowledgeCallback(new JmsAcknowledgeCallback(session, envelope)); } ``` https://github.com/apache/qpid-jms/blob/94822aced1380bae7935db6305250bf6bea7a9ac/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsMessageConsumer.java#L497-L501 @cjwmorgan-sol Could you be kind enough to file an issue, so it could be fixed in a separate PR? 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: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 310125) Time Spent: 50m (was: 40m) > Race condition during consumer creation > --- > > Key: AMQNET-610 > URL: https://issues.apache.org/jira/browse/AMQNET-610 > Project: ActiveMQ .Net > Issue Type: Bug > Components: AMQP, NMS >Reporter: Krzysztof Porebski >Priority: Critical > Time Spent: 50m > Remaining Estimate: 0h > > Working on CI I found a race condition that reveals itself on slower machines > and may result in losing messages by consumers. > The race condition is a result of treating the creation of consumer resources > and starting them as an atomic operation: > {code:java} > public async Task Init() > { > await Session.Connection.CreateResource(Info); > await Session.Connection.StartResource(Info); > } > {code} > On slower boxes pending message may be delivered to the provider before above > code returns: > {code:java} > public IMessageConsumer CreateConsumer(IDestination destination, string > selector, bool noLocal) > { > CheckClosed();NmsMessageConsumer messageConsumer = new > NmsMessageConsumer(consumerIdGenerator.GenerateId(), this, destination, > selector, noLocal); > messageConsumer.Init().ConfigureAwait(false).GetAwaiter().GetResult(); > // here may be a race condition > consumers.TryAdd(messageConsumer.Info.Id, messageConsumer); > > return messageConsumer; > } > {code} > If message arrives before `Init` returns (which means before newly created > consumer is added to the list of available consumers), the message will be > ignored. > {code:java} > public void OnInboundMessage(InboundMessageDispatch envelope) > { > if (consumers.TryGetValue(envelope.ConsumerInfo.Id, out > NmsMessageConsumer messageConsumer)) > { > messageConsumer.OnInboundMessage(envelope); > } > } > {code} > > > -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Work logged] (AMQNET-610) Race condition during consumer creation
[ https://issues.apache.org/jira/browse/AMQNET-610?focusedWorklogId=310123=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-310123 ] ASF GitHub Bot logged work on AMQNET-610: - Author: ASF GitHub Bot Created on: 10/Sep/19 21:14 Start Date: 10/Sep/19 21:14 Worklog Time Spent: 10m Work Description: Havret commented on issue #29: AMQNET-610: Race conditions during consumer creation URL: https://github.com/apache/activemq-nms-amqp/pull/29#issuecomment-530123108 Hi Chris, I see where it may come from: https://github.com/apache/activemq-nms-amqp/blob/3c7ecd5c1b11d7211027293e4e4b38f05c21e0d9/src/NMS.AMQP/NmsMessageConsumer.cs#L399-L409 In line 405 we are using AcknowledgementMode property of session, and there is a check there which throws exception when connection is closed. In qpid jms they have this helper method ```isIndividualAcknowledge``` which circumvents the check that sits inside the getter. I remember asking myself during the implementation, why the heck they have this method when they can make the check directly. Apparently I've got my answer. ``` if (acknowledgementMode == Session.CLIENT_ACKNOWLEDGE) { envelope.getMessage().setAcknowledgeCallback(new JmsAcknowledgeCallback(session)); } else if (session.isIndividualAcknowledge()) { envelope.getMessage().setAcknowledgeCallback(new JmsAcknowledgeCallback(session, envelope)); } ``` https://github.com/apache/qpid-jms/blob/94822aced1380bae7935db6305250bf6bea7a9ac/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsMessageConsumer.java#L497-L501 @cjwmorgan-sol Could you be kindly enough to file an issue, so it could be fixed in a separate PR? 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: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 310123) Time Spent: 40m (was: 0.5h) > Race condition during consumer creation > --- > > Key: AMQNET-610 > URL: https://issues.apache.org/jira/browse/AMQNET-610 > Project: ActiveMQ .Net > Issue Type: Bug > Components: AMQP, NMS >Reporter: Krzysztof Porebski >Priority: Critical > Time Spent: 40m > Remaining Estimate: 0h > > Working on CI I found a race condition that reveals itself on slower machines > and may result in losing messages by consumers. > The race condition is a result of treating the creation of consumer resources > and starting them as an atomic operation: > {code:java} > public async Task Init() > { > await Session.Connection.CreateResource(Info); > await Session.Connection.StartResource(Info); > } > {code} > On slower boxes pending message may be delivered to the provider before above > code returns: > {code:java} > public IMessageConsumer CreateConsumer(IDestination destination, string > selector, bool noLocal) > { > CheckClosed();NmsMessageConsumer messageConsumer = new > NmsMessageConsumer(consumerIdGenerator.GenerateId(), this, destination, > selector, noLocal); > messageConsumer.Init().ConfigureAwait(false).GetAwaiter().GetResult(); > // here may be a race condition > consumers.TryAdd(messageConsumer.Info.Id, messageConsumer); > > return messageConsumer; > } > {code} > If message arrives before `Init` returns (which means before newly created > consumer is added to the list of available consumers), the message will be > ignored. > {code:java} > public void OnInboundMessage(InboundMessageDispatch envelope) > { > if (consumers.TryGetValue(envelope.ConsumerInfo.Id, out > NmsMessageConsumer messageConsumer)) > { > messageConsumer.OnInboundMessage(envelope); > } > } > {code} > > > -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Work logged] (AMQNET-610) Race condition during consumer creation
[ https://issues.apache.org/jira/browse/AMQNET-610?focusedWorklogId=309989=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-309989 ] ASF GitHub Bot logged work on AMQNET-610: - Author: ASF GitHub Bot Created on: 10/Sep/19 17:39 Start Date: 10/Sep/19 17:39 Worklog Time Spent: 10m Work Description: cjwmorgan-sol commented on issue #29: AMQNET-610: Race conditions during consumer creation URL: https://github.com/apache/activemq-nms-amqp/pull/29#issuecomment-530044362 Seem pretty good to me however I did find one exception when trying to shutdown a connection with live traffic: PubSubLogger 9/10/2019 12:44:06 PM Error: Exception occurred: Apache.NMS.IllegalStateException: The Session is closed at Apache.NMS.AMQP.NmsSession.CheckClosed() at Apache.NMS.AMQP.NmsSession.get_AcknowledgementMode() at Apache.NMS.AMQP.NmsMessageConsumer.SetAcknowledgeCallback(InboundMessageDispatch envelope) at Apache.NMS.AMQP.NmsMessageConsumer.OnInboundMessage(InboundMessageDispatch envelope) at Apache.NMS.AMQP.NmsSession.OnInboundMessage(InboundMessageDispatch envelope) at Apache.NMS.AMQP.NmsConnection.OnInboundMessage(InboundMessageDispatch envelope) at Apache.NMS.AMQP.Provider.Failover.FailoverProvider.OnInboundMessage(InboundMessageDispatch envelope) at Apache.NMS.AMQP.Provider.Amqp.AmqpConsumer.OnMessage(IReceiverLink receiver, Message amqpMessage) at Amqp.ReceiverLink.OnTransfer(Delivery delivery, Transfer transfer, ByteBuffer buffer) at Amqp.Session.OnTransfer(Transfer transfer, ByteBuffer buffer) at Amqp.Connection.OnFrame(ByteBuffer buffer) I believe this can be fixed by using the Session.SessionInfo.AcknowledgementMode instead of Session.AcknowledgementMode in the Apache.NMS.AMQP.NmsMessageConsumer.SetAcknowledgeCallback method. I tried this and it worked. However, this seems somewhat odd to though as my application called stop on the connection before closing the connection. 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: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 309989) Time Spent: 0.5h (was: 20m) > Race condition during consumer creation > --- > > Key: AMQNET-610 > URL: https://issues.apache.org/jira/browse/AMQNET-610 > Project: ActiveMQ .Net > Issue Type: Bug > Components: AMQP, NMS >Reporter: Krzysztof Porebski >Priority: Critical > Time Spent: 0.5h > Remaining Estimate: 0h > > Working on CI I found a race condition that reveals itself on slower machines > and may result in losing messages by consumers. > The race condition is a result of treating the creation of consumer resources > and starting them as an atomic operation: > {code:java} > public async Task Init() > { > await Session.Connection.CreateResource(Info); > await Session.Connection.StartResource(Info); > } > {code} > On slower boxes pending message may be delivered to the provider before above > code returns: > {code:java} > public IMessageConsumer CreateConsumer(IDestination destination, string > selector, bool noLocal) > { > CheckClosed();NmsMessageConsumer messageConsumer = new > NmsMessageConsumer(consumerIdGenerator.GenerateId(), this, destination, > selector, noLocal); > messageConsumer.Init().ConfigureAwait(false).GetAwaiter().GetResult(); > // here may be a race condition > consumers.TryAdd(messageConsumer.Info.Id, messageConsumer); > > return messageConsumer; > } > {code} > If message arrives before `Init` returns (which means before newly created > consumer is added to the list of available consumers), the message will be > ignored. > {code:java} > public void OnInboundMessage(InboundMessageDispatch envelope) > { > if (consumers.TryGetValue(envelope.ConsumerInfo.Id, out > NmsMessageConsumer messageConsumer)) > { > messageConsumer.OnInboundMessage(envelope); > } > } > {code} > > > -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Work logged] (AMQNET-610) Race condition during consumer creation
[ https://issues.apache.org/jira/browse/AMQNET-610?focusedWorklogId=308868=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-308868 ] ASF GitHub Bot logged work on AMQNET-610: - Author: ASF GitHub Bot Created on: 09/Sep/19 13:48 Start Date: 09/Sep/19 13:48 Worklog Time Spent: 10m Work Description: michaelandrepearce commented on issue #29: AMQNET-610: Race conditions during consumer creation URL: https://github.com/apache/activemq-nms-amqp/pull/29#issuecomment-529483580 LGTM, will give it another 24hrs before merging so @cjwmorgan-sol gets a chance to look 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: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 308868) Time Spent: 20m (was: 10m) > Race condition during consumer creation > --- > > Key: AMQNET-610 > URL: https://issues.apache.org/jira/browse/AMQNET-610 > Project: ActiveMQ .Net > Issue Type: Bug > Components: AMQP, NMS >Reporter: Krzysztof Porebski >Priority: Critical > Time Spent: 20m > Remaining Estimate: 0h > > Working on CI I found a race condition that reveals itself on slower machines > and may result in losing messages by consumers. > The race condition is a result of treating the creation of consumer resources > and starting them as an atomic operation: > {code:java} > public async Task Init() > { > await Session.Connection.CreateResource(Info); > await Session.Connection.StartResource(Info); > } > {code} > On slower boxes pending message may be delivered to the provider before above > code returns: > {code:java} > public IMessageConsumer CreateConsumer(IDestination destination, string > selector, bool noLocal) > { > CheckClosed();NmsMessageConsumer messageConsumer = new > NmsMessageConsumer(consumerIdGenerator.GenerateId(), this, destination, > selector, noLocal); > messageConsumer.Init().ConfigureAwait(false).GetAwaiter().GetResult(); > // here may be a race condition > consumers.TryAdd(messageConsumer.Info.Id, messageConsumer); > > return messageConsumer; > } > {code} > If message arrives before `Init` returns (which means before newly created > consumer is added to the list of available consumers), the message will be > ignored. > {code:java} > public void OnInboundMessage(InboundMessageDispatch envelope) > { > if (consumers.TryGetValue(envelope.ConsumerInfo.Id, out > NmsMessageConsumer messageConsumer)) > { > messageConsumer.OnInboundMessage(envelope); > } > } > {code} > > > -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Work logged] (AMQNET-610) Race condition during consumer creation
[ https://issues.apache.org/jira/browse/AMQNET-610?focusedWorklogId=308564=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-308564 ] ASF GitHub Bot logged work on AMQNET-610: - Author: ASF GitHub Bot Created on: 08/Sep/19 22:51 Start Date: 08/Sep/19 22:51 Worklog Time Spent: 10m Work Description: Havret commented on pull request #29: AMQNET-610: Race conditions during consumer creation URL: https://github.com/apache/activemq-nms-amqp/pull/29 It closes https://issues.apache.org/jira/projects/AMQNET/issues/AMQNET-610 @michaelandrepearce @cjwmorgan-sol Could you please take a look? 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: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 308564) Remaining Estimate: 0h Time Spent: 10m > Race condition during consumer creation > --- > > Key: AMQNET-610 > URL: https://issues.apache.org/jira/browse/AMQNET-610 > Project: ActiveMQ .Net > Issue Type: Bug > Components: AMQP, NMS >Reporter: Krzysztof Porebski >Priority: Critical > Time Spent: 10m > Remaining Estimate: 0h > > Working on CI I found a race condition that reveals itself on slower machines > and may result in losing messages by consumers. > The race condition is a result of treating the creation of consumer resources > and starting them as an atomic operation: > {code:java} > public async Task Init() > { > await Session.Connection.CreateResource(Info); > await Session.Connection.StartResource(Info); > } > {code} > On slower boxes pending message may be delivered to the provider before above > code returns: > {code:java} > public IMessageConsumer CreateConsumer(IDestination destination, string > selector, bool noLocal) > { > CheckClosed();NmsMessageConsumer messageConsumer = new > NmsMessageConsumer(consumerIdGenerator.GenerateId(), this, destination, > selector, noLocal); > messageConsumer.Init().ConfigureAwait(false).GetAwaiter().GetResult(); > // here may be a race condition > consumers.TryAdd(messageConsumer.Info.Id, messageConsumer); > > return messageConsumer; > } > {code} > If message arrives before `Init` returns (which means before newly created > consumer is added to the list of available consumers), the message will be > ignored. > {code:java} > public void OnInboundMessage(InboundMessageDispatch envelope) > { > if (consumers.TryGetValue(envelope.ConsumerInfo.Id, out > NmsMessageConsumer messageConsumer)) > { > messageConsumer.OnInboundMessage(envelope); > } > } > {code} > > > -- This message was sent by Atlassian Jira (v8.3.2#803003)