Thứ Ba, 28 tháng 3, 2023

Các câu lệnh kiểm tra, xử lý với giao dịch phân tán (giao dịch qua database link) trong Oracle Database

Mục đích: Các câu lệnh kiểm tra, xử lý với giao dịch phân tán (giao dịch qua database link) trong Oracle Database

/**********************DISTRIBIUTED TRANSACTION **************************/
-- KIỂM TRA
---///////ORA-01591: lock held by in-doubt distributed transaction 10.1.10741505, xy ly tren sqlplus
select * from sys.pending_trans$;

select * from DBA_2PC_PENDING;

select * from DBA_2PC_NEIGHBORS;

743.30.1421878
1896.9.233248
2780.32.722288
3127.12.110519

SELECT   local_tran_id, state
              FROM   DBA_2PC_PENDING
              where (retry_time-fail_time)*24*60>1.5; --chờ hơn 1.5 phút

-- XỬ LÝ
commit force '3127.12.110519'
--rollback force '75.1.3697342'
execute dbms_transaction.purge_lost_db_entry('3127.12.110519');
commit;



-- THỦ TỤC KILL LOCK DBLINK TỰ ĐỘNG
 declare
 CURSOR c1
        IS
            SELECT   local_tran_id, state
              FROM   DBA_2PC_PENDING
              where (retry_time-fail_time)*24*60>1.5; --chờ hơn 1.5 phút
    BEGIN
        /*FOR r1 IN c1
        LOOP

            dbms_output.put_line('1');
            EXECUTE IMMEDIATE 'rollback force '''
                     || r1.local_tran_id
                     || '''';
            commit;
        end loop;*/

        FOR r2 IN c1
        LOOP
            if r2.state in ('committed') then
                EXECUTE IMMEDIATE 'begin
                dbms_transaction.purge_lost_db_entry('''
                         || r2.local_tran_id
                         || ''');
                commit;
                end;';
                commit;
             elsif r2.state='prepared' then
                EXECUTE IMMEDIATE 'rollback force '''
                     || r2.local_tran_id
                     || '''';
                commit;
                EXECUTE IMMEDIATE 'begin
                dbms_transaction.purge_lost_db_entry('''
                         || r2.local_tran_id
                         || ''');
                commit;
                end;';
                commit;
             else
                EXECUTE IMMEDIATE 'begin
                dbms_transaction.purge_lost_db_entry('''
                         || r2.local_tran_id
                         || ''');
                commit;
                end;';
                commit;

             end if;
        end loop;
    END;

Chi tiết các câu lệnh monitor giám sát mọi database tại: [VIP] Bí quyết Giám sát mọi cơ sở dữ liệu Oracle Database
=============================
* KHOÁ HỌC ORACLE DATABASE A-Z ENTERPRISE trực tiếp từ tôi giúp bạn bước đầu trở thành những chuyên gia DBA, đủ kinh nghiệm đi thi chứng chỉ OA/OCP, đặc biệt là rất nhiều kinh nghiệm, bí kíp thực chiến trên các hệ thống Core tại VN chỉ sau 1 khoá học.
* CÁCH ĐĂNG KÝ: Gõ (.) hoặc để lại số điện thoại hoặc inbox https://m.me/tranvanbinh.vn hoặc Hotline/Zalo 090.29.12.888
* Chi tiết tham khảo:
https://bit.ly/oaz_w
=============================
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH:
📧 Mail: binhoracle@gmail.com
☎️ Mobile/Zalo: 0902912888
👨 Facebook: https://www.facebook.com/BinhOracleMaster
👨 Inbox Messenger: https://m.me/101036604657441 (profile)
👨 Fanpage: https://www.facebook.com/tranvanbinh.vn
👨 Inbox Fanpage: https://m.me/tranvanbinh.vn
👨👩 Group FB: https://www.facebook.com/groups/DBAVietNam
👨 Website: https://www.tranvanbinh.vn
👨 Blogger: https://tranvanbinhmaster.blogspot.com
🎬 Youtube: http://bit.ly/ytb_binhoraclemaster
👨 Tiktok: https://www.tiktok.com/@binhoraclemaster?lang=vi
👨 Linkin: https://www.linkedin.com/in/binhoracle
👨 Twitter: https://twitter.com/binhoracle
👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội

=============================
Các câu lệnh kiểm tra, xử lý với giao dịch phân tán (giao dịch qua database link), oracle tutorial, học oracle database, Tự học Oracle, Tài liệu Oracle 12c tiếng Việt, Hướng dẫn sử dụng Oracle Database, Oracle SQL cơ bản, Oracle SQL là gì, Khóa học Oracle Hà Nội, Học chứng chỉ Oracle ở đầu, Khóa học Oracle online,sql tutorial, khóa học pl/sql tutorial, học dba, học dba ở việt nam, khóa học dba, khóa học dba sql, tài liệu học dba oracle, Khóa học Oracle online, học oracle sql, học oracle ở đâu tphcm, học oracle bắt đầu từ đâu, học oracle ở hà nội, oracle database tutorial, oracle database 12c, oracle database là gì, oracle database 11g, oracle download, oracle database 19c, oracle dba tutorial, oracle tunning, sql tunning , oracle 12c, oracle multitenant, Container Databases (CDB), Pluggable Databases (PDB), oracle cloud, oracle security, oracle fga, audit_trail,oracle RAC, ASM, oracle dataguard, oracle goldengate, mview, oracle exadata, oracle oca, oracle ocp, oracle ocm , oracle weblogic, postgresql tutorial, mysql tutorial, mariadb tutorial, sql server tutorial, nosql, mongodb tutorial, oci, cloud, middleware tutorial, hoc solaris tutorial, hoc linux tutorial, hoc aix tutorial, unix tutorial, securecrt, xshell, mobaxterm, putty

ĐỌC NHIỀU

Trần Văn Bình - Oracle Database Master