Ruby C extension returns report_on_exception is true

896 Views Asked by At

I was trying to import server_info api in the ibm_db extension. It worked well in windows but in Linux, it returns tread sleep error.

#<Thread:0x000055c9febc5ca0 sleep> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
stack level too deep (SystemStackError)
^C*** stack smashing detected ***: <unknown> terminated

code:-

require 'ibm_db'
conn = IBM_DB.connect('DATABASE=;HOSTNAME=localhost;PORT=50000;PROTOCOL=TCPIP;UID=;PWD=','','')
puts 'this is ibm_db'
#Thread.report_on_exception = false
puts 'this is begin'
puts IBM_DB
serverinfo = IBM_DB::server_info( conn )
puts serverinfo.DBMS_NAME[0,100]
puts IBM_DB.close(conn)

why the same code returns the error in Linux but woe=rks well in windows.

When I run the code in debug mode it does not produce any error only in normal mode it produces an error.

Thanks, Akhil

1

There are 1 best solutions below

0
Chitresh goyal On

Well, two approach

  1. use sleep for 5-10 second after db connection
  2. check db connection like: p "connected" if ActiveRecord::Base.connected?

In your case, need to check in ibm_db gem how to check if connection established or not

conn=ibm_db.connect("DATABASE=database;HOSTNAME=hostname;PORT=port;PROTOCOL=TCPIP;UID=username;PWD=password",'','')
connState = ibm_db.active(conn)
print(connState)

if it says "TRUE" go ahead else pause/sleep whatever your requirement.