jeremyevans/sequel — Issue #409: ORA-12154 with Sequel, Grape and daemonized Thin
Author: leucos
Created: 2011-12-11 16:11:10+00:00
State: open

Hello,

# Word or warning

First, I'm not sure this is a Sequel related issue, but subsequent (admitively poor) tests seems to suggest so.
If not, forgive me for the noise.
I tried to make reader's life as easy as possible, trying to include only relevant things, but if anymore information/tests/whatever are required, I'd be glad to send some more input. Hopefuly, you might not have to deal with Oracle so it might be uneasy to reproduce at your place.

# Context

I'm trying to use Sequel on an Oracle backend to create webservice backed by [Thin]([https://github.com/macournoyer/thin), [Rack](https://github.com/chneukirchen/rack) and [Grape](https://github.com/intridea/grape).

# The issue

Things were running pretty well until I tried to use the 'daemonize' feature of Thin, which lets you start *n* detached web processes on different ports.

I rewrote a simplified example as a Gist (https://gist.github.com/1460919) that includes the code ([init.rb](https://gist.github.com/1460919#file_init.rb)), the rackup file ([config.ru](https://gist.github.com/1460919#file_config.ru)) and the Thin log ([thin.3000.log](https://gist.github.com/1460919#file_thin.3000.log)).

In summary : things are always running okay with SQLite as the DB backend. When using Oracle, it works when thin is started undetached with `thin -R config.ru start`, but fails when run daemonized with `thin -R config.ru -s2 start`, yielding the following lovely oracle error :

ORA-12154: TNS:could not resolve the connect identifier specified

I dumped the environment in the log file, to be sure that `ORACLE_HOME` and `LD_LIBRARY_PATH` are fine, and fine they seem.

I tried to reproduce directly this error without Sequel/Grape and Thin, using the Daemons gem like Thin does (https://github.com/macournoyer/thin/blob/master/lib/thin/daemonizing.rb). I wanted to check if it wasn't related to the oci8 driver, but it seems not (https://gist.github.com/1460919#file_zoradaemontest.rb).

I tried to make the [Gist](https://gist.github.com/1460919) comprehensive, with all files involved.

Thanks for reading.

M