最近開發組同事使用Azure的Function App訪問公司內部的Oracle資料庫時,偶爾會遇到“ORA-12537: Network Session: End of file”這個錯誤。關於ORA-12537的詳細信息如下: [oracle@DB-Server ~]$ oerr ora 125... ...
最近開發組同事使用Azure的Function App訪問公司內部的Oracle資料庫時,偶爾會遇到“ORA-12537: Network Session: End of file”這個錯誤。關於ORA-12537的詳細信息如下:
[oracle@DB-Server ~]$ oerr ora 12537
12537, 00000, "TNS:connection closed"
// *Cause: "End of file" condition has been reached; partner has disconnected.
// *Action: None needed; this is an information message.
按照官方文檔,引起ORA-12537的錯誤原因很多,如下所示:
ORA-12537 is an informational message and means that the connection has been closed. This error message can happen due to any of the following reasons:
- There are too many connections being open by the application.
- There are configuration issues in the sqlnet.ora, protocol.ora and listener.ora files.
- Database is shut down (maybe for nightly backup), but connection to database was kept by client.
- A timeout occurred on the client connection.
- A firewall closed idle connections.
- There is a path name that is too long for the Oracle TNS client on Windows. See Note:263489.1
一一分析、排除後,懷疑我設定的一個定期清理超過90分鐘空閑會話的作業導致了這個問題,具體參考“ORACLE定期清理INACTIVE會話”,測試了一下,我們通過V$SESSION找到對應的會話,然後使用下麵SQL終止會話。
SQL> ALTER SYSTEM DISCONNECT SESSION 'xxx,xxx' IMMEDIATE;
Azure的Function App測試驗證發現報“ORA-12537: Network Session: End of file” 。註意:ALTER SYSTEM KILL SESSION 'xxx,xxx' IMMEDIATE;也是同樣的錯誤。
但是如果你使用SQL*Plus等工具(使用SQL*Net連接資料庫),測試發現報ORA-03113:通信通道的文件結尾“,而不是ORA-12537這個錯誤,如下所示:
查了一下官方文檔關於Azure的Function(Function App)連接資料庫的相關知識,因為連接池緣故,應用程式關閉會話後,連接池對應的資料庫會話一直處於INACTIVE狀態,而當達到條件時(空閑時間超過90分鐘),就被作業清理掉,而此時如果Azure的Function應用再次訪問資料庫時,由於連接池的相關會話被清理掉了,從而報錯。