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

integrations: aioredis creates coroutines that do not execute for sync operations #623

Closed
vishal-wadhwa opened this issue Sep 18, 2022 · 3 comments

Comments

@vishal-wadhwa
Copy link

vishal-wadhwa commented Sep 18, 2022

Description

In order to record Redis database transactions via aioredis client library, we upgraded the newrelic python agent from v7.4.0.172 to v7.16.0.178

Service degradation was observed as the update was rolled out in production.
The cause was that the newrelic wrapped aioredis functions for Pipelines were failing to execute.

To me, it seems that the new aioredis integration is wrapping all of the functions with async and effectively returning a coroutine while the original implementation returns an Awaitable (Pipeline) always, that need not be awaited immediately.

Since aioredis supports both sync and async callbacks in the transaction function, the newrelic package should too.

Refer to the reproducible example below.

Expected Behavior
All functions to work the same as without newrelic integrations. The functionality should not break.

Troubleshooting or NR Diag results
This log was printed to stderr when aioredis pipeline set was used in a transaction.

RuntimeWarning: coroutine '_wrap_AioRedis_method_wrapper.<locals>._nr_wrapper_AioRedis_method_' was never awaited 

Steps to Reproduce
Instructions and repro here -
https://gist.github.com/vishal-wadhwa/337ff7c7e3146ede0849cbbbfff107b0

Your Environment
Not relevant. Reproducible in all environments.

Additional context
NA

@vishal-wadhwa vishal-wadhwa changed the title integrations/aioredis: Leaks and creates coroutines that do not execute for sync operations integrations: aioredis creates coroutines that do not execute for sync operations Sep 18, 2022
@TimPansino
Copy link
Contributor

We can reproduce and confirm this is an issue, we'll get a patch out soon to avoid breaking the underlying package functionality.

Unfortunately full transaction support is a bit large for a patch and would be a new feature. It will need some development time so for the time being transactions will function but won't send up any telemetry data while we work to support them.

@guillemfrancisco
Copy link

Is this really fixed? Still seeing this error with latest library release...

I'm using FastApi with aioredis to build a realtime application with pub/sub pattern. On FastApi startup I create an asyncio task that subscribes to a redis channel pattern.

However when using the latest release I'm facing similar issue as @vishal-wadhwa , I get AttributeError: 'coroutine' object has no attribute 'psubscribe' . But if instead I use an older version such as newrelic==7.4.0.172 everything works perfectly!

@lrafeei
Copy link
Contributor

lrafeei commented Aug 14, 2023

The latest release of the agent should have a fix for this issue. If this is still an issue for you with the latest version (v8.10.0), we can reopen this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants