Commit 4e1c717e authored by Kubo Takehiro's avatar Kubo Takehiro
Browse files

Add a document about conflicts between local connections and child process handling on Unix.

parent c1e494e3
......@@ -11,10 +11,4 @@
NEWS
COPYING
COPYING_old
docs/install-full-client.md
docs/install-instant-client.md
docs/install-binary-package.md
docs/install-on-osx.md
docs/platform-specific-issues.md
docs/report-installation-issue.md
docs/timeout-parameters.md
docs/*.md
2016-03-15 Kubo Takehiro <kubo@jiubao.org>
* docs/conflicts-local-connections-and-processes.md: Add a document
about conflicts between local connections and child process
handling on Unix.
* README.md: Add a link to a newly added file.
2016-03-13 Kubo Takehiro <kubo@jiubao.org>
* ruby-oci8.gemspec: Change the license name in gemspec to suppress the
following warning.
......
......@@ -41,6 +41,11 @@ Report issues
* {file:docs/report-installation-issue.md Report Installation Issues}
* [The issues page on github](https://github.com/kubo/ruby-oci8/issues)
Other documents
===============
* {file:docs/conflicts-local-connections-and-processes.md Conflicts between Local Connections and Child Process Handling on Unix}
License
=======
......
......@@ -14,6 +14,7 @@ docs/install-binary-package.md
docs/install-full-client.md
docs/install-instant-client.md
docs/install-on-osx.md
docs/conflicts-local-connections-and-processes.md
docs/osx-install-dev-tools.png
docs/platform-specific-issues.md
docs/report-installation-issue.md
......
# @title Conflicts between Local Connections and Child Process Handling on Unix
Background
==========
When a local (not-TCP) Oracle connection is established on Unix,
Oracle client library changes signal handlers in the process to reap
all dead child processes. However it conflicts with child process
handling in ruby.
Problem 1: It trashes child process handling of Open3::popen.
==========
require 'oci8'
require 'open3'
Open3::popen3('true') do |i, o, e, w|
p w.value
end
conn = OCI8.new(username, password)
puts "establish a local connection"
Open3::popen3('true') do |i, o, e, w|
p w.value
end
The above code outputs the following result:
#<Process::Status: pid 19236 exit 0>
establish a local connection
nil
`w.value` after a local connection doesn't work because Oracle reaps
the child process on the process termination before ruby detects it.
Problem 2: It creates defunct processes after disconnection if signal handlers are reset.
==========
The `system` function overwrites signal handlers.
It fixes the problem 1 as follows.
require 'oci8'
require 'open3'
Open3::popen3('true') do |i, o, e, w|
p w.value
end
conn = OCI8.new(username, password) # Signal handlers are changed here.
puts "establish a local connection"
system('true') # Signal handlers are reset here.
Open3::popen3('true') do |i, o, e, w|
p w.value
end
The above code outputs the following result:
#<Process::Status: pid 19652 exit 0>
establish a local connection
#<Process::Status: pid 19656 exit 0>
`w.value` after a local connection works.
However it makes another problem.
require 'oci8'
conn = OCI8.new(username, password) # Signal handlers are changed here.
# An Oracle server process is created here.
puts "establish a local connection"
system('true') # Signal handlers are reset here.
conn.logoff # The Oracle server process exits and become defunct.
# ... do other stuffs...
If a program repeatedly creates a local connection and disconnects it,
the number of defunct processes increases gradually.
Solution: BEQUEATH_DETACH=YES
==========
By setting [BEQUEATH_DETACH=YES][] in `sqlnet.ora`, Oracle client library
doesn't change signal handlers. The above two problems are fixed.
Oracle client library reads `sqlnet.ora` in the following locations:
* `$TNS_ADMIN/sqlnet.ora` if the environment variable `TNS_ADMIN`
is set and `$TNS_ADMIN/sqlnet.ora` exists.
Otherwise, `$ORACLE_HOME/network/admin/sqlnet.ora`.
* `$HOME/.sqlnet.ora`
[BEQUEATH_DETACH=YES]: https://docs.oracle.com/database/121/NETRF/sqlnet.htm#NETRF183
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment