Re: Pike 8.0: Sql.pgsql objects don't get garbage collected?

"Stephen R. van den Berg" <[email protected]>
Newsgroups gmane.comp.lang.pike.user
Message-ID <[email protected]>
Jeff Hungerford wrote:
>I do still see the "Attempting to clone an unfinished program" error
>from time to time, and I'm not sure what is causing it, but it only
>happens when multiple threads are attempting to open the first connections
>to a database at the same time.

Ok, this gave a me a hint.
The pgsql instantiates its own backend for communicating with the
database truely asynchronously.
It does this by starting exactly *one* backend to be shared amongst all
database connections.

As it seems, there is a race condition in pike when instantiating the same
single object from two different threads, which sometimes results in that
exception.  I've kludged around this now, which hopefully eliminates the
race-exception, but the real fix is in making the cloning code Pike
thread-safe (not provided).

>I've managed to trigger a couple of errors related to acceessing
>objects after they've been destroyed,

Found the reason for that, reasonably simple fix, also eliminates one
system call.

> and one fatal error,
>which I think is likely due to something deeper in how Pike threads
>work, and not directly related to the database driver.

Well, yes and no.  It probably relates to a Mutex lock that is still being
held while the lock itself is destructed, so then the garbage-collector code
attempts to unlock the lock at some point, but then triggers the fatal.
Not quite sure if this is something that should be detected in Pike and
should not result in a fatal.

In any case, the previous fix should most likely eliminate this
destruct race too, so the problem should automatically vanish.

Please retest.
-- 
Stephen.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.