forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb7214a8
committed
What I have done for libpgtcl:
Everytime if I do PQconsumeInput (when the backend channel getsreadable) I check for the return value. (0 == error) and generate anotification manually, e.g. fixed string connection_closed) and pass it to theTCL event queue. The only other thing I had to do is to comment out removingall pending events in PgStopNotifyEventSource whenever the connection wasunexpectedly closed (so the manually generated event will not be deleted).A broken backend connection triggers a notify event to the client (fixednotification string "connection_closed") so proper action can be taken to switchto another database server etc. Remember that this is event driven. If you haveapplications, that have idle database connections most of the time, you'll getimmediate feedback of a dying server. Upon connection to the server issue apg_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. (ofcourse the Tcl-Event loop has to be processed). Issuing a notification"connection_closed" on a still working database could be used for switching toanother db-server (which I've actually impelemented right now).Gerhard Hintermayer1 parentb813554 commitb7214a8
3 files changed
+26
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
422 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
423 | 425 | | |
| 426 | + | |
424 | 427 | | |
425 | 428 | | |
426 | 429 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
280 | | - | |
| 280 | + | |
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | | - | |
| 444 | + | |
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
| |||
611 | 611 | | |
612 | 612 | | |
613 | 613 | | |
614 | | - | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
615 | 617 | | |
616 | 618 | | |
617 | 619 | | |
| |||
675 | 677 | | |
676 | 678 | | |
677 | 679 | | |
678 | | - | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
679 | 691 | | |
680 | 692 | | |
681 | 693 | | |
| |||
724 | 736 | | |
725 | 737 | | |
726 | 738 | | |
727 | | - | |
| 739 | + | |
728 | 740 | | |
729 | 741 | | |
730 | 742 | | |
| |||
743 | 755 | | |
744 | 756 | | |
745 | 757 | | |
746 | | - | |
| 758 | + | |
747 | 759 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
0 commit comments
Comments
(0)