Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,guys

I'm working on a Catalyst project involving DB usage and I've noticed a strange and probably buggy behaviour when using the built-in HTTP server engine.

Firstly, here are version details: Perl 5.10 on Linux (SuSE), Catalyst v5.80032, Catalyst::Model::DBI v0.28, Oracle 10g on a remote server

I have reduced my issue to the simplest one: I have built an absolutely new Catalyst application (just "catalyst.pl MyApp") + TT view, then I have added a new Catalyst::Model::DBI model:

  ./script/dummy_create.pl model DB DBI dbi:Oracle:DUMMY

The config from the model:

__PACKAGE__->config( dsn => 'dbi:Oracle:DUMMY', username => 'dummyuser', password => 'dummypass', options => { AutoCommit => 1 }, );

And only one method in the 'DB.pm' model:

sub dummyMethod { my ( $self, $id ) = @_; my $r = $self->dbh->selectrow_hashref("SELECT id, name FROM us +ers WHERE id = $id"); return $r; }

Inside the 'index' action of the Root.pm controller I just put a call to this dummyMethod() and the result is dump'ed

sub index :Path :Args(0) { my ( $self, $c ) = @_; my $data = $c->model("DB")->dummyMethod(12); $c->stash->{data} = Data::Dump::pp($data); $c->stash->{template} = 'homepage.tt2'; }

Now about the behaviour. Everything works fine (I mean it's possible to access the application as it should, it returns the dump'ed data and so on) except the restarting procedure. If I launch the application and I do not access it at all, then Catalyst is restarting the application correctly on every code change. If I launch the app and I access it at least once, Catalyst will not be able to restart the app if a change in the code is made, it just prints out:

    Attempting to restart the server

and is waiting in this state.

I have to kill the perl processes manually to be able to launch again my app. When I'm not using database connections (a self-sufficient standalone app), it is restarting correctly every time

So, what do you think? am I doing smth wrong? or a Catalyst bug? or maybe a Catalyst::Model::DBI bug? any ideas?

Replies are listed 'Best First'.
Re: built-in Catalyst server restarting issue
by Your Mother (Archbishop) on Nov 07, 2011 at 14:50 UTC

    I’m not an Oracle dev but I suspect the connection is what’s hanging you up. A possible place to start is adding RaiseError so you might have a better chance to see what’s happening. Generally, you should never use DBI without RaiseError or, at the least, PrintError set.

    options => { AutoCommit => 1, RaiseError => 1, },

      (it's me, the original author of the thread, just logged in)

      Thank you for your reply, but RaiseError changed nothing (well, it shouldn't change anything as I know, only report errors) and it didn't report anything:

      Saw changes to the following files: - /path_to_my_project/MyProject/lib/MyProject/Model/DB.pm (modify) Attempting to restart the server

      The good part is that the issue is related to the DB connection for sure. I've just installed MySQL and tested using it and it does work correctly. So, it's something Oracle specific and maybe someone with Oracle knowledge could help .. I hope.

        That is because signal handling has changed in the newer version of the Oracle client. Use the "ora_connect_with_default_signals" option to restore default signal handler:
        options => { AutoCommit => 1, ora_connect_with_default_signals => [ 'INT' ], },