-
Notifications
You must be signed in to change notification settings - Fork 8k
Implements check_liveness for pdo_firebird #5555
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
Conversation
The code looks reasonable. Is there a way you could add a .phpt test that confirms the expected behavior? I realize testing on live connections is tricky, that this would be more of an integration test than a unit test, but we try to get this kind of coverage on the pdo extensions. |
I based my code on the official firebird driver and tested it manually, sorry, but I don't know how to do unit testing. https://github.com/FirebirdSQL/php-firebird/blob/master/interbase.c -> line 971 if ((le = zend_hash_str_find_ptr(&EG(persistent_list), hash, sizeof(hash)-1)) != NULL) { |
My test was to create a loop that queries a table and then manually delete the connections from the MON$ATTACHMENTS table and see if it detected that the connection died Edit: the loop calls an restAPI |
I made a test file, it was really ugly but it worked :) |
News on this PR? |
the solution works, runs on my server and solved the problem here. |
Could you rebase this on latest master? |
@Girgias |
Windows fails with: ========DIFF========
001+ Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error in C:\projects\php-src\ext\pdo_firebird\tests\liveness.php:4
001- done
002+ Stack trace:
003+ #0 C:\projects\php-src\ext\pdo_firebird\tests\liveness.php(4): PDO->exec('DROP TABLE test...')
004+ #1 {main}
005+ thrown in C:\projects\php-src\ext\pdo_firebird\tests\liveness.php on line 4
========DONE========
FAIL PDO_Firebird: Check persistent conection is alive [C:\projects\php-src\ext\pdo_firebird\tests\liveness.phpt]
=====================================================================
TIME END 2023-01-05 14:50:23 @cmb69 could you have a look? |
The basic problem is that the default error mode is $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$dbh->exec('DROP TABLE testz');
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); Or, probably better (also as a step to be able to run these tests in parallel) use a unique table name according to the test name (i.e. But why didn't that fail in the other CI runs? Because the pdo_firebird tests are skipped there: <testsuite name="php.ext.pdo.firebird.tests" tests="112" failures="0" errors="0" skip="98" time="3.7339"> For instance, because of <testcase name='ext/pdo_firebird/tests/bug_47415.phpt (Bug #47415 PDO_Firebird segfaults when passing lowercased column name to bindColumn())' time='0.0582'>
<skipped>: PDO_FIREBIRD_TEST_DSN must be set</skipped>
</testcase> and <testcase name='ext/pdo_firebird/tests/bug_34630.phpt (FIREBIRD PDO Common: Bug #34630 (inserting streams as LOBs))' time='0.1020'>
<skipped>SQLSTATE[HY000] [335544721] Unable to complete network request to host "localhost".</skipped>
</testcase> I suggest to fix CI before proceeding with this PR. |
There has not been any recent activity in this PR. It will automatically be closed in 7 days if no further action is taken. |
the PDO-firebird does not check if the connection is alive when persistent connections are used and that was generating the error:
SQLSTATE [HY000]: General error: -902 Error writing data to the connection.