BacGyber's Tricks

[solved] Oracle 접속 WAS 로그에서 SQLRecoverableException 발생

□ Tech (Software)

최근 오픈한 시스템에서 겪은 내용 간단히 정리합니다.


일부 사용자들이 웹페이지가 안열린다는 얘기가 있었습니다.


WAS 로그를 확인해봤는데 

두대중 한대의 WAS 로그에서 이러한 내용이 있었습니다. 



java.sql.SQLRecoverableException: I/O Exception: Connection reset



구글링했더니 도움이 될만한 검색결과가 여러개 나왔던거 같습니다.

그 중 오라클 커뮤니티 게시물 내용이 깔끔한거 같아 복사해둡니다.


I was recently struggling with this exact same problem. I opened a ticket with Oracle and this is what they told me.


java.security.SecureRandom is a standard API provided by sun. Among various methods offered by this class void

nextBytes(byte[])

is one. This method is used for generating random bytes. Oracle 11g JDBC drivers use this API to generate random number during

login. Users using Linux have been encountering SQLException("Io exception: Connection

reset").


The problem is two fold


1. The JVM tries to list all the files in the /tmp (or alternate tmp directory set by -Djava.io.tmpdir) when

SecureRandom.nextBytes(byte[]) is invoked. If the number of files is large the

method takes a long time to respond and hence cause the server to timeout


2. The method void nextBytes(byte[]) uses /dev/random on Linux and on some machines which lack the random

number generating hardware the operation slows down to the extent of bringing the whole login process to

a halt. Ultimately the the user encounters SQLException("Io exception: Connection reset")


Users upgrading to 11g can encounter this issue if the underlying OS is Linux which is running on a faulty hardware.


Cause

The cause of this has not yet been determined exactly. It could either be a problem in

your hardware or the fact

that for some reason the software cannot read from dev/random



Solution 

Change the setup for your application, so you add the next parameter to the java command:


-Djava.security.egd=file:/dev/../dev/urandom




We made this change in our java.security file and it has gotten rid of the error.





* 내용을 보면... Linux 상에서 파라미터를 조정하여도 해결될 확률은 있는거 같군요.

  어떤 이유인건 간에... Linux 상의 부하로 인해 발생할 수 있는 상황 같기도 하구요.

  적용한 이유 문제가 없는걸 보면... 이번 경우는 위의 두가지 유형중 두번째에 해당하는 확률이 높은것 같습니다.  



* 환경 정보 요약

Linux Server상의 JEUS 에서 Oracle 12C 에 연결

 


Oracle SQL Developer 재접속 설정, Toad 재접속 설정

□ Tech (General), Digital

Toad 를 사용하는데 오라클 세션 타임아웃으로 인해.... 하루에 여러번 Reconnect 를 하고 있다.  해당 DB는 고객쪽 DB라 설정은 바꿀수 없는 상황.


하여 분노의 구글링을 해보니...


Toad for Oracle 의 경우... version 12 이상에서만 재접속 기능이 있는거 같다.

현재 버젼은 v11 이라 재접속 기능은 포기...


그래서 SQL Developer 에 있지 않을까 싶어서 오랜만에 설치를 해봤는데 해당 기능은 보이지 않는다.


그래서 좀 더 구글링을 해보니 

재접속 기능 Plugin 을 발견!! 설치했더니 잘 됨~



SQL Developer 의 경우 Java Version 을 고려해서 설치해야 함.


2016.08.11 현재

최종 버젼 : sqldeveloper-4.1.3.20.78-x64.zip

  * Java 1.8 이상이어야 한다고 되어 있음.

    내 경우 1.8도 깔려있지만 기본 설정은 1.7 로 잡혀있는데...

    아무튼 설치후 특별한 기능은 안써보고 쿼리 실행을 해봤는데 잘 된다.


Java 1.7 환경에서의 최종버젼 : sqldeveloper-4.0.3.16.84-x64.zip




재접속 Plugin


아래 경로에서 Download 가능

http://scristalli.github.io/SQL-Developer-4-keepalive/

https://github.com/scristalli/SQL-Developer-4-keepalive/releases


설치후 

상단 메뉴 아이콘중 가장 우측 아이콘 클릭후 원하는 시간을 설정하면 됨.


자세한 사용법은 아래 링크들을 참고해주세요^^



* Reference


http://xorb.tistory.com/entry/SQLDeveloper-4-%EB%B2%84%EC%A0%84-%EC%84%B8%EC%85%98-%EC%9C%A0%EC%A7%80


http://stackoverflow.com/questions/12999811/when-sql-developer-is-idle-i-lose-my-connection