Example #1
0
 def gpstart_and_verify(self, master_dd=os.environ.get('MASTER_DATA_DIRECTORY'), host='localhost'):
     pid = walrepl.get_postmaster_pid(master_dd, host)
     tinctest.logger.info("gpstart_verify: master dd is %s, host is %s, master pid is %s"%(master_dd,host, pid))
     if pid == -1:
         return False
     cmd_str = 'kill -s 0 {pid}'.format(pid=pid)
     cmd = SmartCmd(cmd_str, host=host)
     cmd.run()
     results = cmd.get_results()
     return results.rc == 0
Example #2
0
 def gpstart_and_verify(self, master_dd=os.environ.get('MASTER_DATA_DIRECTORY'), host='localhost'):
     pid = walrepl.get_postmaster_pid(master_dd, host)
     tinctest.logger.info("gpstart_verify: master dd is %s, host is %s, master pid is %s"%(master_dd,host, pid))
     if pid == -1:
         return False
     cmd_str = 'kill -s 0 {pid}'.format(pid=pid)
     cmd = SmartCmd(cmd_str, host=host)
     cmd.run()
     results = cmd.get_results()
     return results.rc == 0
Example #3
0
    def check_standby_processes(self):
        '''Check if all the standby processes are present '''

        # Get hostname and data directory of standby, if any.
        # We could use gparray, but for now let's stay away from gppylib
        with DbConn(dbname='postgres') as conn:
            results = conn.execute("""
                SELECT hostname, fselocation
                FROM gp_segment_configuration
                INNER JOIN pg_filespace_entry ON dbid = fsedbid
                WHERE fsefsoid = 3052 AND content = -1 AND role = 'm'
                """)
            # If standby is not configured, there must not be any standby processes.
            if len(results) == 0:
                return False
            host = results[0].hostname
            datadir = results[0].fselocation

        # We look for these processes that are spawned from standby postmaster.
        # They should have postmaster pid as ppid.  We minimize remote operation
        # cost by getting ps output once, and search for these strings from the
        # output lines using regexp.
        process_list = [
            'master logger process', 'startup process', 'wal receiver process'
        ]
        target_process = '(' + '|'.join(process_list) + ')'
        postmaster_pid = walrepl.get_postmaster_pid(datadir, host)
        # If postmaster does not exit, child processes are not present.
        if postmaster_pid == -1:
            return False

        # Make it string for the later comparison
        postmaster_pid = str(postmaster_pid)
        cmd = SmartCmd('ps -e -o ppid,command | grep [p]ostgres', host=host)
        cmd.run()
        standby_processes = []
        for line in cmd.get_results().stdout.splitlines(True):
            line = line.strip()
            (ppid, command) = re.split(r'\s+', line, 1)
            if ppid == postmaster_pid and re.search(target_process, command):
                standby_processes.append(line)

        # If we found more or less than expected, we don't know.
        if len(standby_processes) != len(process_list):
            return False
        tinctest.logger.info(
            'All the standby processes are present at standby host'
            '')
        return True
Example #4
0
File: verify.py Project: 50wu/gpdb
    def check_standby_processes(self):
        '''Check if all the standby processes are present '''

        # Get hostname and data directory of standby, if any.
        # We could use gparray, but for now let's stay away from gppylib
        with DbConn(dbname='postgres') as conn:
            results = conn.execute("""
                SELECT hostname, fselocation
                FROM gp_segment_configuration
                INNER JOIN pg_filespace_entry ON dbid = fsedbid
                WHERE fsefsoid = 3052 AND content = -1 AND role = 'm'
                """)
            # If standby is not configured, there must not be any standby processes.
            if len(results) == 0:
                return False
            host = results[0].hostname
            datadir = results[0].fselocation

        # We look for these processes that are spawned from standby postmaster.
        # They should have postmaster pid as ppid.  We minimize remote operation
        # cost by getting ps output once, and search for these strings from the
        # output lines using regexp.
        process_list  = ['master logger process', 'startup process', 'wal receiver process']
        target_process = '(' + '|'.join(process_list) + ')'
        postmaster_pid = walrepl.get_postmaster_pid(datadir, host)
        # If postmaster does not exit, child processes are not present.
        if postmaster_pid == -1:
            return False

        # Make it string for the later comparison
        postmaster_pid = str(postmaster_pid)
        cmd = SmartCmd('ps -e -o ppid,command | grep [p]ostgres', host=host)
        cmd.run()
        standby_processes = []
        for line in cmd.get_results().stdout.splitlines(True):
            line = line.strip()
            (ppid, command) = re.split(r'\s+', line, 1)
            if ppid == postmaster_pid and re.search(target_process, command):
                standby_processes.append(line)

        # If we found more or less than expected, we don't know.
        if len(standby_processes) != len(process_list):
            return False
        tinctest.logger.info('All the standby processes are present at standby host''')
        return True