Why would ruby-oci8 raise a "could not resolve a connection identifier" in a resque worker but not console?

StackOverflow https://stackoverflow.com/questions/18518997

Pergunta

We have a small script that connects to an instance of Oracle. This script works fine when it is ran outside of our resque worker. It even runs fine under console. However, when we load that same script up in a resque worker it throws

TNS:could not resolve the connect identifier specified

We've tried many things, but nothing has worked thus far.

The resque worker calls the same class that works in the root environment and console.

Foi útil?

Solução 2

Apparently, the resque worker could not see $TNS_ADMIN so I manually set ENV['TNS_ADMIN'] in the application.rb

Outras dicas

Well, I know nothing of Ruby, so, I don't fully understand the environment you're taking about, however, I do know Oracle.

I can tell you that 'TNS:could not resolve the connect identifier specified" means that Oracle can't resolve the connect identifier, aka connect string, given the environment that has been set up.

So, some stuff to think about:

In the execution environment of the resque worker (sorry, no idea what that is), you need the ORACLE_HOME environment variable set appropriately. Oracle will look for tnsnames.ora, sqlnet.ora, ldap.ora, etc, in $ORACLE_HOME/network/admin, unless TNS_ADMIN is set. IF TNS_ADMIN is set, it will override the $ORACLE_HOME/network/admin location.

Again, I'm not familiar with Ruby or what a "resque worker" is, so, all I can say, is compare the two environments and see where they are set up differently.

Hope that helps.

If someone who knows both Oracle and Ruby comes along, perhaps they can offer more specific advice.

Again, hope that helps.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top