數據庫版本:12.2.0
操作系統版本:RHEL7.2
最近觀察到一個數據庫alert日志老是報硬解析太多錯誤,且對應的sql語句都是查看數據字典表:
2017-06-16T08:46:46.417468+08:00 TTEST(4):WARNING: too many parse errors, count=100 SQL hash=0x03b29074 TTEST(4):PARSE ERROR: ospid=3504, error=12850 for statement: 2017-06-16T08:46:46.417595+08:00 TTEST(4):SELECT NULL AS table_cat, o.owner AS table_schem, o.object_name AS table_name, o.object_type AS table_type, c.comments AS remarks FROM all_objects o, all_tab_comments c WHERE o.owner LIKE :1 ESCAPE '/' AND o.object_name LIKE :2 ESCAPE '/' AND o.object_type IN ('xxx', 'TABLE', 'VIEW') AND o.owner = c.owner (+) AND o.object_name = c.table_name (+) ORDER BY table_type, table_schem, table_name TTEST(4):Additional information: hd=0x64d87278 phd=0x6853e3f0 flg=0x110676 cisid=110 sid=110 ciuid=110 uid=110
看到都是數據庫內部的sql並沒有感覺會是開發的問題,檢查了對應的數據庫用戶的權限以及數據配置,但是並沒有發現有問題。
搜索了一下,發現不少網友的Hibernate程序都遇到過這個問題。
在eagle的網站中也發現類似問題:
SELECT NULL AS table_cat, c.owner AS table_schem, c.table_name, c.column_name, c.POSITION AS key_seq, c.constraint_name AS pk_name FROM all_cons_columns c, all_constraints k WHERE k.constraint_type = 'P' AND k.table_name = :1 AND k.owner LIKE :2 ESCAPE '/' AND k.constraint_name = c.constraint_name AND k.table_name = c.table_name AND k.owner = c.owner ORDER BY column_name 給出的解釋是:當JAVA程序中通過DatabaseMetaData#getPrimaryKeys()調用,將會執行這個SQL,如果不及時關閉,則還可能產生嚴重的內存占用。 看了些其它的資料,也是說的java在調用某些函數的使用應用到該語句,所以呢,最好還是讓開發排查一下。
在MOS中也發現一篇文章:
Liferay Sending Invalid Request To The Database (Doc ID 1492529.1)
給出的說明是:
By default, jdbc.default.idleConnectionTestPeriod is set to 60 and will cause C3PO to ping the database every 60 seconds to test each pooled connection and make sure it’s still alive. To configure these pings to be less frequent, increase the jdbc.default.idleConnectionTestPeriod to be a higher number, or set it to zero to disable pinging altogether (if that is the desired behavior). Changing this parameter requires a restart of the Liferay application server/application.
將該參數的默認值調大后,后台已經看不到報錯信息。但是還要繼續觀察一段時間。