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

JMS: Tombstone the message handling on abort (#904) #905

Merged
merged 1 commit into from
May 7, 2018

Conversation

akara
Copy link
Contributor

@akara akara commented Apr 22, 2018

... and validate the TxEnvelope on commit/rollback - hopefully at no or very minimal performance impact.

Unfortunately, cannot recreate issue on unit-test broker. Can consistently recreate issue on same 'abort message loss' test with our internal broker.

@ennru ennru changed the title Tombstone the message handling on abort (#904) JMS: Tombstone the message handling on abort (#904) Apr 23, 2018
@ennru ennru added the p:jms label Apr 23, 2018
@ennru
Copy link
Member

ennru commented Apr 23, 2018

What JMS broker do you use for testing? We could run a Docker image with a JMS broker instead of the embedded ActiveMQ.

@akara
Copy link
Contributor Author

akara commented Apr 23, 2018

Unfortunately, it is a highly customized version of ActiveMQ on both client and broker. Not something I can make available. In debugging this issue, we need to determine whether it is the bug in that infrastructure or on the Alpakka implementation. Looks like I have to go by reasoning on this one.

@akara
Copy link
Contributor Author

akara commented Apr 25, 2018

What it turns out to be is that the session stop is not stopping the session immediately in our client, but after a few message cycles. The message held by the session at the time (based on the current code) is rolled back, but as the message handling did not stop, the next message is delivered downstream. The downstream still holds the TxEnvelope for that message we rolled back and subsequently calls commit on that envelope. The current message in the session now has changed to the next message already. So the commit call actually committed the new message that should not have been committed.

This is the reason for the proposed change. Once we abort, we ensure no more messages are handled, neither commit nor rollback. This is achieved by the tombstone. Also we want to make sure we always commit on the right message. So we pass the envelope down to be checked against the current message envelope to provide that level of validation.

The only way we can try and see whether we can recreate is to move back to an older version of the ActiveMQ broker AND client library (yes, what we're using is based on a pretty old version) and see whether we can reproduce. Not 100% sure, though.

@ennru
Copy link
Member

ennru commented Apr 26, 2018

Ok, I understand the problem you're solving now.
I think it would be good to explain the "Tombstone" in the code somehow. How should the JMS exception thrown for an unexpected TX envelope be handled?

@akara
Copy link
Contributor Author

akara commented Apr 26, 2018

Sure. Let me add these comments in the code to make it clear. Thanks!

@akara akara force-pushed the tx-abort-message-loss branch from d4a6cf7 to 6ef2b11 Compare April 27, 2018 17:00
@akara
Copy link
Contributor Author

akara commented Apr 27, 2018

Just updated the code to make the envelope validation using require() so it is clear. If validation fail, we fail the source stage and signal that IllegalArgumentException to the output port. Also added comments on the tombstone, which manifests itself as a StopMessageListenerException thrown and a catch block in the message handling loop to stop consuming.

@akara
Copy link
Contributor Author

akara commented Apr 27, 2018

Build is failing for unrelated issues. Unfortunately, I can't restart the build.

Copy link
Member

@ennru ennru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@ennru ennru added this to the 0.19 milestone May 7, 2018
@2m 2m merged commit 342f8c3 into akka:master May 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants