Bug #78930 [Com]: PDO Sqlite not close connection after destruction (windows only)

From: Date: Sun, 08 Dec 2019 20:08:24 +0000
Subject: Bug #78930 [Com]: PDO Sqlite not close connection after destruction (windows only)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224140@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78930&edit=1 ID: 78930 Comment by: julien dot boudry at gmail dot com Reported by: julien dot boudry at gmail dot com Summary: PDO Sqlite not close connection after destruction (windows only) Status: Not a bug Type: Bug Package: PDO SQLite Operating System: Windows only PHP Version: 7.4.0 Block user comment: N Private report: N New Comment: Okay, I see and it works in this simple example. But if the use of gc_collect_cycles() already appears a bit like a hack. That the addition of the presence of a destructor changes the way properties are cleaned still seems to me to be counter-intuitive (and not documented to my knowledge). Now, in a much more complex code like the one I initially had a problem with. With many circular references and destructors everywhere. The problem is then more serious. I had already tried the gc_collect_cycles() without success. But I can't clean all the properties by hand, because it makes the code unnecessarily verbose, but also because the call order of the destroyers is not guaranteed "in any order during the shutdown sequence. " (from official doc.) and that point produce others problems. Previous Comments: ------------------------------------------------------------------------ [2019-12-08 19:55:59] requinix@php.net I see now, the behavior is a bit different. That prepared statement you created is keeping the SQLite resource in use. You have to unset $base as well as $prepare. ------------------------------------------------------------------------ [2019-12-08 19:39:41] julien dot boudry at gmail dot com You're right, exactly the same, it's working. But. If I had a destructor (and change a visibility), it fails again. Look only the last revision here (or the last version). https://gist.github.com/julien-boudry/6672e4e98e48b14fc6a6871942a6ef2b/revisions ------------------------------------------------------------------------ [2019-12-08 19:27:53] requinix@php.net > Even if I add gc_collect_cycles(); just before last line with unlink call. It's not > working better. > I do not seem to have any convincing solution for my use case. Adding gc_collect_cycles() works for me. Are you running the *exact* code you posted but with a gc_collect_cycles(); added immediately before the unlink()? ------------------------------------------------------------------------ [2019-12-08 19:22:03] julien dot boudry at gmail dot com Hi, Even if I add gc_collect_cycles(); just before last line with unlink call. It's not working better. I do not seem to have any convincing solution for my use case. I would like to make it clear that if I do not produce any circular references. Then the unlink works correctly under windows. ------------------------------------------------------------------------ [2019-12-08 19:12:51] requinix@php.net Windows does not allow deleting files while there are open handles to it. Linux does. Clean up the circular reference with gc_collect_cycles(). https://www.php.net/manual/en/features.gc.php ------------------------------------------------------------------------ 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 https://bugs.php.net/bug.php?id=78930 -- Edit this bug report at https://bugs.php.net/bug.php?id=78930&edit=1

« previous php.bugs (#224140) next »