ibmdb/python-ibmdb

ibm_db_dbi::DatabaseError: Failed to LOB Data: Error occurred in SQL Call Level Interface SQLSTATE=HY021 SQLCODE=-999

sgonchigar opened this issue · 4 comments

  • Operating System Name: IBMi V7R4

  • db2level output from clidriver if in use:

  • Target Db2 Server Version: DB2400

  • Python Version: 3.6

  • ibm_db version: 2.0.5.12

  • For non-Windows, output of below commands:
    uname: OS400
    uname -m 0078000508B1

  • Value of below environment variables if set:
    IBM_DB_HOME: not set
    PATH: /QOpenSys/pkgs/bin:/QOpenSys/pkgs/bin:/usr/bin:.:/QOpenSys/usr/bin
    LIB/LD_LIBRARY_PATH/DYLD_LIBRARY_PATH:

  • Test script to reproduce the problem.

  • For installation related issue, complete output of pip install ibm_db command.

Steps to Reproduce:

  1. RPGLE pgm ---> write to input Data Q ---> py script reading from input Data Q and writing to output Data Q ---> RPGLE (read output Data Q)
  2. RPGLE pgm ---> 15,336 writes ----> py script reading from Data Q and 15, 336 writes, py script errored with this message
    ibm_db_dbi::DatabaseError: Failed to LOB Data: Error occurred in SQL Call Level Interface SQLSTATE=HY021 SQLCODE=-999
import ibm_db_dbi as db2
 options = {
        db2.SQL_ATTR_TXN_ISOLATION: db2.SQL_TXN_NO_COMMIT,
        db2.SQL_ATTR_DBC_SYS_NAMING: db2.SQL_TRUE
    }

    conn = db2.connect("DATABASE=*LOCAL")
    conn.set_option(options)

    cur = conn.cursor()
    receive_data_queue = """ 
        select MESSAGE_DATA
        from TABLE(QSYS2.RECEIVE_DATA_QUEUE(
                        DATA_QUEUE => '{inputKeyedDqName}', 
                        DATA_QUEUE_LIBRARY => '{keyedDqLib}',
                        WAIT_TIME => -1,
                        KEY_ORDER => 'EQ',
                        KEY_DATA => cast('{dQKey}' as char({dQKeyLen}))
                        )) limit 1
        """.format(inputKeyedDqName = inputKeyedDqName
                    ,keyedDqLib=keyedDqLib
                    ,dQKey=dQKey
                    ,dQKeyLen=dQKeyLen)
   
 
    print("waiting for first entry...")

    while True:
          try:
                 cur.execute(receive_data_queue)
                 row = cur.fetchone()
                 ....... process the input
                 
                 cur = conn.cursor()
                send_data_queue = """ 
                         CALL QSYS2.SEND_DATA_QUEUE(MESSAGE_DATA => '{outputStr}',
                                    DATA_QUEUE => '{outputKeyedDqName}', 
                                    DATA_QUEUE_LIBRARY => '{keyedDqLib}',
                                    KEY_DATA => cast('{dQKey}' as char({dQKeyLen}))
                                )
               """.format(outputKeyedDqName =outputKeyedDqName
                    ,keyedDqLib=keyedDqLib
                    ,dQKey=dQKey
                    ,dQKeyLen=dQKeyLen
                    ,outputStr=outputStr)

              cur.execute(send_data_queue)

          except Exception as err:
            print("Error on Fetch", err)
            #..close the cursor and connection.
            cur.close()
            conn.close()
            break
          
         print("waiting for next entry...") 
    
Appreciate any help. Thank you!

--- Logging error ---
Traceback (most recent call last):
File "/QOpenSys/pkgs/lib/python3.6/site-packages/ibm_db_dbi.py", line 1472, in _fetch_helper
row = ibm_db.fetch_tuple(self.stmt_handler)
Exception: Failed to LOB Data: Error occurred in SQL Call Level Interface SQLSTATE=HY021 SQLCODE=-99999
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/sgonchigar/python/sc3270.py", line 123, in read_dataQ
row = cur.fetchone()
File "/QOpenSys/pkgs/lib/python3.6/site-packages/ibm_db_dbi.py", line 1492, in fetchone
row_list = self._fetch_helper(1)
File "/QOpenSys/pkgs/lib/python3.6/site-packages/ibm_db_dbi.py", line 1476, in _fetch_helper
raise self.messages[-1]
ibm_db_dbi.DatabaseError: ibm_db_dbi::DatabaseError: Failed to LOB Data: Error occurred in SQL Call Level Interface SQLSTATE=HY021 S
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/QOpenSys/pkgs/lib/python3.6/logging/init.py", line 994, in emit
msg = self.format(record)
File "/QOpenSys/pkgs/lib/python3.6/logging/init.py", line 840, in format
return fmt.format(record)
File "/QOpenSys/pkgs/lib/python3.6/logging/init.py", line 577, in format
record.message = record.getMessage()
File "/QOpenSys/pkgs/lib/python3.6/logging/init.py", line 338, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
File "/home/sgonchigar/python/sc3270.py", line 351, in
main();
File "/home/sgonchigar/python/sc3270.py", line 80, in main
read_dataQ(keyedDqLib,inputKeyedDqName,outputKeyedDqName,dQKey,dQKeyLen)
File "/home/sgonchigar/python/sc3270.py", line 138, in read_dataQ
log.error("Error = ", err)
Message: 'Error = '
Arguments: (DatabaseError('Failed to LOB Data: Error occurred in SQL Call Level Interface SQLSTATE=HY021 SQLCODE=-99999',),)

imavo commented

Does this symptom recreate on demand?
If it does, please can you take a CLI trace , and append relevant section here?
Use the clidriver tool called db2trc as follows in a shell:

db2trc on -cli -f hy021.dmp

now run your python script until it fails with the symptom you reported, then:

db2trc off

db2trc fmt -cli hy021.dmp hy021.txt

The resulting file (e.g. hy021.txt) is plain text, and will show the SQLGetData() that is returning the SQL_ERROR that triggers your symptom - but it will hopefully also show the types,lengths,characteristics of the arguments, which will be needed to find root cause, along with other useful information.

@sgonchigar Could you please collect the traces as mentioned by imavo and share here? Thanks.

This is now resolved. sorry didn't close this. you can see the updates here
kadler#12