-
Notifications
You must be signed in to change notification settings - Fork 98
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
ACID violation: implicit lose transaction when the connection pool is reopened #209
Comments
I believe that it affects all types of Database classes, since they all use the same mechanism of re-connection (and pools from driver) |
related to #123 |
@rodion-solovev-7 i merged your test into master with skip param #210. Thank you. I hope we can fix it some time :) Also i tried to cancel transaction tasks. async def close_async(self):
"""Close async connection.
"""
if self._async_wait:
await self._async_wait
if self._async_conn:
conn = self._async_conn
self._async_conn = None
self._async_wait = None
self._task_data = None
if self._task_data is not None:
for data in self._task_data.data.values():
# i had addded code to save task into _task_data
data['task'].cancel()
await conn.close() The test had been passed. All i can say :) |
@kalombos, Thank you for your response. But I'll be watching for official fix too :) |
Some news guys. Have a look at these problems that i found. And this commit should fix them including the issue. The test is green now :) |
What the hell?
Let's imagine that we have a web server intensively processing 8+ parallel requests by a handler like this:
The code above relies on transactionality: delayed transfer task should only be created with corresponding historical record. And most of the time it will work as expected...
But in some rarely cases, this can lead to creation of delayed task without corresponding historical record.
This happens completely implicitly. You may not even see the corresponding error.
When it occurs?
peewee-async==0.9.1
Pooled*Database
(example:peewee_async.PooledPostgresqlDatabase
)asyncio.Task
with running SQL queriesHow to reproduce
Environment:
. venv/bin/activate python3.8 -m venv venv pip install peewee==3.16.3 peewee-async==0.9.1 aiopg==1.3.1 psycopg2-binary==2.9.1 pytest==6.2.3 pytest-aiohttp==0.3.0
Test:
The text was updated successfully, but these errors were encountered: