Background worker assistance & review

From: Keith Fiske <keith(at)omniti(dot)com>
To: PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Background worker assistance & review
Date: 2015-04-08 21:35:35
Message-ID: CAG1_KcAo_24d_dJSzZncgNuT+xr2gWJfi97Uq60aR5gTndtbiw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm working on a background worker (BGW) for my pg_partman extension. I've
gotten the basics of it working for my first round, but there's two
features I'm missing that I'd like to add before release:

1) Only allow one instance of this BGW to run
2) Create a bgw_terminate_partman() function to stop it more intuitively
than doing a pg_cancel_backend() on the PID

This is my first venture into writing C code for postgres, so I'm not
familiar with a lot of the internals yet. I read
http://www.postgresql.org/docs/9.4/static/bgworker.html and I see it
mentioning how you can check the status of a BGW launched dynamically and
the function to terminate one, but I'm not clear how how you can get the
information on a currently running BGW to do these things.

I used the worker_spi example for a lot of this, so if there's any
additional guidance for a better way to do what I've done, I'd appreciate
it. All I really have it doing now is calling the run_maintenance()
function at a defined interval and don't need it doing more than that yet.

https://gist.github.com/keithf4/0047eae0b3a22829d527

--
Keith Fiske
Database Administrator
OmniTI Computer Consulting, Inc.
http://www.keithf4.com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vasudevan, Ramya 2015-04-08 21:43:38 Re: Finding values of bind variables
Previous Message John R Pierce 2015-04-08 21:25:44 Re: Finding values of bind variables