ID: 21513 Comment by: jsphp at kanargh dot force9 dot co dot uk Reported By: ceeam at mail dot ru Status: Assigned Bug Type: Scripting Engine problem Operating System: win32 (only) PHP Version: 4CVS, 5CVS Assigned To: zeev New Comment:
HUP. Just came across this today. As the leading comment says, this is really bad for DB transactions. I had originally assumed that when a page dies for whatever reason, in the middle of an uncommitted transaction on a non-persistent pgsql connection, the transaction would be rolled back - but in fact it is implicitly committed. (So a series of many INSERTs will be half-complete, and you can't just hit Back and try again 'cos you'll get duplication.) This is bad enough - unclosed transactions ought not to be committed if you don't know whether they were complete or not - in fact only an explicitly coded COMMIT statement should change the database state. So I looked through the help and found register_shutdown_function, implemented one and relaxed again. Only to find that the timeout causes the shutdown function to abort too, so there doesn't appear to be any way to not balls up the database :-( Does PHP itself complete the transaction, or is it likely that PostgreSQL is doing this itself when the connection is dropped? If the former this is another bug in PHP, if the latter (which given the lack of PHP API support for transactions seems likely) I may well throw it over to their bugtracker too. But the register_shutdown_function issue does need fixing. Apache/2.0.48 (Win32) PHP/4.3.4 PostgreSQL 7.4.1 Previous Comments: ------------------------------------------------------------------------ [2003-08-04 00:24:07] wmeler at wp-sa dot pl This is related to http://bugs.php.net/bug.php?id=16820 (see comment from 21 Jul 2:46am CDT) You can find my patch at http://strony.wp.pl/wp/wmeler/. These are old issues ... ------------------------------------------------------------------------ [2003-01-22 22:44:36] [EMAIL PROTECTED] I can not reproduce this with PHP CGI/CLI/Apache DSO, but Steph tested the script under windows and got the same results as [EMAIL PROTECTED] did so this is definately a windows-only bug. ------------------------------------------------------------------------ [2003-01-22 02:09:49] ceeam at mail dot ru [EMAIL PROTECTED]: > This script works just fine for me (using CLI): > [skipped] I tested your script. The output is: PHP Fatal error: Maximum execution time of 1 second exceeded in c:\exp.php on line 16 PHP Fatal error: Maximum execution time of 1 second exceeded in c:\exp.php on line 7 "test.log" contains only one "Start" line. I tried with both my own (pretty much cleaned up) php.ini and "recommended" php.ini. I suspect it is only Windows-related problem. ------------------------------------------------------------------------ [2003-01-20 22:47:06] [EMAIL PROTECTED] And this is related to http://bugs.php.net/bug.php?id=14542 (and maybe to http://bugs.php.net/bug.php?id=14251 ?) ------------------------------------------------------------------------ [2003-01-20 22:44:38] [EMAIL PROTECTED] This script works just fine for me (using CLI): <?php error_log ("Start\n", 3, "test.log"); function boo() { error_log ("Shutdown - function 'foo'\n", 3, "test.log"); } register_shutdown_function("boo"); /* not necessary, just to show the error sooner */ set_time_limit(1); /* infinite loop to simulate long processing */ for (;;) {} error_log ("\nEnd\n", 3, "test.log"); ?> In test.log I have now: ----cut---- Start Shutdown - function 'foo' ----cut---- Which is the expected output. Can you try this script? ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/21513 -- Edit this bug report at http://bugs.php.net/?id=21513&edit=1