]> git.8kb.co.uk Git - slony-i/pgbouncer_follower/commitdiff
Add support for auth_user and ensure nodes currently being cloned are never used.
authorglyn <glyn@8kb.co.uk>
Tue, 13 Oct 2015 09:56:57 +0000 (10:56 +0100)
committerglyn <glyn@8kb.co.uk>
Tue, 13 Oct 2015 09:56:57 +0000 (10:56 +0100)
README.md
pgbouncer_follower.pl
pgbouncer_follower_ro.conf
pgbouncer_follower_rw.conf

index 83577801db0ddfba352be6d01eeb4e4b017c1294..142e864fb93fd28a5b283a0318f39406486c41e9 100644 (file)
--- a/README.md
+++ b/README.md
@@ -43,6 +43,7 @@ $ sudo invoke-rc.d pgbouncer_follower_rw start
 | pgBouncer | sets_to_follow         | text    | *1*                                         | Comma separated list of sets to follow or 'all' to follow all sets
 | pgBouncer | pool_mode              | 'ro/rw' | *'rw'*                                      | Select a read-only subscriber or the origin for read-write
 | pgBouncer | pool_all_databases     | boolean | *'false'*                                   | If true uses wildcard for database name in pgbouncer.ini, false uses slony database
+| pgBouncer | auth_user              | text    | *''*                                        | If set auth_user will be appended to conninfo written in [databases] section
 | pgBouncer | only_follow_origins    | boolean | *'false'*                                   | If true pgbouncer will only be reconfigured and reloaded when sets move origin
 | pgBouncer | status_file            | text    | *'/tmp/pgbouncer_follower_%mode.status'*    | File used to store a hash depicting the state of the cluster
 | pgBouncer | log_file               | text    | *'/tmp/pgbouncer_follower_%mode.log'*       | Log file for the script
index aa55bcba58d348d7851f70455c95e615223b9976..e2c25612b81e2a41878225724365c809495a7807 100755 (executable)
@@ -55,6 +55,7 @@ my $g_conf_target = "/etc/pgbouncer/pgbouncer_%mode.ini";
 my $g_reload_command = "/etc/init.d/pgbouncer_%mode reload";
 my $g_mode = 'rw';
 my $g_all_databases=false;
+my $g_auth_user='';
 my ($year, $month, $day, $hour, $min, $sec);
 my $change_time;
 my $g_host = hostname;
@@ -186,11 +187,16 @@ sub generateConfig {
     my $target_sets;
     my $target_port = 5432;
     my $target_is_origin;
+    my $target_auth = "";
 
     if ($g_debug) {
         printLogLn($g_logfile, "DEBUG: All databases = " . ($g_all_databases ? 'true' : 'false'));
     }
 
+    if ($g_auth_user ne "") {
+        $target_auth = " auth_user=" . $g_auth_user;
+    }
+
     if (open(INFILE, "<", $template)) {
         if (open(OUTFILE, ">", $target)) {
             print OUTFILE "# Configuration file autogenerated at " . getRuntime() . " from $template\n";
@@ -259,10 +265,10 @@ sub generateConfig {
                             printLogLn ($g_logfile, "DEBUG: Configuration for " . ($target_is_origin ? "origin" : "subscriber") . " of sets $target_sets node #$target_node_id $target_host:$target_port");
                         }
                         if ($all_databases) {
-                            $_ =~ s/(\[databases\])/$1\n\* = host=$target_host port=$target_port/;
+                            $_ =~ s/(\[databases\])/$1\n\* = host=$target_host port=$target_port$target_auth/;
                         }
                         else {
-                            $_ =~ s/(\[databases\])/$1\n$target_db = host=$target_host port=$target_port dbname=$target_db/;
+                            $_ =~ s/(\[databases\])/$1\n$target_db = host=$target_host port=$target_port dbname=$target_db$target_auth/;
                         }
                     }
                     else {
@@ -387,6 +393,7 @@ sub loadCluster {
                     COALESCE((? BETWEEN 1 AND extract(epoch from s.st_lag_time)),false) AS lag_exceeded
                 FROM x 
                 LEFT JOIN $qw_clname.sl_status s ON s.st_received = x.no_id
+               WHERE x.no_conninfo != '<event pending>'
                 )
                 SELECT * FROM z 
                 ORDER BY origin_sets, @(CASE WHEN (host ~ '^[0-9]{1,3}(.[0-9]{1,3}){3}\$') THEN host::inet ELSE '255.255.255.255'::inet END - ?::inet) ASC";
@@ -497,6 +504,9 @@ sub getConfig {
                     when(/\bpool_all_databases\b/i) {
                         $g_all_databases = checkBoolean($value);
                     }
+                    when(/\bauth_user\b/i) {
+                        $g_auth_user = $value;
+                    }
                     when(/\bonly_follow_origins\b/i) {
                         $g_origins_only = checkBoolean($value);
                     }
index 209c8bcea3eb76e8eee1eae6b22713a4e3145f43..7c07e7f760598768d67d819924bf312e6055ff9d 100755 (executable)
@@ -33,6 +33,9 @@ pool_all_databases=false
                                                                                 # thus hosting all databases on the node. If false
                                                                                 # only the replicated database is hosted.
 
+auth_user=                                                                     # If set auth_user will be appended to conninfo written
+                                                                                # in [databases] section.
+
 status_file=/var/slony/pgbouncer_follower/pgbouncer_follower_%mode.status       # File used to store tate of the cluster
 log_file=/var/slony/pgbouncer_follower/pgbouncer_follower_%mode.log             # Log for pool_follower script
 pid_file=/var/run/pgbouncer_follower_%mode.pid                                  # Pidfile for poll mode 
index f06fa446bd8c31c26f419d70bc86411d024d4e13..8f58c754691db9f8929ac39647fb282cdac2c285 100755 (executable)
@@ -33,6 +33,9 @@ pool_all_databases=false
                                                                                 # thus hosting all databases on the node. If false
                                                                                 # only the replicated database is hosted.
 
+auth_user=                                                                      # If set auth_user will be appended to conninfo written
+                                                                                # in [databases] section.
+
 status_file=/var/slony/pgbouncer_follower/pgbouncer_follower_%mode.status       # File used to store tate of the cluster
 log_file=/var/slony/pgbouncer_follower/pgbouncer_follower_%mode.log             # Log for pool_follower script
 pid_file=/var/run/pgbouncer_follower_%mode.pid                                  # Pidfile for poll mode