(self)
Copy a complete WAL segment to slave.
Copy a complete WAL segment to slave.
Copy a complete WAL segment to slave .
def master_xarchive(self):
        """Copy a complete WAL segment to slave."""

        self.assert_is_master(True)

        if len(self.args) < 2:
            die(1, "usage: xarchive srcpath srcname")
        srcpath = self.args[0]
        srcname = self.args[1]

        start_time = time.time()
        self.log.debug("%s: start copy", srcname)

        self.master_periodic()

        dst_loc = self.cf.getfile("completed_wals")
        if dst_loc[-1] != "/":
            dst_loc += "/"

        # copy data
        self.exec_rsync([ srcpath, dst_loc ], True)

        # sync the buffers to disk - this is should reduce the chance
        # of WAL file corruption in case the slave crashes.
        slave = self.cf.get("slave")
        cmdline = ["ssh", "-nT", slave, "sync" ]
        self.exec_cmd(cmdline)

        # slave has the file now, set markers
        self.set_last_complete(srcname)

        self.log.debug("%s: done", srcname)
        end_time = time.time()
        self.stat_add('count', 1)
        self.stat_add('duration', end_time - start_time)
        self.send_stats()
def master_xarchive ( self ) : self . assert_is_master ( True ) if len ( self . args ) < 2 : die ( 1 , "usage: xarchive srcpath srcname" ) srcpath = self . args [ 0 ] srcname = self . args [ 1 ] start_time = time . time ( ) self . log . debug ( "%s: start copy" , srcname ) self . master_periodic ( ) dst_loc = self . cf . getfile ( "completed_wals" ) if dst_loc [ - 1 ] != "/" : dst_loc += "/" # copy data self . exec_rsync ( [ srcpath , dst_loc ] , True ) # sync the buffers to disk - this is should reduce the chance # of WAL file corruption in case the slave crashes. slave = self . cf . get ( "slave" ) cmdline = [ "ssh" , "-nT" , slave , "sync" ] self . exec_cmd ( cmdline ) # slave has the file now, set markers self . set_last_complete ( srcname ) self . log . debug ( "%s: done" , srcname ) end_time = time . time ( ) self . stat_add ( 'count' , 1 ) self . stat_add ( 'duration' , end_time - start_time ) self . send_stats ( )