• J
    Decouple OID and relfilenode allocations with new relfilenode counter · 1fd11387
    Jimmy Yih 提交于
    The master allocates an OID and provides it to segments during
    dispatch. The segments then check if they can use this OID as its
    relfilenode. If a segment cannot use the preassigned OID as the
    relation's relfilenode, it will generate a new relfilenode value via
    nextOid counter. This can result in a race condition between the
    generation of the new OID and the segment file being created on disk
    after being added to persistent tables. To combat this race condition,
    we have a small OID cache... but we have found in testing that it was
    not enough to prevent the issue.
    
    To fully solve the issue, we decouple OID and relfilenode on both QD and QE
    segments by introducing a nextRelfilenode counter which is similar to
    the nextOid counter. The QD segment will generate the OIDs and its own
    relfilenodes. The QE segments only use the preassigned OIDs from the QD
    dispatch and generate a relfilenode value from their own nextRelfilenode
    counter.
    
    Current sequence generation is always done on QD sequence server, and
    assumes the OID is always same as relfilenode when handling sequence client
    requests from QE segments. It is hard to change this assumption so we have a
    special OID/relfilenode sync for sequence relations for GP_ROLE_DISPATCH and
    GP_ROLE_UTILITY.
    
    Reference gpdb-dev thread:
    https://groups.google.com/a/greenplum.org/forum/#!topic/gpdb-dev/lv6Sb4I6iSISigned-off-by: NXin Zhang <xzhang@pivotal.io>
    1fd11387
relcache.c 151.5 KB