def __ensureStopped(self, gpEnv, directives): """ @param directives a list of the GpStopSegmentDirectoryDirective values indicating which segments to stop """ if len(directives) == 0: return self.__logger.info("Ensuring %d failed segment(s) are stopped" % (len(directives))) segments = [d.getSegment() for d in directives] segments = self._get_running_postgres_segments(segments) segmentByHost = GpArray.getSegmentsByHostName(segments) cmds = [] for hostName, segments in segmentByHost.iteritems(): cmd = gp.GpSegStopCmd("remote segment stop on host '%s'" % hostName, gpEnv.getGpHome(), gpEnv.getGpVersion(), mode='fast', dbs=segments, verbose=gplog.logging_is_verbose(), ctxt=base.REMOTE, remoteHost=hostName) cmds.append(cmd) # we suppress checking for the error. This is because gpsegstop will actually error # in many cases where the stop is actually done (that is, for example, the segment is # running but slow to shutdown so gpsegstop errors after whacking it with a kill) # # Perhaps we should make it so that it so that is checks if the seg is running and only attempt stop # if it's running? In that case, we could propagate the error # self.__runWaitAndCheckWorkerPoolForErrorsAndClear(cmds, "stopping segments", suppressErrorCheck=True)
def _stop_failed_segments(self, gpEnv): failed_reachable_segments = self._get_failed_reachable_segments() if len(failed_reachable_segments) == 0: return self.__logger.info("Ensuring %d failed segment(s) are stopped" % (len(failed_reachable_segments))) segments = self._get_running_postgres_segments( failed_reachable_segments) segmentByHost = GpArray.getSegmentsByHostName(segments) cmds = [] for hostName, segments in segmentByHost.items(): cmd = gp.GpSegStopCmd("remote segment stop on host '%s'" % hostName, gpEnv.getGpHome(), gpEnv.getGpVersion(), mode='fast', dbs=segments, verbose=gplog.logging_is_verbose(), ctxt=base.REMOTE, remoteHost=hostName, segment_batch_size=self.__parallelPerHost) cmds.append(cmd) # we suppress checking for the error. This is because gpsegstop will actually error # in many cases where the stop is actually done (that is, for example, the segment is # running but slow to shutdown so gpsegstop errors after whacking it with a kill) # # Perhaps we should make it so that it so that is checks if the seg is running and only attempt stop # if it's running? In that case, we could propagate the error # self.__runWaitAndCheckWorkerPoolForErrorsAndClear( cmds, suppressErrorCheck=True)