pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Autonomous transaction, background worker
3+ messages / 2 participants
[nested] [flat]

* Autonomous transaction, background worker
@ 2018-03-27 04:12  Thiemo Kellner <thiemo@gelassene-pferde.biz>
  0 siblings, 1 reply; 3+ messages in thread

From: Thiemo Kellner @ 2018-03-27 04:12 UTC (permalink / raw)
  To: PostgreSQL General <pgsql-general@lists.postgresql.org>

Hi

I try to setup a logging facility and want it to do its work 
asynchronously in autonomous transactions. I have read 
http://blog.dalibo.com/2016/08/19/Autonoumous_transactions_support_in_PostgreSQL.html 
and chapter 47 of the documentation believing those articles are about 
the same. However, pg_background_launch mentioned in the blog is not 
available on my vanilla installation of Debian 10.3-2 from the 
PostgreSQL repositories.
CHapter 47 makes me believe I need to code some C functions to use 
background workers.

How are things actually?

Kind regards Thiemo

-- 
+49 (0)1578-772 37 37
+41 (0)78 947 36 21
SIP/iptel.org: thiemo.kellner
Öffentlicher PGP-Schlüssel:
http://pgp.mit.edu/pks/lookup?op=get&search=0xCA167FB0E717AFFC

Attachments:

thiemo.vcf (text/x-vcard, 691B) download begin:vcard fn:Thiemo Kellner n:Kellner;Thiemo adr:;;Landstr. 34;Weilheim-Bannholz;BW;79809;Deutschland email;internet:thiemo@gelassene-pferde.biz tel;work:+49 1578 772 37 37 tel;cell:+41 78 947 36 21 note;quoted-printable:Auf Gelassene Pferde kann man bauen!=0D=0A= +49 (0)1578-772 37 37 (Mo, Di)=0D=0A= +41 (0)78 947 36 21 (Mi - Fr)=0D=0A= sip: thiemo.kellner@iptel.org=0D=0A= Skype: thiemo.kellner=0D=0A= http://www.gelassene-pferde.biz=0D=0A= Mitglied bei http://www.keep-it-natural.org=0D=0A= =C3=96ffentlicher PGP-Schl=C3=BCssel: http://pgp.mit.edu/pks/lookup?op=3D= get&search=3D0x8F70EFD2D972CBEF x-mozilla-html:FALSE url:http://www.gelassene-pferde.biz version:2.1 end:vcard
^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: Autonomous transaction, background worker
@ 2018-03-27 15:13  Paul Jungwirth <pj@illuminatedcomputing.com>
  parent: Thiemo Kellner <thiemo@gelassene-pferde.biz>
  0 siblings, 1 reply; 3+ messages in thread

From: Paul Jungwirth @ 2018-03-27 15:13 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

> I try to setup a logging facility and want it to do its work 
> asynchronously in autonomous transactions. I have read 
> http://blog.dalibo.com/2016/08/19/Autonoumous_transactions_support_in_PostgreSQL.html 
> and chapter 47 of the documentation believing those articles are about 
> the same. However, pg_background_launch mentioned in the blog is not 
> available on my vanilla installation of Debian 10.3-2 from the 
> PostgreSQL repositories.
> CHapter 47 makes me believe I need to code some C functions to use 
> background workers.

I've experimented with background workers a bit. Yes, normally you'd 
write some C, but you could also install this (mentioned in the blog 
post and the source of pg_background_launch):

https://github.com/vibhorkum/pg_background

Note that is not part of contrib and is not on pgxn, so to install it 
you need to clone the repo and run `make && sudo make install`. Also I'm 
not sure it is really production-level. In particular this is a serious 
issue:

https://github.com/vibhorkum/pg_background/issues/1

(If the launching process exits, the child process won't be able to map 
the shared memory segment.)

This is another example of background workers that might interest you, 
just to see how they're doing it:

https://github.com/citusdata/pg_cron

In that case they start the worker upon database startup, so it doesn't 
have problems with shared memory going away.

I took a stab recently at using background workers to run ad hoc async 
SQL, but eventually I wound up doing something simpler.

I think background workers is a pretty interesting feature though, so if 
you get something working I'm sure others would be happy to hear about 
it. Good luck!

Yours,

-- 
Paul              ~{:-)
pj@illuminatedcomputing.com




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Autonomous transaction, background worker
@ 2018-03-29 03:31  Thiemo Kellner <thiemo@gelassene-pferde.biz>
  parent: Paul Jungwirth <pj@illuminatedcomputing.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Thiemo Kellner @ 2018-03-29 03:31 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

> I've experimented with background workers a bit. Yes, normally you'd 
> write some C, but you could also install this (mentioned in the blog 
> post and the source of pg_background_launch):

Thanks for your answer. I want my logger to be used with the facilities 
there are from PostgreSQL so I'll go the dblink way. The docs write that 
fdw provides a more modern architecture for more ore less the same. 
However, I do not think the execution of arbiträry stuff is possible by fdw.

Kind regards Thiemo

-- 
SIP/iptel.org: thiemo.kellner
Öffentlicher PGP-Schlüssel:
http://pgp.mit.edu/pks/lookup?op=get&search=0xCA167FB0E717AFFC

Attachments:

thiemo.vcf (text/x-vcard, 691B) download begin:vcard fn:Thiemo Kellner n:Kellner;Thiemo adr:;;Landstr. 34;Weilheim-Bannholz;BW;79809;Deutschland email;internet:thiemo@gelassene-pferde.biz tel;work:+49 1578 772 37 37 tel;cell:+41 78 947 36 21 note;quoted-printable:Auf Gelassene Pferde kann man bauen!=0D=0A= +49 (0)1578-772 37 37 (Mo, Di)=0D=0A= +41 (0)78 947 36 21 (Mi - Fr)=0D=0A= sip: thiemo.kellner@iptel.org=0D=0A= Skype: thiemo.kellner=0D=0A= http://www.gelassene-pferde.biz=0D=0A= Mitglied bei http://www.keep-it-natural.org=0D=0A= =C3=96ffentlicher PGP-Schl=C3=BCssel: http://pgp.mit.edu/pks/lookup?op=3D= get&search=3D0x8F70EFD2D972CBEF x-mozilla-html:FALSE url:http://www.gelassene-pferde.biz version:2.1 end:vcard
^ permalink raw reply [nested|flat] 3+ messages in thread


end of thread, other threads:[~2018-03-29 03:31 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-03-27 04:12 Autonomous transaction, background worker Thiemo Kellner <thiemo@gelassene-pferde.biz>
2018-03-27 15:13 ` Paul Jungwirth <pj@illuminatedcomputing.com>
2018-03-29 03:31   ` Thiemo Kellner <thiemo@gelassene-pferde.biz>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox