Skip to content

[WIP] Fix: Corrected and optimized pdo_firebird transaction handling. - #12657

Closed
SakiTakamachi wants to merge 8 commits into
php:masterfrom
SakiTakamachi:fix/pdo_firebird_transation
Closed

SakiTakamachi wants to merge 8 commits into
php:masterfrom
SakiTakamachi:fix/pdo_firebird_transation

Conversation

@SakiTakamachi

@SakiTakamachi SakiTakamachi commented Nov 12, 2023 •

Copy link
Copy Markdown
Member

Follow up #12545

Firebird doesn't have anything like an autocommit mode, so we need to implement such behavior on the pdo side. Also, whatever we do with firebird, we must operate within a transaction.

This means that in many cases a transaction must already be started in order to achieve autocommit mode.


To begin with, I'm a little doubtful that there's a need to emulate autocommit mode with pdo since it doesn't exist in firebird. I'm starting to feel like it's okay to decide that autocommit mode is not supported.

I was able to implement it

@SakiTakamachi

SakiTakamachi commented Nov 12, 2023 •

Copy link
Copy Markdown
Member Author

Some tests failed. It seems there is still room for improvement.


done

@SakiTakamachi
SakiTakamachi marked this pull request as draft November 12, 2023 15:59
@SakiTakamachi

SakiTakamachi commented Nov 12, 2023 •

Copy link
Copy Markdown
Member Author

Hmm. The timeout may be caused by starting a transaction in the constructor.

It seems likely that I will either have to allow a timeout or change the implementation.

I am implementing this to reduce the overhead when starting a transaction, but I think I need to think about it a bit.


Maybe it's because the mock server doesn't assume transactional operations. For this test, I try turning off autocommit.


done

@SakiTakamachi
SakiTakamachi marked this pull request as ready for review November 13, 2023 02:59
@SakiTakamachi

Copy link
Copy Markdown
Member Author

@Girgias
All the changes I think are necessary have been completed. Could you review it?

@SakiTakamachi
SakiTakamachi force-pushed the fix/pdo_firebird_transation branch from e7e52c3 to 10b02c5 Compare November 13, 2023 03:27
@SakiTakamachi

SakiTakamachi commented Nov 13, 2023 •

Copy link
Copy Markdown
Member Author

The existing tests now pass, but this implementation deadlocks easily....
My verification method was bad. I deadlocked even without using autocommit.

@SakiTakamachi

Copy link
Copy Markdown
Member Author

There doesn't seem to be a fix anymore.

@SakiTakamachi
SakiTakamachi marked this pull request as draft November 17, 2023 02:22
@SakiTakamachi SakiTakamachi changed the title Fix: Corrected and optimized pdo_firebird transaction handling. [WIP] Fix: Corrected and optimized pdo_firebird transaction handling. Nov 17, 2023
@SakiTakamachi

Copy link
Copy Markdown
Member Author

It seems better to merge the error handling changes first, so I'll make this a draft.

Girgias pushed a commit that referenced this pull request Nov 27, 2023
take2 of #12657

## About Firebird transaction

Firebird is a full transactional database, so the DB itself does not support autocommit mode. (Strictly, there is an autocommit mode, but it is a different concept from the "autocommit" that we are used to with MySQL and others.)

Therefore, a transaction must have started before any operation is performed, and autocommit mode had to be emulated in PHP.

I made sure that a transaction always exists when in autocommit mode. Since the `in_transacntion` function does not work as expected, I have introduced `H->in_manually_txn` to determine whether a transaction is being manually manipulated.

## There are two types of commit/rollback

(I'm not talking about two-phase commit. This change does not take into account two-phase commit.)

There are `isc_commit_retaining` which starts a transaction again in the same context immediately after committing, and `isc_commit_transaction` which closes the transaction as is.

Similarly, there are two types of rollback.

-----------

Due to the default value of the transaction isolation level, autocommit mode may obtain unintended results.
Regarding this, it would be too large to include support for transaction isolation levels in this PR, so I will leave it as is for now.
@SakiTakamachi
SakiTakamachi deleted the fix/pdo_firebird_transation branch December 15, 2023 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant