• H
    Give a better error message, if preparing an xact fails. · b3c50e40
    Heikki Linnakangas 提交于
    If an error happens in the prepare phase of two-phase commit, relay the
    original error back to the client, instead of the fairly opaque
    "Abort [Prepared]' broadcast failed to one or more segments" message you
    got previously. A lot of things happen during the prepare phase that
    can legitimately fail, like checking deferred constraints, like in the
    'constraints' regression test. But even without that, there can be
    triggers, ON COMMIT actions, etc., any of which can fail.
    
    This commit consists of several parts:
    
    * Pass 'true' for the 'raiseError' argument when dispatching the prepare
      dtx command in doPrepareTransaction(), so that the error is emitted to
      the client.
    
    * Bubble up an ErrorData struct, with as many fields intact as possible,
      to the caller,  when dispatching a dtx command. (Instead of constructing
      a message in a StringInfo). So that we can re-throw the message to
      the client, with its original formatting.
    
    * Don't throw an error in performDtxProtocolCommand(), if we try to abort
      a prepared transaction that doesn't exist. That is business-as-usual,
      if a transaction throws an error before finishing the prepare phase.
    
    * Suppress the "NOTICE: Releasing segworker groups to retry broadcast."
      message, when aborting a prepared transaction.
    
    Put together, the effect is if an error happens during prepare phase, the
    client receives a message that is largely indistinguishable from the
    message you'd get if the same failure happened while running a normal
    statement.
    
    Fixes github issue #4530.
    b3c50e40
rangefuncs.out 24.5 KB