From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
---|---|
To: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Server crash when using bgw_main for a dynamic bgworker |
Date: | 2013-08-12 05:26:48 |
Message-ID: | CAB7nPqQE_i6Jf1joxH=usSmnhQy7JXUAvKFt9HXnzboiD7K_bQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi all,
While playing a bit with background workers (commit 527ea66), I found that
setting bgw_main for a dynamic bgworker, as well as bgw_library_name and
bgw_library_name, crashes to server if the library defining the function
defined in bgw_main is not loaded. In order to reproduce that, for example
simply change bgw_main from NULL to worker_spi_main in
worker_spi_launch:worker_spi.c and do not set shared_preload_libraries with
worker_spi. Then connect to a server having this modified worker_spi
installed and do the following:
postgres=# show shared_preload_libraries ;
shared_preload_libraries
--------------------------
(1 row)
postgres=# create extension worker_spi;
CREATE EXTENSION
postgres=# select worker_spi_launch(1);
worker_spi_launch
-------------------
t
(1 row)
postgres=# select worker_spi_launch(2);
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.
By looking at the code, priority is given to bgw_main...
if (worker->bgw_main != NULL)
entrypt = worker->bgw_main;
else
entrypt = (bgworker_main_type)
load_external_function(worker->bgw_library_name,
worker->bgw_function_name,
true, NULL);
Wouldn't be clearer for the user to add a new flag in
BackgroundWorker:bgworker.h to define a class of bgworker? Or at least
specify clearly in the docs just to never set bgw_main if the library is
not loaded previously using for example shared_preload_libraries?
Opinions?
Regards,
--
Michael
From | Date | Subject | |
---|---|---|---|
Next Message | Romain Billon-Grand | 2013-08-12 06:01:44 | Re: BUG #8335: trim() un-document behaviour |
Previous Message | Ashutosh Bapat | 2013-08-12 04:37:00 | Re: pass-through queries to foreign servers |