-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
fix(transaction): transaction is never released #50
Conversation
Hm 🤔 commit doesn't decrement the refCount, is it supposed to? |
decrementing the refCount on commit/rollback also fixes this problem, so I'm not sure which one is the correct fix. |
Yes, it does in v1, seems that was overlooked when upgrading to v2. |
08ef3fd
to
31f49f7
Compare
Signed-off-by: azjezz <[email protected]>
tests are passing locally 🎉 |
$result = $transaction->query("DELETE FROM test"); | ||
unset($result); | ||
$transaction->rollback(); | ||
|
||
try { | ||
$transaction->execute("SELECT * FROM test"); | ||
$this->fail('Query should fail after transaction commit'); | ||
} catch (TransactionError $exception) { | ||
// Exception expected. | ||
} | ||
|
||
$this->assertTrue($this->link->isAlive()); | ||
|
||
$result = $this->link->execute('SELECT * FROM test WHERE domain = ?', [$data[0]]); | ||
self::assertSame(1, $result->getRowCount()); | ||
unset($result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this still feels buggy to me, even tho it's consistent with v1.
If we remove unset($result) in line 571, we still get the same error, as in line 583, the query is executed before $result
is destructed, so the transaction is not yet released.
wdyt @trowski?
Given the following example:
Prior to this change, i encounter the following error:
Now, this works as expected:
( note: the example above uses the v2 branch, but i'm assuming the issue is also present in v1 )