Closed imavo closed 6 years ago
Can you share your repro?
Sample script below, please change the credentials to suit your databasename, user, password. Need to run it multiple times in succession to get the fault. Each run takes a second. I could not get the attach function working on this page for .zip file or .txt file so pasted inline below.
`#!/usr/bin/python3 #
# import ibm_db import os import sys import logging import pprint import faulthandler import getpass
faulthandler.enable()
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s 0 %(message)s')
logging.debug('Program start')
db_name = 'sample' db_uid = getpass.getuser()
pwd='password' # PLEASE PUT YOUR PASSWORD HERE TO SPEEDUP RETRIES
try: conn = ibm_db.connect(db_name, db_uid, pwd) except: logging.error('Error: Failed to connect to database: %s', ibm_db.conn_errormsg()) sys.exit(1)
logging.debug('Successfully connected to DB2 database')
logging.info('Dynamic SQL with parameter markers, bind, prepare, execute')
sql = 'select * from syscat.tables where tabschema=? and type=? with ur' try: stmt = ibm_db.prepare(conn, sql) logging.debug('Successfully prepared SQL with parameter markers') except: logging.error('Exception from ibm_db.prepare: %s ', ibm_db.stmt_errormsg() ) sys.exit(1)
try: ibm_db.bind_param(stmt,1, db_uid.upper()) except: logging.error('Exception from ibm_db.prepare for parameter-1: %s',ibm_db.stmt.errormsg()) sys.exit(1)
logging.debug('Bound parameter 1 OK')
try: ibm_db.bind_param(stmt,2,'T') except: logging.error('Exception from ibm_db.prepare for parameter-2: %s',ibm_db.stmt.errormsg()) sys.exit(1)
logging.debug('Bound parameter 2 OK')
logging.debug('About to execute the prepared statement') try: ibm_db.execute(stmt) logging.debug('Successfully executed prepared statement') except: logging.error('Failed to execute prepared stmt with 2 parameter markers: %s',ibm_db.stmt_errormsg()) sys.exit(1)
try: logging.debug('Fetching result set via .fetch_both()') result_set_dict=ibm_db.fetch_both(stmt) logging.debug('Successfully Fetched first row') except: logging.error('Exception from ibm_db.fetch_both() %s ',ibm_db.stmt_errormsg()) sys.exit(1)
rownum=0 while result_set_dict == True: pprint.pprint(result_set_dict, width=-1) # pretty-print with one line per column of result-set try: result_set_dict=ibm_db.fetch_both(stmt) rownum += 1 except: logging.error('Failed to fetch row number %d of resultset: %s ',(rownum, ibm_db.stmt_errormsg())) sys.exit(1)
logging.info('End of result set')
logging.debug('Closing database connection')
try:
ibm_db.close(conn)
except:
logging.info('Failed to close the database connection, but ignoring this')
sys.exit(1)
logging.debug('Closed database connection successfully')
sys.exit(0) `
My first guess is that this is similar to https://github.com/ibmdb/python-ibmdb/issues/216.
Are you on the latest source code from git or from pypi. pypi does not contain this fix and currently it is available only in git source.
If you are not already on latest source code from git, can you try building the git source and let me know if your problem is gone.
Thanks, Saba.
Tried on latest code, ran over 30 times and its success.
try and let me know.
I am running the following, which I installed with pip3, so I presume they come from pypi. pip3 list | grep ibm-db ibm-db (2.0.7) ibm-db-django (1.1.0.2) ibm-db-sa (0.3.3) When I look at the file for download in github the filename is ibm_db-2.0.7.tar.gz , so is that the same version 2.0.7 that is reported by pip3 list ? Please clarify.
The fix is available in git and you need to clone the source and build it. you can do the following to build: git clone https://github.com/ibmdb/python-ibmdb.git
cd
we are also working on new release that should have this fix and available via pip(pypi), but the release work is in progress.
Is there any outlook for when the next release will be available via pip/pypi , i.e. will it be in 2017, or in 2018 ? I am not currently set up to build from 'C' source on this environment, so it may be easier to wait for next build and work-around the issue in the meanwhile.
The release would happen in 2017. we will announce shortly.
Getting intermittent segmentation fault running ibm_db.execute(stmt) for a prepared statement. Running ubuntu 16.04 LTS on x64 with python 3.5.2 and ibm_db 2.0.7, with locally installed DB2 v11.1.1.1. The fault always happens on the same line, but if I run my script 10 times in a row then the fault will only happen on average 3 times in 10. I ran gdb to get stack trace and it reported:
The problem only happens if I use a method on an argument to ibm_db.bind_param. For example
ibm_db.bind_param(stmt,1, db_uid.upper() )
If I change this to:
then I do not get the segmentation fault.
It would be more useful if I was not forced to have such workarounds. Is this a bug or a feature ?