Two-Pipe Resource Manager Connection

 

Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

  1. The application calls SQLConnect in the ODBC driver manager, passing the Data Source Name (DSN), user identifier, and Authentication string.

  2. The ODBC driver manager calls SQLConnect in the ODBC driver.

  3. The ODBC driver connects to the resource manager. Typically, the ODBC driver opens a non-transactional resource manager connection because it does not yet know whether the connection requires a transaction.

  4. The ODBC driver manager calls SQLSetConnectAttr(SQL_ATTR_ENLIST_IN_the DTC, pITransaction) in the ODBC driver, instructing the ODBC driver to enlist in the specified transaction.

  5. If the ODBC driver already has a transactional connection open to the resource manager, it proceeds directly to two-pipe resource manager enlistment. If the ODBC driver has a non-transactional connection open to the resource manager, it closes it and creates a new transactional resource manager connection as described in step 6.

  6. The ODBC driver calls theDtcGetTransactionManager procedure in the DTC proxy to establish a connection to the transaction manager. The resource manager specifies the name and location of the transaction manager it wants to use, usually specifying NULL values for these parameters. If Null values are specified, the DTC proxy establishes a connection with the default DTC transaction manager, the name of which is contained in the system registry.

  7. The DtcGetTransactionManager system call is implemented by the DTC proxy. The DTC proxy returns a pointer to the IUnknown interface of the DTC proxy core object.

  8. The ODBC driver invokes QueryInterface on the DTC proxy core object to obtain the IDtcToXaMapper interface.

  9. The ODBC driver opens a new transactional connection to the resource manager by sending an xa_open_entry message to it.

  10. The ODBC driver invokes IDtcToXaMapper::RequestNewResourceManager, passing in the DSN name and the ODBC driver DLL name.

  11. The DTC proxy sends the DSN and ODBC driver DLL names to the DTC transaction manager.

  12. The DTC transaction manager connects to the resource manager. This creates the connection used to send xa_prepare_entry and xa_commit_entry messages to the resource manager. It also ensures that the transaction manager can reconnect to the resource manager if recovery is necessary The transaction manager then records the information needed to reestablish the connection in its log file.

    • The DTC transaction manager calls the Win32 LoadLibrary function to load the ODBC driver DLL. It calls the Windows DLL function GetProcAddress to obtain the address of the GetXaSwitch function, which it calls to obtain the address of the XA switch data structure implemented by the ODBC driver.

    • The DTC transaction manager connects to the resource manager by calling xa_open_entry.

    • The DTC transaction manager generates a resource manager GUID for each connection request it receives and writes a record to the DTCXATM.LOG file indicating that a new resource manager connection is being established. The log record contains the DSN name, the name of the ODBC driver DLL, and the resource manager GUID. The transaction manager uses this information to reconnect to the resource manager if recovery is necessary.

    • The transaction manager returns the resource manager GUID it generated to the DTC proxy.

  13. The DTC proxy calls the DTC Connection Manager to establish a connection to the transaction manager.

  14. The transaction manager creates an internal object to represent the connection between the resource manager and the transaction manager and then returns to the DTC proxy.

  15. The DTC proxy creates a resource manager object and returns an opaque pointer to that object as the RMCookie, which represents the connection to the transaction manager.