Skip to content

Error: cannot use Connection.transaction() in a manually started transaction #93

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

Open
sheldygg opened this issue Apr 15, 2025 · 8 comments
Labels
backend Feature to manage backend connections bug Something isn't working

Comments

@sheldygg
Copy link

sheldygg commented Apr 15, 2025

Hi, after #81 Pull Requests I start receive this error InterfaceError('cannot use Connection.transaction() in a manually started transaction')
After that I temporarily stopped using your pooler, can you tell me if you have made any changes recently that could affect the logic? I need a pooler urgently but I am not sure if you fixed this problem.

pgdog.toml

[general]
host = "0.0.0.0"
port = 6433
shutdown_timeout = 100
idle_healthcheck_delay = 100000000000
default_pool_size = 200

[admin]
password = ""

[[databases]]
name = ""
host = "127.0.0.1"

[[databases]]
name = ""
host = "127.0.0.1"

[[databases]]
name = ""
host = "127.0.0.1"

Image

@levkk
Copy link
Collaborator

levkk commented Apr 15, 2025

I'll take a look, thanks for reporting the issue.

Could you provide a few lines of code from your app that cause the error?

@levkk levkk added bug Something isn't working backend Feature to manage backend connections labels Apr 15, 2025
@sheldygg
Copy link
Author

Yes, I have created one async_sessionmaker and open session for some event like this

async with sessionmaker() as session:
    result = await self.session.get(UserModel, user_id)
Image

@levkk
Copy link
Collaborator

levkk commented Apr 15, 2025

I added a test. Couldn't catch your error though, SQLALchemy kept catching me trying to start another transaction with an active session, so I couldn't get to the error thrown by asyncpg.

If you can provide the code to reproduce, please add it to the test above and send a PR over.

@sheldygg
Copy link
Author

Okay, I will try.

@levkk
Copy link
Collaborator

levkk commented Apr 15, 2025

Cool, thanks. You can probably use your existing config, I just need a piece of code that runs and reproduces the error that I can run on my side.

@sheldygg
Copy link
Author

I tried using the pgdog again and encountered the same error again, I tried to create a minimally reproducible example but unfortunately I didn't succeed :(

@levkk
Copy link
Collaborator

levkk commented Apr 23, 2025

Ah, that's unfortunate. Okay, I'll keep digging, maybe I'll find something. In the meantime, could you run pgdog with export RUST_LOG=trace and send me the output? Maybe we'll get a hint about what's going on in the logs.

@sheldygg
Copy link
Author

sheldygg commented Apr 23, 2025

Ok, I will try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Feature to manage backend connections bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants