Exemplo n.º 1
0
    def getStatusUsingTransition(self, seg, statusRequest, currentPMPidData):
        """
        The data as from GpSegStatusProgram.getPidRunningStatus
        """
        if currentPMPidData is not None and \
            (currentPMPidData['pidValue'] == 0 or not currentPMPidData['lockFileExists'] or not currentPMPidData['netstatPortActive']):
            logger.warn("Error getting data from segment %s; it is not running" % seg.getSegmentDataDirectory())
            return None

        cmd = gp.SendFilerepTransitionStatusMessage("Check Status", statusRequest, seg.getSegmentDataDirectory(),
                                                seg.getSegmentPort())

        cmd.run()
        return cmd.unpackSuccessLine()
Exemplo n.º 2
0
def impl(context):
    cmd = gp.SendFilerepTransitionStatusMessage(
        name='Get segment status',
        msg=gp.SEGMENT_STATUS_GET_STATUS,
        dataDir=context.remote_pair_primary_datadir,
        port=context.remote_pair_primary_port,
        ctxt=gp.REMOTE,
        remoteHost=context.remote_pair_primary_host)
    # wait for segment state of the corresponding primary segment to complete its transition
    # the timeout depends on how soon the current cluster can complete this transition(eg: networking).
    max_try = 5
    while max_try > 0:
        cmd.run(validateAfter=False)
        if 'ChangeTrackingDisabled' in cmd.get_results().stderr:
            break
        sleep(10)
        max_try = max_try - 1
    if max_try == 0:
        raise Exception(
            'Failed to inject segment id %s into change tracking disabled state'
            % context.remote_pair_primary_segdbId)
Exemplo n.º 3
0
    def __checkLocaleAndConnect(self):
        """
        Check locale information of primaries.
        """
        self.logger.info("Validating segment locales...")

        # ask each primary for its locale details
        #
        dataDirToCmd = {}
        for datadir, seg in self.overall_status.dirmap.items():
            if seg.isSegmentPrimary(True):

                # we CANNOT validate using a psql connection because this may hang (see MPP-9974).
                #    so we validate these items using a postmaster 'transition' message
                #
                name = "Check Status"
                statusmsg = "getCollationAndDataDirSettings"
                port = seg.getSegmentPort()

                self.logger.info("Checking %s, port %s" % (datadir, port))
                cmd = gp.SendFilerepTransitionStatusMessage(
                    name, statusmsg, datadir, port)

                dataDirToCmd[datadir] = cmd
                self.pool.addCommand(cmd)

        self.pool.join()

        # examine results from the primaries
        #
        for datadir, cmd in dataDirToCmd.items():
            self.logger.info("Reviewing %s" % datadir)

            cmd.get_results()
            line = cmd.unpackSuccessLine()
            if line is None:

                msg = "Unable to connect to server"
                reasoncode = gp.SEGSTART_ERROR_CHECKING_CONNECTION_AND_LOCALE_FAILED
                self.overall_status.mark_failed(datadir, msg, reasoncode)
                continue

            dict_ = parseKeyColonValueLines(line)

            # verify was parsed, and we got all needed data
            if dict_ is None or \
                [s for s in ["datadir", "lc_collate", "lc_monetary", "lc_numeric"] if s not in dict_]:

                msg = "Invalid response from server"
                reasoncode = gp.SEGSTART_ERROR_CHECKING_CONNECTION_AND_LOCALE_FAILED
                self.overall_status.mark_failed(datadir, msg, reasoncode)
                continue

            msg = ""
            if dict_["lc_collate"] != self.expected_lc_collate:
                msg += "".join([
                    "Segment's value of lc_collate does not match the master.\n",
                    " Master had value: '",
                    str(self.expected_lc_collate),
                    "' while this segment has: '",
                    str(dict_["lc_collate"]), "'\n"
                ])

            if dict_["lc_monetary"] != self.expected_lc_monetary:
                msg += "".join([
                    "Segment's value of lc_monetary does not match the master.\n",
                    " Master had value: '",
                    str(self.expected_lc_monetary),
                    "' while this segment has: '",
                    str(dict_["lc_monetary"]), "'\n"
                ])

            if dict_["lc_numeric"] != self.expected_lc_numeric:
                msg += "".join([
                    "Segment's value of lc_numeric does not match the master.\n",
                    " Master had value: '",
                    str(self.expected_lc_numeric),
                    "' while this segment has: '",
                    str(dict_["lc_numeric"]), "'\n"
                ])

            if not os.path.samefile(dict_["datadir"], datadir):
                msg += "".join([
                    "Segment's data directory does not match. ",
                    " Expected value: '",
                    str(datadir), "' Actual value: '",
                    str(dict_["datadir"]), "'\n"
                ])

            if len(msg) > 0:
                reasoncode = gp.SEGSTART_ERROR_CHECKING_CONNECTION_AND_LOCALE_FAILED
                self.overall_status.mark_failed(datadir, msg, reasoncode)