-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Class cast exception obtaining Observation
context on abortTransaction
completion
#4481
Comments
If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal yet complete sample that reproduces the problem. |
Of course. The stack trace:
And the sample project: https://github.com/worldtiki/mongo-test/tree/main You can either run This file is also relevant as it contains the Observation and Transaction configurations. |
Thanks a lot for the reproducer. The problem comes from the failed We can avoid such exceptions by checking whether the current context points at a MongoDB operation. |
Observation
context on abortTransaction
completion
Refactor duplicate code into callback. See #4481
…text. We now no longer attempt to complete the Observation if the context is not a MongoDB one. For commands that target the admin database and run within a parent observation, we still might have an Observation but that one points to the parent invocation and not the MongoDB one as we do not record commands for the admin database. Closes #4481
Refactor duplicate code into callback. See #4481
…text. We now no longer attempt to complete the Observation if the context is not a MongoDB one. For commands that target the admin database and run within a parent observation, we still might have an Observation but that one points to the parent invocation and not the MongoDB one as we do not record commands for the admin database. Closes #4481
Refactor duplicate code into callback. See #4481
Thank you @mp911de |
When using transactions, the MongoObservationCommandListener.commandSucceeded() is executed twice.
The 1st time, it tries to cast the observation context to a
MongoHandlerContext
(and succeeds), but the 2nd time, which is executed in the context of the commit of the transaction, this cast fails with an exceptionThis seems to be on purpose, at least according to this comment, which is what causes the
MongoHandlerContext
to never be created.Should there be a bit of defensive code to avoid force casting the context into a
MongoHandlerContext
?The text was updated successfully, but these errors were encountered: