def isSegmentUp(context, dbid): qry = """select count(*) from gp_segment_configuration where status='d' and dbid=%s""" % dbid row_count = getRows('template1', qry)[0][0] if row_count == 0: return True else: return False
def impl(context, cid): qry = """select count(*) from gp_segment_configuration where status='d' and content='%s' and role='m'""" % ( cid) row_count = getRows('template1', qry)[0][0] if row_count != 1: raise Exception( 'Expected mirror segment cid %s to be down, but it is up.' % cid)
def impl(context): qry = """select count(*) from gp_segment_configuration where status='d' and hostname='%s' and dbid=%s""" % ( context.remote_mirror_segdbname, context.remote_mirror_segdbId) row_count = getRows('template1', qry)[0][0] if row_count != 1: raise Exception( 'Expected mirror segment %s on host %s to be down, but it is running.' % (context.remote_mirror_datadir, context.remote_mirror_segdbname))
def check_pg_class_lock(dbname): seg_count = 1 query = """select count(*) from pg_locks where relation in (select oid from pg_class where relname='pg_class') and locktype='relation' and mode='ExclusiveLock'""" row_count = getRows(dbname, query)[0][0] return row_count
def impl(context, role_name, dbname): query = "select rolname from pg_roles where rolname = '%s'" % role_name conn = dbconn.connect(dbconn.DbURL(dbname=dbname)) try: result = getRows(dbname, query)[0][0] if result != role_name: raise Exception("Role %s does not exist in database %s." % (role_name, dbname)) except: raise Exception("Role %s does not exist in database %s." % (role_name, dbname))
def impl(context, backup_pg, dbname): query = """select count(*) from pg_locks where relation in (select oid from pg_class where relname='pg_class') and locktype='relation' and mode='ExclusiveLock'""" row_count = getRows(dbname, query)[0][0] if row_count != 0: raise Exception("Found a ExclusiveLock on pg_class")
def impl(context): qry = """select count(*) from gp_segment_configuration where status='d' and hostname='%s' and dbid=%s""" % (context.remote_mirror_segdbname, context.remote_mirror_segdbId) row_count = getRows('template1', qry)[0][0] if row_count != 1: raise Exception('Expected mirror segment %s on host %s to be down, but it is running.' % (context.remote_mirror_datadir, context.remote_mirror_segdbname))
def impl(context, cid): qry = """select count(*) from gp_segment_configuration where status='d' and content='%s' and role='m'""" % (cid) row_count = getRows('template1', qry)[0][0] if row_count != 1: raise Exception('Expected mirror segment cid %s to be down, but it is up.' % cid)