replicator/lib/ruby/pg-wal-plugin.rb
# Turn PG replication online.  This requires a restart. 
Turn PG replication online.  This requires a restart.
Turn PG replication online . This requires a restart .
def plugin_online
    if tag_file_exist?(@online)
      log("Node is already online")
    else
      tag_file_write(@going_online, get_role())
      if is_master() 
        if not status_pg_server(nil)
          start_pg_server(false)
        end
        log("Performing master online procedure")
        trigger = @config.getProperty("postgresql.pg_standby.trigger")
        exec_cmd("touch #{trigger}")
        wait_until_login_works
      elsif is_standby()
        log("Performing standby online procedure")
        provision
        start_pg_server(true)
        sleep(10)
        status_pg_server(true) 
      else
        raise UserError, "Illegal role value"
      end
      tag_file_write(@online, get_role())
      if tag_file_exist?(@going_online)
        tag_file_remove(@going_online)
      end
    end 
  end
def plugin_online if tag_file_exist? ( @online ) log ( "Node is already online" ) else tag_file_write ( @going_online , get_role ( ) ) if is_master ( ) if not status_pg_server ( nil ) start_pg_server ( false ) end log ( "Performing master online procedure" ) trigger = @config . getProperty ( "postgresql.pg_standby.trigger" ) exec_cmd ( "touch #{trigger}" ) wait_until_login_works elsif is_standby ( ) log ( "Performing standby online procedure" ) provision start_pg_server ( true ) sleep ( 10 ) status_pg_server ( true ) else raise UserError , "Illegal role value" end tag_file_write ( @online , get_role ( ) ) if tag_file_exist? ( @going_online ) tag_file_remove ( @going_online ) end end end
Turn PG replication online.
Turn PG replication online .
# Make sure we are online.  # Branch on the role.  # Ensure the server is started. # Write the trigger file.  This will terminate recovery if in effect. # Wait until we can login.  Otherwise we get race conditions when  # trying to start standby instance(s). # Provision standby data.  This stops a live server.  # Start the server.  # Bide a few seconds; PG might not be in continuous recovery mode yet. # TODO: wait for SQLSTATE=57P03 (eg. develop a `./monitorctl checkdb`).  # Check PostgreSQL is started. # Mark online.  