3.4.7.6 Recover XA Resource Manager

The Recover XA Resource Manager event MUST be signaled with the following arguments:

If the Recover XA Resource Manager event is signaled, the XA Resource Manager Bridge Facet MUST perform the following actions:

  • Set the State field of the provided XA Resource Manager object to Recovering.

  • Create a local Recovery Flags variable that is set to TMSTARTRSCAN.

  • For each XA Subordinate Enlistment object in the XA Subordinate Enlistment Table referenced by the provided XA Resource Manager object:

    • Set the State field of the XA Subordinate Enlistment object to Ended.

    • Remove the XA Subordinate Enlistment object from the XA Subordinate Enlistment Table referenced by the provided XA Resource Manager object.

  • Call xa_open on the XA Switch referenced by the XA Resource Manager object with the following arguments:

    • The Data Source Name field of the provided XA Resource Manager object.

    • The XA Resource Manager Identifier field of the provided XA Resource Manager object.

    • TMNOFLAGS.

  • If the result is set to XA_OK:

    • Repeat the following steps until the return value from xa_recover is less than 10 or the result of the call is XAER_RMERR, XAER_RMFAIL, XAER_INVAL, or XAER_PROTO. If the value returned is less than 10, follow the steps, but do not repeat them.

      • Call xa_recover on the XA Switch of the provided XA Resource Manager with the following arguments:

        • XA_UOW xidbuffer[10]

        • 10

        • XA Resource Manager Identifier field of the XA Resource Manager object

        • Recovery Flags

      • If the Outcome is not set to XAER_RMERR, XAER_RMFAIL, XAER_INVAL, or XAER_PROTO:

        • Set Recovery Flags to TMNOFLAGS.

        • Repeat the following steps for each of the XIDs passed back in xidbuffer:

          • Test if the following set of conditions is met:

            • XID from xidbuffer has XA_BQUAL_1 with XATMGUID set to XA Transaction Manager GUID.

            • XID from xidbuffer has XA_BQUAL_1 with RMguid set to Resource Manager Global Identifier of the XA Resource Manager object.

          • If the conditions are satisfied:

            • Attempt to find a transaction in the Transaction Table referenced by the Core Transaction Manager Facet which has Transaction Identifier equal to the XA Global Transaction Identifier contained within the Data field of the XA_XID structure (section 2.2.1.3) contained within the XAIdentifier field of the XA_UOW structure (section 2.2.1.4) contained within the xidbuffer.

            • If found:

              • If the State of the found Transaction is set to Committed:

                • Call xa_commit on the XA Switch of the provided XA Resource Manager object with the following arguments:

                  • The XID from xidbuffer.

                  • The XA Resource Manager Identifier field of the provided XA Resource Manager object.

                  • TMNOFLAGS.

                • If the Outcome is set to XA_RETRY:

                  • Initialize a Recovery Interval Timer (section 3.4.2.1) with a time out of the Recovery Interval field of the provided XA Resource Manager object and the following argument: The provided XA Resource Manager object.

                  • The Recovery Interval field of the provided XA Resource Manager object SHOULD be set to double its previous value, with a ceiling of XaTmMaxWarmRecoveryInterval.<52>

                • Otherwise,if the Outcome is set to either XA_HEURCOM or XA_OK:

                  • Continue to next XID to be recovered.

                • Otherwise:

                  • Set the State field of the XA Resource Manager object to Ended.

                  • Remove the provided XA Resource Manager object from the XA Resource Manager Durable Log.

                  • Remove the provided XA Resource Manager object from the XA Resource Manager Table.

                  • If Pending Open Connections Table referenced by the XA Resource Manager object is not empty, the following actions MUST be performed on each XA Resource Manager CMP Connection in the Pending Open Connections Table referenced by the XA Resource Manager object:
                    (1) Remove the XA Resource Manager CMP Connection from the Pending Open Connections Table referenced by the XA Resource Manager object.
                    (2) If the Outcome of the xa_commit call was XAER_PROTO, send an XATMUSER_MTAG_E_RMPROTOCOL message on the XA Resource Manager CMP Connection; otherwise, send an XATMUSER_MTAG_E_RMOPENFAILED message on the XA Resource Manager CMP Connection.
                    (3) Set the State field of the XA Resource Manager CMP Connection to Ended.

                  • Terminate the processing for this event.

              • Otherwise:

                • Continue to the next XID to be recovered.

            • Otherwise:

              • Call xa_rollback on the XA Switch of the provided XA Resource Manager object with the following arguments:

                • The XID from xidbuffer.

                • The XA Resource Manager Identifier field of the provided XA Resource Manager object.

                • TMNOFLAGS.

              • If the Outcome is set to either XA_HEURRB, XA_OK, or XA_RB*:

                • Continue to next XID to be recovered.

              • Otherwise:

                • Set the State field of the XA Resource Manager object to Ended.

                • Remove the provided XA Resource Manager object from the XA Resource Manager Durable Log.

                • Remove the provided XA Resource Manager object from the XA Resource Manager Table.

                • If Pending Open Connections Table referenced by the XA Resource Manager object is not empty:

                  • The following actions MUST be performed on each XA Resource Manager CMP Connection in the Pending Open Connections Table referenced by the XA Resource Manager object:
                    (1) Remove the XA Resource Manager CMP Connection from the Pending Open Connections Table referenced by the XA Resource Manager object.
                    (2) If the Outcome of the xa_rollback call was XAER_PROTO, send an XATMUSER_MTAG_E_RMPROTOCOL message on the XA Resource Manager CMP Connection; otherwise, send an XATMUSER_MTAG_E_RMOPENFAILED message on the XA Resource Manager CMP Connection.
                    (3) Set the State field of the XA Resource Manager CMP Connection to Ended.

                • Terminate the processing for this event.

      • Otherwise:

        • Proceed with the following processing.

    • Call xa_close on the XA Switch of the provided XA Resource Manager object with the following arguments:

      • The Data Source Name of the provided XA Resource Manager object.

      • The XA Resource Manager Identifier of the XA Resource Manager object.

      • TMNOFLAGS.

    • If the Pending Open Connections Table referenced by the XA Resource Manager object is empty:

      • Remove the provided XA Resource Manager object from the XA Resource Manager Durable Log.

      • Remove the provided XA Resource Manager object from the XA Resource Manager Table.

      • Set the State field of the XA Resource Manager object to Ended.

    • Otherwise:

      • Set the State field of the XA Resource Manager object to Active.

      • If Pending Open Connections Table referenced by the XA Resource Manager object is not empty:

        • The following actions MUST be performed on each XA Resource Manager CMP Connection in the Pending Open Connections Table referenced by the XA Resource Manager object:

          • Remove the XA Resource Manager CMP Connection from the Pending Open Connections Table referenced by the XA Resource Manager object.

          • Add the XA Resource Manager CMP Connection to the Request Connections Table referenced by the XA Resource Manager.

          • Set the State field of the Connection to Active.

          • Send an XATMUSER_MTAG_RMOPENOK message (section 2.2.3.2.6) on the Connection with the following settings:

            • The localRmId field is set to the XA Resource Manager Identifier field of the XA Resource Manager object.

            • The guidRm field is set to the Resource Manager Global Identifier field of the XA Resource Manager object.

  • Otherwise if Outcome is XAER_RMERR:

    • Initialize a Recovery Interval Timer with a time out of the Recovery Interval field of the provided XA Resource Manager object and the following argument:

      • The provided XA Resource Manager object.

    • Recovery Interval field of the provided XA Resource Manager SHOULD be set to double its previous value, with a ceiling of XaTmMaxWarmRecoveryInterval.<53>

  • Otherwise:

    • Remove the provided XA Resource Manager object from the XA Resource Manager Durable Log.

    • Remove the provided XA Resource Manager object from the XA Resource Manager Table.

    • If Pending Open Connections Table referenced by the XA Resource Manager object is not empty:

      • The following actions MUST be performed on each XA Resource Manager CMP Connection in the Pending Open Connections Table referenced by the XA Resource Manager object:

        • Remove the XA Resource Manager CMP Connection from the Pending Open Connections Table referenced by the XA Resource Manager object.

        • If the Outcome of the xa_open call was XAER_PROTO:

          • Send an XATMUSER_MTAG_E_RMPROTOCOL message on the XA Resource Manager CMP Connection.

        • Otherwise:

          • Send an XATMUSER_MTAG_E_RMOPENFAILED message on the XA Resource Manager CMP Connection.

        • Set the State field of the XA Resource Manager CMP Connection to Ended.