Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, I agree with the previous posters and commenters - normally, you shouldn't be getting segfaults from this situation, and a proper fix is figuring out why it segfaults and correcting (could very well be a library bug as Jonathan said).</p> <p>HOWEVER, to answer your direct technical question, you can NOT recover a Perl interpreter (or any other program for that mater) once it segfaults. You wouldn't WANT to anyway - it is likely in a messy state. </p> <p>Therefore you solve your problem via a "backup" mechanism of a second process ready to pick up the shattered pieces and make sure that the show goes on, as follows:</p> <ul> <li><p>Just prior to attempted DB connection, you fork off a child process.</p> <p>Please note that you may need to daemonize the child process right after forking, as the parents death can kill the child. It's ~2am so my brain's too asleep to be sure whether it's the case or not. If that's the case, daemonization was covered numerous times on SO.</p></li> <li><p>The parent process attempts the DB connection, <strong>timed out</strong> by a standard Perl alarm (set to, say 10 seconds or whatever you want).</p></li> <li><p>If the connection was successful, it sends a signal to a child to indicate that DB connection is OK, and the parent code can proceed as usual.</p> <p>If the connection fails, the parent either coredumps, or issues a <code>die</code> assuming the connection failed in non-coredump way or timed out.</p></li> <li><p>The child process, right after forking, sets the signal handler to catch the parent's "DB connection successful" signal, and then sets the alarm for 10+<em>epsilon</em> seconds.</p></li> <li><p>If the child process catches the parent's "DB connection successful" signal, the child process dies.</p></li> <li><p>On the other hand, if the child process alarm handler is triggered, it means the parent couldn't connect to DB. Therefore, the child process sends a signal to parent "I am about to do the fail-over"; and then execute the fail-over logic as needed</p></li> </ul> <p>The above logic is very rough, it may need to be refined to deal with race conditions, perhaps by virtue of a lock obtained by both processes before using the data.</p> <p><strong>UPDATE</strong></p> <p>As noted in the comments, a variation of the above where the CHILD process tries to establish a DB connection and the parent process catches problems and acts as a fall-back may be somewhat easier to implement.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload