SQL*Net break/reset to client (%)等待事件


 某客戶通過監控發現某一套Oracle DB在一個時間段內的,異常指標!需要進行分析

 

使用如下SQL進行診斷,發現TOP EVENT 是SQL*Net break/reset to client
SQL>select
instance_number,event,count(*) from dba_hist_active_sess_history
where SAMPLE_TIME between to_date('2020-02-25 06','yyyy-mm-dd hh24') and
to_date('2020-02-25 09','yyyy-mm-dd hh24') and
having(count(*))>200 group by instance_number,event order by 2;

 

查詢11g官方文檔獲取該等待事件解釋說明,基本上與應用執行的程序=SQL有關系
SQL*Net break/reset to client (%) Description The server is sending a break or reset message to the client. The session running on the server is waiting for a reply
from the client. These waits are caused by an application attempting to: Select from a closed cursor Select on a cursor after the last row has already been fetched and no data has been returned Select on a non-existent table Insert a duplicate row into a uniquely indexed table Issuing a query with invalid syntax If the value, v$session_wait.p2, for this parameter equals 0, it means a reset was sent to the client. A non-zero value
means that the break was sent to the client.

 

使用如下SQL 可以查詢到執行SQL的用戶ID=DBA_USER USER_ID=>USERNAME   以及SQL_id
SQL>select
event,USER_ID,sql_id,count(*) from dba_hist_active_sess_history where SAMPLE_TIME
between to_date('2020-02-25 06','yyyy-mm-dd hh24') and to_date('2020-02-25 09','yyyy-mm-dd hh24')
and instance_number=1 and event='SQL*Net break/reset to client' group by USER_ID,event,sql_id order by 2;
數據庫並未找到SQL文本,但是該庫存在監控,通過監控輸入SQL_ID找到SQL_TEXT 發現是查詢視圖!

由於本次問題,開發人員自己處理了,因此並未造成影響。開發也並未反饋是什么原因。如下進行測試模擬參考文檔!
https://tanelpoder.com/2008/04/10/sqlnet-breakreset-to-client/

 

如下是測試內容
SQL> select event, total_waits from v$session_event where event like '%reset%' and sid = (select sid from v$mystat where rownum = 1); SQL> begin execute immediate 'drop table non_existent'; exception when others then null; end; / SQL> select event, total_waits from v$session_event where event like '%reset%' and sid = (select sid from v$mystat where rownum = 1); null
上述可以發現,當查詢一個不存在的表,但是PLSQL存在異常處理部分,並不會出現本次測試的等待事件!
SQL
> begin execute immediate 'drop table non_existent'; end; / SQL> select event, total_waits from v$session_event where event like '%reset%' and sid = (select sid from v$mystat where rownum = 1); EVENT TOTAL_WAITS ------------------------------ ----------- SQL*Net break/reset to client 2
上述可以發現,當查詢一個不存在的表,但是PLSQL不存在異常處理部分,該等待事件出現!

查詢一個不存在的表!
SQL> select * from non_existent;
select * from non_existent
              *
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> select event, total_waits from v$session_event where event like '%reset%' and sid = (select sid from v$mystat where rownum = 1);
EVENT                          TOTAL_WAITS
------------------------------ -----------
SQL*Net break/reset to client            4

創建一個表,后置查詢一個不存在的表!
SQL> create table a as select * from employees;
create table a as select * from employees
                                *
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> select event, total_waits from v$session_event where event like '%reset%' and sid = (select sid from v$mystat where rownum = 1);
EVENT                          TOTAL_WAITS
------------------------------ -----------
SQL*Net break/reset to client            6


查詢一個視圖,視圖對應的表被刪除
SQL> create table a as select * from hr.employees;
SQL> create view a_t as select EMPLOYEE_ID,FIRST_NAME from a;
SQL> drop table a;
SQL> select event, total_waits from v$session_event where event like '%reset%' and sid = (select sid from v$mystat where rownum = 1);
EVENT                          TOTAL_WAITS
------------------------------ -----------
SQL*Net break/reset to client            6

SQL> select * from a_t;
select * from a_t
              *
ERROR at line 1:
ORA-04063: view "SYS.A_T" has errors
SQL> select event, total_waits from v$session_event where event like '%reset%' and sid = (select sid from v$mystat where rownum = 1);

EVENT                          TOTAL_WAITS
------------------------------ -----------
SQL*Net break/reset to client            8

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM