Closed akarelas closed 3 years ago
Pasting the current version of myapp.pl
here, in case it gets modified in the future:
#!/usr/bin/env perl
use v5.32;
use warnings;
use FindBin '$RealBin';
use lib "$RealBin/local/lib/perl5";
use Mojolicious::Lite -signatures;
use Mojo::IOLoop;
use Mojo::Pg;
our ($pg, $pubsub);
Mojo::IOLoop->next_tick(sub {
$pg = Mojo::Pg->new('postgresql://dbuser:dbuser@localhost/my_db');
$pubsub = $pg->pubsub;
$pubsub->listen(events => sub {});
$pubsub->on(disconnect => sub {
app->log->warn('Dis-connected!!!');
warn 'Dis-connected';
});
$pubsub->on(reconnect => sub {
app->log->warn('Re-connected!!!');
warn 'Re-connected';
});
Mojo::IOLoop->recurring(5 => sub {
$pubsub->notify(events => 'foo');
});
});
get '/' => sub ($c) {
$c->render(template => 'index');
};
app->start;
__DATA__
@@ index.html.ep
% layout 'default';
% title 'Welcome';
<h1>Welcome to the Mojolicious real-time web framework!</h1>
@@ layouts/default.html.ep
<!DOCTYPE html>
<html>
<head><title><%= title %></title></head>
<body><%= content %></body>
</html>
I did a binary search for the commit of Mojo-Pg that started this problem, and found it is this one: d51e252b157bc05928d92a85f1b92be23626d590: "Handle notifications without eval (closes #58)"
Reopened as #70
Steps to reproduce the behavior
As UNIX user
postgres
, create databasemy_db
on localhost's postgresql, and allow userdbuser
with passworddbuser
to connect to it, eg:Then download and run this small mojolicious app:
Then watch the production log file:
Expected behavior
The log should not repeatedly mention disconnections from the Pg pubsub server.
Actual behavior
The log shows a warning message that Mojolicious disconnected from the pubsub server, many times per minute:
This problem doesn't appear when morbo is running instead of hypnotoad.