I often use the 'R' command of the perl debugger in order to restart my
program.  This works by re-exec-ing the debugger.  The problem is that
any database connections I have open remain open, keeping transactions
alive, and thus blocking subsequent activity.  I observe this problem
with DBD::Pg and DBD::Sybase (with FreeTDS) in Perl 5.8.3.

I can think of several potential solutions, but I'm not sure which is
the most promising:

- Have the database drivers set the close-on-exec flag of the fd used to
  connect to the database.  This makes sense to me, because after an
  exec, there is usually no way to recover the connection (does any
  database library allow this?).  It would seem that this should be done
  by the native (C) client library, rather than the DBD wrapper, but it
  could be done in the DBD as a work-around.  On the other hand, Perl
  likes to set close-on-exec on fds opened within perl, so maybe DBDs
  should do the same.  Can anyone think of a reason not to set
  close-on-exec, and do you have an opinion of where it should be done?

- Have the debugger close all open filehandles, other than the standard
  ones and internal ones, before re-exec-ing.  This might be the
  simplest.  Does anyone depend on filehandles remaining open across
  debugger restarts?

- Have the debugger run all destructors before re-exec-ing, which will
  cause all connections to be closed cleanly.  I don't know this is even
  possible within perl, and it carries the usual issues with global
  destruction, but if it can be done it should work.

Opinions?

Andrew

Reply via email to