Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
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))
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
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))
Ejemplo n.º 7
0
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")
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
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")
Ejemplo n.º 10
0
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))
Ejemplo n.º 11
0
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))
Ejemplo n.º 12
0
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)