| From: | Akash Agrawal <aagrawa6(at)ncsu(dot)edu> |
|---|---|
| To: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | How to kill a Background worker and Its metadata |
| Date: | 2016-06-27 18:27:15 |
| Message-ID: | CALF3U-4To6FfrBcMWH2uR7yubcm03L9G0pJYMcyv0fNA6A=Z3Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
I've created a background worker and I am using Postgresql-9.4. This
bgworker handles the job queue dynamically and goes to sleep if there is no
job to process within the next 1 hour.
Now, I want to have a mechanism to wake the bgworker up in case if someone
adds a new job while the bgworker is in sleep mode. So to do it, I have
created a trigger which initially removes the existing background worker
and then registers a new one. I am using the following two queries inside
it:
select pg_terminate_backend(pid of bgworker);
select worker_spi1_launch(1);
I am retrieving the pid from pg_Stat_activity. The maximum number of
background worker that can run simultaneously is equal to 8. I think even
if I call pg_terminate_backend the metadata of the background worker is not
being deleted and as a result after 8 insert operations I am not able to
register a background worker. Please suggest what can be done here.
Best,
Akash
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alex Malek | 2016-06-27 18:27:32 | Re: problems using pg_start_backup/pg_stop_backup and pg_basebackup at same time |
| Previous Message | Christoph Berg | 2016-06-27 18:22:56 | Re: Broken handling of lwlocknames.h |