pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedlibpgtcl modifications
13+ messages / 3 participants
[nested] [flat]
* libpgtcl modifications
@ 2002-08-08 08:52 g.hintermayer@mail.inode.at
0 siblings, 0 replies; 13+ messages in thread
From: g.hintermayer@mail.inode.at @ 2002-08-08 08:52 UTC (permalink / raw)
To: pgsql-interfaces
I hacked libpgtcl to get the following working:
> A broken backend connection trigers a notify event to the client (fixed
> notification string "connection_closed") so proper action can be taken to switch
> to another database server etc. Remember that this is event driven. If you have
> applications, that have idle database connections most of the time, you'll get
> immediate feedback of a dying server. Upon connection to the server issue a
> pg_notify for notify event "connection_closed" and whenever the backend crashes
> (which it does do in very very rare cases) you get an event driven recovery. (of
> course the Tcl-Event loop has to be processed). Issuing a notification
> "connection_closed" on a still working database could be used for switching to
> another db-server.
> I'd like to share my changes (because I don't want to apply them to every
> release). What's the way to go ?
Attached is a patch (hope I did it right ;-) )
Gerhard
--
Gerhard Hintermayer
http://www.inode.at/g.hintermayer
Attachments:
patch-notification.gz (text/plain, 1.3K) download
O= patch åXioã6ýìüÉÈÚª|ÈrÔRován6§³@QV¢l"²äP´[wÿÞ²\Mât»@ÀIÍp÷É<¡ìCYÀ$IåP°ô:*»zÅ)'«©ð«<LÏÒjÄ¿LÒªê³;ÒÇò)Fe½|ɧ$wÌhÓÚmîì6ÛP¯Õr¹ü¢x
ïé NkÛ»N<Ö)ÐÕxÓÙ±õ6¨ üýÐï
>ürr>ø|x~Ñ;9ýlãdÁOâ:p:üÀd/y÷¢jb'³ßßmØ¢WyPÚÛØú,êïåý8<äLü"ØìÀñåÑQüú~4¸òvõ+ïùÀU0r<ÔYSÃ?»S.Ð꫱ø\þ¯«_éÕBÕT&(ÇCÇ'ýÞû_ÍX,S@É'!saUééð-iù!½yL
ÏÌÒ¶£¶FÅÂÍÚeÖâm/x6kÉä¥%[ÅØãdÐgéºÛp_ÊXåï_w²óµîºv}»ñµ ô©à VQ^£RÕl
9â©*ºÆ'Â2 `çÆÏúøRlUô¤ÔãxRh¢·±Ý(Iò½^Yd;|ïô,ä1OG*Ð_CÄ,MCÄï(MC×Hô^=n:v³é.úk=q
ó¶òV±5EØÚRL#õÑëÏ'l9_N¶NÒ&R«u
ì.<gé4fæ½{ãUo¶RÂÏ'GýÞÑ¡Qð8sòQ
&h55¹dMüƹÑLUzµîëWÛqì¶ã®òÑ'LLÿIÄ_ê>X`̤~z¦_ÉÃ~Zé òB½ÑH¬ZªÞ:UÒ¼V,õ !Ê`ãd¦ø´`¦«èmè0ãBN½H³ûQByLxð(/&"A¤§í`µ[E¸·AnËno;«
âFb/æÈSÍÝ=ø24§¢ñ#æ `^P¦L@pñSø¥jáx:³^<ÊÛT_F_xq2E26ñ,Õízʦ¬éÈPW"ó¡*.ñ 0ÂÙÞÉ ç¿.fó±³óËJóÀÒIu -
±%~1å±$\-éSAÃá©ecwÜdST
2/jÛò¾`Qb`¿¹È7Æ@
[Þa5¨:Õao 㨠Oq4÷6äEÑõAúao¡]gÔeåX¤ïº(C-QgþAïÈç_
±bq O«¤×Ós7ßo÷ÑÍ7m·QËèf"¡1°èlT=;=kÐÑhúÕ$r®u Ûøvç¤*¦1Kn£m»ÍzFõ³QF
F_+Ø{«Úl`ðË]f¥Á¾¤ÆªuÁ²©cÁ°s,ö9å®¶wêdz»R=NðÆ´qò¤WÜþ£JÛjÙnk¹ï¼VtT§[5õ#^ûÂ1zþ!´Æ
cTè¦pâK¨· æî¶jæBÿÂö§.àm£YÛ9ü i·tfÒ>¢XÁzë#^x©/=uðkqÍSç/Sxcs
Åuùçùì1·¼³ú
ô|2Þöð,1ºÂ½òøl{¶ï
lqOÎõ¹<_}¨ÐÇlê!ßÿ¹CwTù»lÙßl¹ç»©
^ permalink raw reply [nested|flat] 13+ messages in thread
* libpgtcl modifications
@ 2002-08-12 09:16 Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-12 19:56 ` Re: [INTERFACES] libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-23 04:30 ` Re: libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
0 siblings, 2 replies; 13+ messages in thread
From: g.hintermayer@inode.at @ 2002-08-12 09:16 UTC (permalink / raw)
To: pgsql-interfaces
Well, I hacked some files to get the following working:
A broken backend connection trigers a notify event to the client
(fixed
notification string "connection_closed") so proper action can be taken
to switch to another database server etc. Remember that this is event
driven. If you have applications, that have idle database connections
most of the time, you'll get immediate feedback of a dying server.
Upon
connection to the server issue a pg_notify for notify event
"connection_closed" and whenever the backend crashes (which it does do
in very very rare cases) you get an event driven recovery. (of course
the Tcl-Event loop has to be processed). Issuing a notification
"connection_closed" on a still working database could be used for
switching to another db-server.
I'd like to share my changes (because I don't want to apply them to
every release). What's the way to go ?
I'd also like to see a TclObj-based implementation, and also support
for
Tcl8.4, *and* I'd even be willing to implement some of these changes.
Any suggestions ?
Attached is the patch with the described functionality. Oops , cannot
attach files with google, and my ISP does'nt have
comp.databases.postgresql.interfaces :-(, what shall I do ? My ISP
says, this NG is not listed in the BIG8 groups, is that correct ?
Gerhard
>
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: [INTERFACES] libpgtcl modifications
2002-08-12 09:16 libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
@ 2002-08-12 19:56 ` Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-14 05:43 ` Re: libpgtcl modifications Bruce Momjian <pgman@candle.pha.pa.us>
2002-08-16 04:58 ` Re: libpgtcl modifications Bruce Momjian <pgman@candle.pha.pa.us>
1 sibling, 2 replies; 13+ messages in thread
From: Gerhard Hintermayer @ 2002-08-12 19:56 UTC (permalink / raw)
To: pgsql-interfaces
Luke Myers wrote:
> Gerhard Hintermayer wrote:
>
>> Attached is the patch with the described functionality. Oops , cannot
>> attach files with google, and my ISP does'nt have
>> comp.databases.postgresql.interfaces :-(, what shall I do ? My ISP
>> says, this NG is not listed in the BIG8 groups, is that correct ?
>>
>> Gerhard
>>
>
> Can you use news.postgresql.org?
>
> -- Luke Kale Myers
>
Indeed that works, and I even managed to use it with leafnode.
Here's the patch (hope i did it right)
--
Gerhard Hintermayer
http://www.inode.at/g.hintermayer
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
Attachments:
patch-notification.gz (application/x-gunzip, 1.3K) download
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: libpgtcl modifications
2002-08-12 09:16 libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-12 19:56 ` Re: [INTERFACES] libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
@ 2002-08-14 05:43 ` Bruce Momjian <pgman@candle.pha.pa.us>
2002-08-14 06:04 ` Re: [INTERFACES] libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
1 sibling, 1 reply; 13+ messages in thread
From: Bruce Momjian @ 2002-08-14 05:43 UTC (permalink / raw)
To: Gerhard Hintermayer <g.hintermayer@inode.at>; +Cc: pgsql-interfaces
Can I have some description of what this patch does?
---------------------------------------------------------------------------
Gerhard Hintermayer wrote:
> Luke Myers wrote:
> > Gerhard Hintermayer wrote:
> >
> >> Attached is the patch with the described functionality. Oops , cannot
> >> attach files with google, and my ISP does'nt have
> >> comp.databases.postgresql.interfaces :-(, what shall I do ? My ISP
> >> says, this NG is not listed in the BIG8 groups, is that correct ?
> >>
> >> Gerhard
> >>
> >
> > Can you use news.postgresql.org?
> >
> > -- Luke Kale Myers
> >
>
> Indeed that works, and I even managed to use it with leafnode.
>
> Here's the patch (hope i did it right)
>
>
> --
> Gerhard Hintermayer
> http://www.inode.at/g.hintermayer
[ application/x-gunzip is not supported, skipping... ]
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: [INTERFACES] libpgtcl modifications
2002-08-12 09:16 libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-12 19:56 ` Re: [INTERFACES] libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-14 05:43 ` Re: libpgtcl modifications Bruce Momjian <pgman@candle.pha.pa.us>
@ 2002-08-14 06:04 ` Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-17 12:19 ` Re: [INTERFACES] libpgtcl modifications Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 1 reply; 13+ messages in thread
From: Gerhard Hintermayer @ 2002-08-14 06:04 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>
Bruce Momjian wrote:
> Can I have some description of what this patch does?
>
Unfortunately some of my postings seem to vanish in cyberspace ;-)
What I have done for libpgtcl:
Everytime if I do PQconsumeInput (when the backend channel gets
readable) I check for the return value. (0 == error) and generate a
notification manually, e.g. fixed string connection_closed) and pass it to the
TCL event queue. The only other thing I had to do is to comment out removing
all pending events in PgStopNotifyEventSource whenever the connection was
unexpectedly closed (so the manually generated event will not be deleted).
A broken backend connection triggers a notify event to the client (fixed
notification string "connection_closed") so proper action can be taken to switch
to another database server etc. Remember that this is event driven. If you have
applications, that have idle database connections most of the time, you'll get
immediate feedback of a dying server. Upon connection to the server issue a
pg_notify for notify event "connection_closed" and whenever the backend crashes
(which it does do in very very rare cases) you get an event driven recovery. (of
course the Tcl-Event loop has to be processed). Issuing a notification
"connection_closed" on a still working database could be used for switching to
another db-server (which I've actually impelemented right now).
I did this not because we have crashing db-servers all the time, in fact we have
running pg for many years without any major problems in a production environment
(recipe and batch data for petfood production).
One reason was to get notifications to applications, that run permanently and
have a persistent db connection, in case the primary server should be changed
for whatever reason (network problems, server shutdown, maintenance etc.)
Gerhard.
PS:
>[ application/x-gunzip is not supported, skipping... ]
are you joking, which file format do you suggest for a patch ?
--
Gerhard Hintermayer
http://www.inode.at/g.hintermayer
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: [INTERFACES] libpgtcl modifications
2002-08-12 09:16 libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-12 19:56 ` Re: [INTERFACES] libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-14 05:43 ` Re: libpgtcl modifications Bruce Momjian <pgman@candle.pha.pa.us>
2002-08-14 06:04 ` Re: [INTERFACES] libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
@ 2002-08-17 12:19 ` Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 0 replies; 13+ messages in thread
From: Bruce Momjian @ 2002-08-17 12:19 UTC (permalink / raw)
To: Gerhard Hintermayer <g.hintermayer@inode.at>; +Cc: PostgreSQL-patches <pgsql-patches@postgresql.org>
Your patch has been added to the PostgreSQL unapplied patches list at:
http://candle.pha.pa.us/cgi-bin/pgpatches
I will try to apply it within the next 48 hours.
---------------------------------------------------------------------------
Gerhard Hintermayer wrote:
> Bruce Momjian wrote:
> > Can I have some description of what this patch does?
> >
>
> Unfortunately some of my postings seem to vanish in cyberspace ;-)
>
> What I have done for libpgtcl:
> Everytime if I do PQconsumeInput (when the backend channel gets
> readable) I check for the return value. (0 == error) and generate a
> notification manually, e.g. fixed string connection_closed) and pass it to the
> TCL event queue. The only other thing I had to do is to comment out removing
> all pending events in PgStopNotifyEventSource whenever the connection was
> unexpectedly closed (so the manually generated event will not be deleted).
>
> A broken backend connection triggers a notify event to the client (fixed
> notification string "connection_closed") so proper action can be taken to switch
> to another database server etc. Remember that this is event driven. If you have
> applications, that have idle database connections most of the time, you'll get
> immediate feedback of a dying server. Upon connection to the server issue a
> pg_notify for notify event "connection_closed" and whenever the backend crashes
> (which it does do in very very rare cases) you get an event driven recovery. (of
> course the Tcl-Event loop has to be processed). Issuing a notification
> "connection_closed" on a still working database could be used for switching to
> another db-server (which I've actually impelemented right now).
>
> I did this not because we have crashing db-servers all the time, in fact we have
> running pg for many years without any major problems in a production environment
> (recipe and batch data for petfood production).
> One reason was to get notifications to applications, that run permanently and
> have a persistent db connection, in case the primary server should be changed
> for whatever reason (network problems, server shutdown, maintenance etc.)
>
> Gerhard.
>
> PS:
> >[ application/x-gunzip is not supported, skipping... ]
> are you joking, which file format do you suggest for a patch ?
>
>
> --
> Gerhard Hintermayer
> http://www.inode.at/g.hintermayer
>
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: libpgtcl modifications
2002-08-12 09:16 libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-12 19:56 ` Re: [INTERFACES] libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
@ 2002-08-16 04:58 ` Bruce Momjian <pgman@candle.pha.pa.us>
2002-08-26 07:00 ` Re: libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
1 sibling, 1 reply; 13+ messages in thread
From: Bruce Momjian @ 2002-08-16 04:58 UTC (permalink / raw)
To: Gerhard Hintermayer <g.hintermayer@inode.at>; +Cc: pgsql-interfaces
Your patch has been added to the PostgreSQL unapplied patches list at:
http://candle.pha.pa.us/cgi-bin/pgpatches
I will try to apply it within the next 48 hours.
---------------------------------------------------------------------------
Gerhard Hintermayer wrote:
> Luke Myers wrote:
> > Gerhard Hintermayer wrote:
> >
> >> Attached is the patch with the described functionality. Oops , cannot
> >> attach files with google, and my ISP does'nt have
> >> comp.databases.postgresql.interfaces :-(, what shall I do ? My ISP
> >> says, this NG is not listed in the BIG8 groups, is that correct ?
> >>
> >> Gerhard
> >>
> >
> > Can you use news.postgresql.org?
> >
> > -- Luke Kale Myers
> >
>
> Indeed that works, and I even managed to use it with leafnode.
>
> Here's the patch (hope i did it right)
>
>
> --
> Gerhard Hintermayer
> http://www.inode.at/g.hintermayer
[ application/x-gunzip is not supported, skipping... ]
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: libpgtcl modifications
2002-08-12 09:16 libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-12 19:56 ` Re: [INTERFACES] libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-16 04:58 ` Re: libpgtcl modifications Bruce Momjian <pgman@candle.pha.pa.us>
@ 2002-08-26 07:00 ` Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-26 14:40 ` Re: libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
0 siblings, 1 reply; 13+ messages in thread
From: g.hintermayer@inode.at @ 2002-08-26 07:00 UTC (permalink / raw)
To: pgsql-interfaces
Last Thursday I posted revision 2 of my patch (directly to
news.postgresql.org with *no* error). Unfortuntely it does not show up
here. This are the longest 6 to 9 hours I've ever seen. I Will repost
in the evening :-(
Gerhard
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: libpgtcl modifications
2002-08-12 09:16 libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-12 19:56 ` Re: [INTERFACES] libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-16 04:58 ` Re: libpgtcl modifications Bruce Momjian <pgman@candle.pha.pa.us>
2002-08-26 07:00 ` Re: libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
@ 2002-08-26 14:40 ` Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-26 14:42 ` Re: libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-27 21:07 ` Re: libpgtcl modifications Bruce Momjian <pgman@candle.pha.pa.us>
2002-09-03 01:07 ` Re: libpgtcl modifications Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 3 replies; 13+ messages in thread
From: Gerhard Hintermayer @ 2002-08-26 14:40 UTC (permalink / raw)
To: pgsql-interfaces
Gerhard Hintermayer wrote:
> Last Thursday I posted revision 2 of my patch (directly to
> news.postgresql.org with *no* error). Unfortuntely it does not show up
> here. This are the longest 6 to 9 hours I've ever seen. I Will repost
> in the evening :-(
>
> Gerhard
Damn, I posted that from the PC located at my girlfriend. Do'nt have the
description I wrote (It was quite long). Btw, is there a more save way to do
postings to comp.databases.postgresql.interfaces. I also do get strange replys
from postmaster@afk.dk when I do post via Google ? Strange !
Here you have a short description, the long one you'll get when I'm at my other
PC next time.
I added a new command:
pg_on_connection_loss conn ?callback?
changed libpgtcl version to 1.4 to reflect the additional command.
No callback to query the current script, with callback to set/change callback
script. Script is executed whenever (all occurences of) PQconsumeInput return
false, i.e. both in an idle database connection and while processing a COPY
command. Tested a bit, no errors, alle db-operations in callback are allowed
(and trigger a "is not a valid connection" or so error)
Any comments ?
--
Gerhard Hintermayer
http://www.inode.at/g.hintermayer
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: libpgtcl modifications
2002-08-12 09:16 libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-12 19:56 ` Re: [INTERFACES] libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-16 04:58 ` Re: libpgtcl modifications Bruce Momjian <pgman@candle.pha.pa.us>
2002-08-26 07:00 ` Re: libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-26 14:40 ` Re: libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
@ 2002-08-26 14:42 ` Gerhard Hintermayer <g.hintermayer@inode.at>
2 siblings, 0 replies; 13+ messages in thread
From: Gerhard Hintermayer @ 2002-08-26 14:42 UTC (permalink / raw)
To: pgsql-interfaces
Sorry, forgot the attachment. Here it is.
--
Gerhard Hintermayer
http://www.inode.at/g.hintermayer
Attachments:
patch_conn_loss.gz (application/x-gunzip, 2.6K) download
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: libpgtcl modifications
2002-08-12 09:16 libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-12 19:56 ` Re: [INTERFACES] libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-16 04:58 ` Re: libpgtcl modifications Bruce Momjian <pgman@candle.pha.pa.us>
2002-08-26 07:00 ` Re: libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-26 14:40 ` Re: libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
@ 2002-08-27 21:07 ` Bruce Momjian <pgman@candle.pha.pa.us>
2 siblings, 0 replies; 13+ messages in thread
From: Bruce Momjian @ 2002-08-27 21:07 UTC (permalink / raw)
To: Gerhard Hintermayer <g.hintermayer@inode.at>; +Cc: pgsql-interfaces
Your patch has been added to the PostgreSQL unapplied patches list at:
http://candle.pha.pa.us/cgi-bin/pgpatches
I will try to apply it within the next 48 hours.
---------------------------------------------------------------------------
Gerhard Hintermayer wrote:
> Gerhard Hintermayer wrote:
> > Last Thursday I posted revision 2 of my patch (directly to
> > news.postgresql.org with *no* error). Unfortuntely it does not show up
> > here. This are the longest 6 to 9 hours I've ever seen. I Will repost
> > in the evening :-(
> >
> > Gerhard
>
> Damn, I posted that from the PC located at my girlfriend. Do'nt have the
> description I wrote (It was quite long). Btw, is there a more save way to do
> postings to comp.databases.postgresql.interfaces. I also do get strange replys
> from postmaster@afk.dk when I do post via Google ? Strange !
>
> Here you have a short description, the long one you'll get when I'm at my other
> PC next time.
>
> I added a new command:
>
> pg_on_connection_loss conn ?callback?
>
> changed libpgtcl version to 1.4 to reflect the additional command.
>
> No callback to query the current script, with callback to set/change callback
> script. Script is executed whenever (all occurences of) PQconsumeInput return
> false, i.e. both in an idle database connection and while processing a COPY
> command. Tested a bit, no errors, alle db-operations in callback are allowed
> (and trigger a "is not a valid connection" or so error)
>
> Any comments ?
>
> --
> Gerhard Hintermayer
> http://www.inode.at/g.hintermayer
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: libpgtcl modifications
2002-08-12 09:16 libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-12 19:56 ` Re: [INTERFACES] libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-16 04:58 ` Re: libpgtcl modifications Bruce Momjian <pgman@candle.pha.pa.us>
2002-08-26 07:00 ` Re: libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-26 14:40 ` Re: libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
@ 2002-09-03 01:07 ` Bruce Momjian <pgman@candle.pha.pa.us>
2 siblings, 0 replies; 13+ messages in thread
From: Bruce Momjian @ 2002-09-03 01:07 UTC (permalink / raw)
To: Gerhard Hintermayer <g.hintermayer@inode.at>; +Cc: pgsql-interfaces
Patch applied for 7.3. Thanks.
---------------------------------------------------------------------------
Gerhard Hintermayer wrote:
> Gerhard Hintermayer wrote:
> > Last Thursday I posted revision 2 of my patch (directly to
> > news.postgresql.org with *no* error). Unfortuntely it does not show up
> > here. This are the longest 6 to 9 hours I've ever seen. I Will repost
> > in the evening :-(
> >
> > Gerhard
>
> Damn, I posted that from the PC located at my girlfriend. Do'nt have the
> description I wrote (It was quite long). Btw, is there a more save way to do
> postings to comp.databases.postgresql.interfaces. I also do get strange replys
> from postmaster@afk.dk when I do post via Google ? Strange !
>
> Here you have a short description, the long one you'll get when I'm at my other
> PC next time.
>
> I added a new command:
>
> pg_on_connection_loss conn ?callback?
>
> changed libpgtcl version to 1.4 to reflect the additional command.
>
> No callback to query the current script, with callback to set/change callback
> script. Script is executed whenever (all occurences of) PQconsumeInput return
> false, i.e. both in an idle database connection and while processing a COPY
> command. Tested a bit, no errors, alle db-operations in callback are allowed
> (and trigger a "is not a valid connection" or so error)
>
> Any comments ?
>
> --
> Gerhard Hintermayer
> http://www.inode.at/g.hintermayer
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: libpgtcl modifications
2002-08-12 09:16 libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
@ 2002-08-23 04:30 ` Gerhard Hintermayer <g.hintermayer@inode.at>
1 sibling, 0 replies; 13+ messages in thread
From: Gerhard Hintermayer @ 2002-08-23 04:30 UTC (permalink / raw)
To: pgsql-interfaces
Revision 2 was not so quick, but also not so dirty. Here's my first draft.
I have modified:
- Version number of Pgtcl changed to 1.4 (to reflect the additional command)
- added a command pg_on_connection_loss
Syntax: pg_on_connection_loss conn ?callback?
Use no callback parameter to query the actuall callback script and
with parameter to set/change callback. The callback is evaluated
whenever the connection to the backend gets lost (eof condition ?).
I do this by checking for a false return value from PQconsumeInput.
Today I did some quick testing, no segfaults, no errors. Broken backends
are detected both in idle connections and when you're in a COPY command
(these are the two possibilities, where PQconsumeInput is called).
I'm using the same readable fileevent on the database connection as
pg_listen does internally. The structure Pg_ConnectionId was extended by
two fields : char *conn_loss to store the callback and Tcl_Interp
*interp to store the interpreter, in which context the callback will be
evaluated.
Can someone with more experience on Tcl event programming take a look at
this, I mananged to write some Tcl extensions, but am new to modifying
the Tcl event-loop. (what I did, was copying most of the pg_listen stuff).
Basically PgStartNotifyEventSource() is called, when a callback proc is
supplied to pg_on_connection_loss, which (unmodified) does install a
readable fileevent on the db connection, then I check for false return
value of PQconsumeInput and add a ConnLossEvent type to the event queue.
(pg_)listen callbacks are deleted immediately from the the event queue
when the db connection is broken, just like in the unpatch version. What
This a point worth to discuss: Which commands will dump core when used
in the disconnect handler ? pg_disconnect works, but the best thing
might be to invoke pg_disconnect as the first command within the
disconnect handler per default (in C code, not in Tcl) so possible
subsequent operations on the just closed connection would at least
trigger a "... is not a valid postgresql connection" error, but not run
into any segfaults.
I will do some more testing tomorrow, but since I only can post via
google at work, I'd like to get some feedback more quickly.
Gerhard
PS: I need my patch also for an older version of Postgresql (7.0.2), can
I copy the whole libpgtcl directory into the 7.0.2 source path without
any risk ?
--
Gerhard Hintermayer
http://www.inode.at/g.hintermayer
Attachments:
patch_conn_loss.gz (application/x-gunzip, 1.8K) download
^ permalink raw reply [nested|flat] 13+ messages in thread
end of thread, other threads:[~2002-09-03 01:07 UTC | newest]
Thread overview: 13+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-08-08 08:52 libpgtcl modifications g.hintermayer@mail.inode.at
2002-08-12 09:16 libpgtcl modifications Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-12 19:56 ` Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-14 05:43 ` Bruce Momjian <pgman@candle.pha.pa.us>
2002-08-14 06:04 ` Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-17 12:19 ` Bruce Momjian <pgman@candle.pha.pa.us>
2002-08-16 04:58 ` Bruce Momjian <pgman@candle.pha.pa.us>
2002-08-26 07:00 ` Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-26 14:40 ` Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-26 14:42 ` Gerhard Hintermayer <g.hintermayer@inode.at>
2002-08-27 21:07 ` Bruce Momjian <pgman@candle.pha.pa.us>
2002-09-03 01:07 ` Bruce Momjian <pgman@candle.pha.pa.us>
2002-08-23 04:30 ` Gerhard Hintermayer <g.hintermayer@inode.at>
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