• T
    Unify the way to fetch/manage the number of segments (#6034) · 8eed4217
    Tang Pengzhou 提交于
    * Don't use GpIdentity.numsegments directly for the number of segments
    
    Use getgpsegmentCount() instead.
    
    * Unify the way to fetch/manage the number of segments
    
    Commit e0b06678 lets us expanding a GPDB cluster without a restart,
    the number of segments may changes during a transaction now, so we
    need to take care of the numsegments.
    
    We now have two way to get segments number, 1) from GpIdentity.numsegments
    2) from gp_segment_configuration (cdb_component_dbs) which dispatcher used
    to decide the segments range of dispatching. We did some hard work to
    update GpIdentity.numsegments correctly within e0b06678 which made the
    management of segments more complicated, now we want to use an easier way
    to do it:
    
    1. We only allow getting segments info (include number of segments) through
    gp_segment_configuration, gp_segment_configuration has newest segments info,
    there is no need to update GpIdentity.numsegments, GpIdentity.numsegments is
    left only for debugging and can be removed totally in the future.
    
    2. Each global transaction fetches/updates the newest snapshot of
    gp_segment_configuration and never change it until the end of transaction
    unless a writer gang is lost, so a global transaction can see consistent
    state of segments. We used to use gxidDispatched to do the same thing, now
    it can be removed.
    
    * Remove GpIdentity.numsegments
    
    GpIdentity.numsegments take no effect now, remove it. This commit
    does not remove gp_num_contents_in_cluster because it needs to
    modify utilities like gpstart, gpstop, gprecoverseg etc, let's
    do such cleanup work in another PR.
    
    * Exchange the default UP/DOWN value in fts cache
    
    Previously, Fts prober read gp_segment_configuration, checked the
    status of segments and then set the status of segments in the shared
    memory struct named ftsProbeInfo->fts_status[], so other components
    (mainly used by dispatcher) can detect a segment was down.
    
    All segments were initialized as down and then be updated to up in
    most common cases, this brings two problems:
    
    1. The fts_status is invalid until FTS does the first loop, so QD
    need to check ftsProbeInfo->fts_statusVersion > 0
    2. gpexpand add a new segment in gp_segment_configuration, the
    new added segment may be marked as DOWN if FTS doesn't scan it
    yet.
    
    This commit changes the default value from DOWN to UP which can
    resolve problems mentioned above.
    
    * Fts should not be used to notify backends that a gpexpand occurs
    
    As Ashwin mentioned in PR#5679, "I don't think giving FTS responsibility to
    provide new segment count is right. FTS should only be responsible for HA
    of the segments. The dispatcher should independently figure out the count
    based on catalog.gp_segment_configuration should be the only way to get
    the segment count", FTS should decouple from gpexpand.
    
    * Access gp_segment_configuration inside a transaction
    
    * upgrade log level from ERROR to FATAL if expand version changed
    
    * Modify gpexpand test cases according to new design
    8eed4217
copy.c 205.7 KB