ORA-24777: Use of Non-Migratable Database Link Not Allowed
ORA-24777: Use of Non-Migratable Database Link Not Allowed
Section titled “ORA-24777: Use of Non-Migratable Database Link Not Allowed”Error Overview
Section titled “Error Overview”Error Text: ORA-24777: use of non-migratable database link not allowed
ORA-24777 occurs when a session using shared server (MTS) or distributed XA transactions attempts to use a database link that does not support transaction migration between processes. Distributed transactions in shared server mode require migratable links so different shared servers can pick up the same transaction.
Understanding Migratable vs Non-Migratable Links
Section titled “Understanding Migratable vs Non-Migratable Links”| Type | Created With | Behavior |
|---|---|---|
| Non-migratable | CONNECT TO user IDENTIFIED BY pwd | Tied to the connecting session’s process |
| Migratable | CONNECT TO CURRENT_USER or shared via XA | Can be used by any shared server |
In dedicated server mode, all links work fine. In shared server mode, only migratable links work for distributed transactions because each call may be served by a different shared server process.
Common Causes
Section titled “Common Causes”Shared Server Mode + Non-Migratable Link
Section titled “Shared Server Mode + Non-Migratable Link”- Database configured with shared servers
- Application uses traditional
CONNECT TO user IDENTIFIED BY pwdlink - Distributed transaction spans multiple SQL calls
XA Transactions
Section titled “XA Transactions”- Application server uses XA distributed transactions
- Database link not configured for XA participation
- Mixed local and global transactions
Application Server Pool
Section titled “Application Server Pool”- Connection pool returns different physical connections
- Transaction context lost between calls
- Implicit XA behavior in J2EE/Tuxedo
Diagnostic Steps
Section titled “Diagnostic Steps”Check Connection Mode
Section titled “Check Connection Mode”-- See if session is dedicated or sharedSELECT sid, server, type, statusFROM v$sessionWHERE audsid = USERENV('SESSIONID');
-- SERVER = 'DEDICATED' or 'SHARED'
-- Check shared server configSHOW PARAMETER shared_servers;SHOW PARAMETER dispatchers;Inspect Database Link Definition
Section titled “Inspect Database Link Definition”-- View link configurationSELECT db_link, username, host, createdFROM dba_db_linksWHERE db_link LIKE 'TARGET%';
-- A link with username defined is non-migratable-- A link with empty username (CURRENT_USER) is migratableCheck Active Distributed Transactions
Section titled “Check Active Distributed Transactions”-- See in-flight distributed transactionsSELECT * FROM v$global_transaction;
SELECT local_tran_id, global_tran_id, stateFROM dba_2pc_pending;Resolution Steps
Section titled “Resolution Steps”1. Use Migratable (CURRENT_USER) Database Link
Section titled “1. Use Migratable (CURRENT_USER) Database Link”-- Drop non-migratable linkDROP DATABASE LINK target_db;
-- Create migratable link using CURRENT_USERCREATE DATABASE LINK target_dbCONNECT TO CURRENT_USERUSING 'TARGET_TNS';
-- Each user must exist on remote DB with same authenticationNote: CURRENT_USER links require remote DB to recognize the local user (often via global users with enterprise security).
2. Switch Session to Dedicated Server
Section titled “2. Switch Session to Dedicated Server”# Use TNS entry that forces dedicated server# tnsnames.oraTARGET_DEDICATED = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = service) (SERVER = DEDICATED) ) )-- Application connects to dedicated TNS aliassqlplus user/pwd@target_dedicated3. Configure XA-Compatible Setup
Section titled “3. Configure XA-Compatible Setup”-- Grant XA privilegesGRANT SELECT ON sys.dba_pending_transactions TO xa_user;GRANT EXECUTE ON sys.dbms_xa TO xa_user;GRANT FORCE ANY TRANSACTION TO xa_user;
-- Confirm XA supportSELECT * FROM v$option WHERE parameter = 'XA';For application servers using XA:
- Configure datasource as XA datasource (e.g.,
OracleXADataSource) - Ensure database link uses authentication compatible with XA
4. Refactor to Avoid Distributed Transaction
Section titled “4. Refactor to Avoid Distributed Transaction”If feasible, eliminate the distributed transaction:
-- Instead of cross-DB transaction:INSERT INTO local_table VALUES (...);INSERT INTO remote_table@target_db VALUES (...);COMMIT; -- distributed commit
-- Use local staging + Oracle Streams/GoldenGate replication:INSERT INTO local_table VALUES (...);INSERT INTO local_replication_queue VALUES (...);COMMIT;-- Async replication handles cross-DB delivery5. Connect User Configuration
Section titled “5. Connect User Configuration”For migratable CONNECT TO CURRENT_USER:
-- On remote DB, ensure local users existCREATE USER app_user IDENTIFIED EXTERNALLY;GRANT CONNECT, RESOURCE TO app_user;
-- Or use enterprise users via OIDCommon Scenarios
Section titled “Common Scenarios”Scenario 1: Application Server with Shared Servers
Section titled “Scenario 1: Application Server with Shared Servers”WebLogic uses XA datasource. DB has shared_servers > 0.Cross-DB transaction → ORA-24777Fix: Either disable shared servers, or recreate links as CONNECT TO CURRENT_USER.
Scenario 2: Tuxedo Distributed Transactions
Section titled “Scenario 2: Tuxedo Distributed Transactions”Tuxedo /Q application updates two databases via XA.ORA-24777: use of non-migratable database link not allowedFix: Configure XA-compliant link or use single XA datasource.
Scenario 3: Reporting Tool Hits Shared Server
Section titled “Scenario 3: Reporting Tool Hits Shared Server”Crystal Reports → Oracle (shared server) → DB link → remote DBFix: Use dedicated server connection for reporting; shared server poorly suited for distributed reads.
Sample Output
Section titled “Sample Output”SQL> COMMIT;COMMIT*ERROR at line 1:ORA-24777: use of non-migratable database link not allowed
SQL> SELECT server FROM v$session WHERE audsid = USERENV('SESSIONID');SERVER---------SHARED
SQL> SELECT db_link, username FROM dba_db_links WHERE db_link = 'TARGET_DB';DB_LINK USERNAME----------- ----------TARGET_DB APP_USER
-- Non-migratable: USERNAME populated. Recreate as CURRENT_USER.SQL> DROP DATABASE LINK target_db;SQL> CREATE DATABASE LINK target_db CONNECT TO CURRENT_USER USING 'TARGET';Database link created.Prevention Strategies
Section titled “Prevention Strategies”Architecture Decisions
Section titled “Architecture Decisions”- Choose dedicated server for applications using DB links extensively
- Avoid mixing shared server and distributed transactions
- Use enterprise users + global authentication for
CURRENT_USERlinks
Connection Pool Configuration
Section titled “Connection Pool Configuration”<!-- WebLogic XA datasource example --><jdbc-data-source> <name>OracleXA</name> <jdbc-driver-params> <driver-name>oracle.jdbc.xa.client.OracleXADataSource</driver-name> <url>jdbc:oracle:thin:@host:1521:service</url> </jdbc-driver-params></jdbc-data-source>Link Audit
Section titled “Link Audit”-- Identify non-migratable links that may break with shared serverSELECT db_link, username, CASE WHEN username IS NULL THEN 'MIGRATABLE' ELSE 'NON-MIGRATABLE' END AS link_typeFROM dba_db_links;Use TNS Aliases for Mode Selection
Section titled “Use TNS Aliases for Mode Selection”# dedicated for app serverTARGET_DEDICATED = (... (SERVER=DEDICATED) ...)
# shared for OLTPTARGET_SHARED = (... (SERVER=SHARED) ...)Related Errors
Section titled “Related Errors”- ORA-02049: Distributed lock timeout
- ORA-02050: Transaction rolled back, remote DBs may be in-doubt
- ORA-02063: Preceding line from database link
- ORA-02068: Following severe error from database link
- ORA-24756: Transaction does not exist
Troubleshooting Checklist
Section titled “Troubleshooting Checklist”- Verify session uses shared or dedicated server (
v$session.server) - Check link type (non-migratable if username populated)
- Review shared server parameters
- Recreate link as
CONNECT TO CURRENT_USERfor migratability - Configure XA datasource for application server
- Consider dedicated server for distributed-transaction workloads