-
Notifications
You must be signed in to change notification settings - Fork 561
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
Redis 4.x.x instrumentation causes application to crash when watched keys change as errors are thrown twice #1708
Comments
Seeing the same behavior on node 16 as well. |
The only two places we use try {
await getClient().executeIsolated(async (client) => {
await client.watch(`lock`);
const owner = await client.get(`lock`);
return await client.multi().set(`lock`, ..., { PXAT: ... }).exec();
});
} catch (err) {
if (err instanceof WatchError) throw new LockInUseError();
} But our application crashes because of an uncaught |
I managed to patch this in a fork, but I'm unsure if it's the right way to proceed. In
So a solution to our problem was to add Thus we can catch the exception from running |
@blumamir do you have any insights into this? I see that you're a frequent contributor to this package:) |
I've created a PR to more clearly show what fixes the issue for us. Would you be able to confirm it fixes it for you as well, @drob? |
I think I have a fix. Details in a bit. @pichlermarc I'm a member of the OTel org now. Should that mean I should be able to assign myself to this issue? |
@FredrikAugust Thanks very much for your PR, it provides a repro and the source of the problem. 1. the crashThis is the wrapper for private _getPatchMultiCommandsExec() {
const plugin = this;
return function execPatchWrapper(original: Function) {
return function execPatch(this: any) {
const execRes = original.apply(this, arguments);
// ...
execRes
.then((redisRes: unknown[]) => {
const openSpans = this[OTEL_OPEN_SPANS];
// ...
for (let i = 0; i < openSpans.length; i++) {
// ...
plugin._endSpanWithResponse(...)
}); The issue is that if the You are right that it can be suppressed, as you did in your patch by adding an empty 2. the
|
…) handling The instrumentation was not handling a rejection of the promise from client.multi(), resulting in unended spans and an unhandleRejection event. Fixes: open-telemetry#1708
I think only approvers and maintainers (users write-access to repo) can do that, I assigned you :) |
@trentm Thanks a lot for the great explanations! I arrived at the same conclusions so happy to see that I wasn't completely lost:) Apologies for not updating the issue as I understood the problem(s) in greater detail. As for the second issue I saw that it will change between "multi" and "MULTI" depending on what redis SDK version you're running. This can be observed by running the test suite for this repo. So I assume it's trying to patch both of the commands (even though they're the same?) and soft-fails when it can't find the "other"? |
Yes, exactly. In #1729 I change it to only attempt to patch |
Thanks for the great work, @trentm!<3 |
I only had the Thank you, @trentm!! |
What version of OpenTelemetry are you using?
Using the image
otel/opentelemetry-collector-contrib:0.83.0
What version of Node are you using?
Node 18.17.1
What did you do?
We use the auto-instrumentation to instrument our application, and this correctly injects redis-4. We use the
multi
command throughout our application.What did you expect to see?
When a watched key changes within a
multi
command we expect it to behave the same way as it would without the instrumentation.What did you see instead?
If we enable the instrumentation, we see a message
Printed to the console when we start the application, and the application will crash when a watched key changes in a
multi
command. This does not happen if we disable the instrumentation.Additional context
#1672
This issue is related as it requests the ability to disable a single instrumentation, and it is where we first identified the issue.
The text was updated successfully, but these errors were encountered: