Hi,

get_err_buffer uses thread specific buffer. Internally it uses pthread_getspecific.
In a few words it returns NULL if it called from the wrong thread.

So, looks like you have called
OraclePreparedStatement_getLastError from incorrect thread. It should be called from the same thread where prepared statement was initialed.
 
Hope it helps.

Good luck,
Volodymyr!


On Monday, March 14, 2016 6:29 PM, Jan-Henrik Haukeland <hauk@tildeslash.com> wrote:


I recommend asking Volodymyr Tarasenko. The Oracle driver in libzdb is his work. I believe he also work at your Company, PortaOne? Some refactoring into a more general error function may be good. For instance, both OracleConnection_getLastError and OraclePreparedStatement_getLastError basically do the same thing.

Ps. If you do plan to do some changes, great! If so, keep an eye on this branch, https://bitbucket.org/tildeslash/libzdb/branch/prefetch. I’m in the process of doing som internal refactoring which changes the internal API a bit.

This work is to support prefetch of Result Sets for both MySQL and Oracle to speed up retrieval of data from the data base. Suggested by jianlinlong in https://bitbucket.org/tildeslash/libzdb/issues/17 This should hopefully speed up things considerably in programs like DBMail. Currently almost done with MySQL and plan to start on Oracle soon (just need to install Oracle Express on my Mac as I don’t have access to an Oracle database at the moment).

> On 14 Mar 2016, at 15:57, Pavlo Lavrenenko <santa@portaone.com> wrote:
>
> Hello.
>
> I have dbmail-imapd crashed with:
> > Jan 20 04:25:17 um1 dbmail/imap4d[24111]: EMERGENCY:[libzdb] TabortHandler(+43): AssertException: 0x0x3db0e15950
> > raised in OraclePreparedStatement_getLastError at src/db/oracle/OraclePreparedStatement.c:257
>
> Which seems to be triggered by assert() in OraclePreparedStatement_getLastError():
>
> > 251 /* This is a general error function also used in OracleResultSet */
> > 252 const char *OraclePreparedStatement_getLastError(int err, OCIError *errhp) {
> > 253        sb4 errcode;
> > 254        char* erb;
> > 255    pthread_once(&error_msg_key_once, error_msg_key_alloc);
> > 256    erb = get_err_buffer();
> > 257    assert(erb);
>
> I do not have any steps to reproduce the issue unfortunately, but maybe you can give me a nudge into a right investigation direction (I am investigating why get_err_buffer() returned NULL).
>
> I would also be nice to have another thread safe way to store the error message or even to print it (providing the issue is reproducible at all).
>
> --
> Best regards,
> Pavlo Lavrenenko,
> PortaOne, Inc., Junior Software Developer
> Tel: +1-866-SIP VOIP (+1 866 747 8647) ext. 7624
>
> PortaOne - VoIP Solutions Company
> Visit our Website: http://www.portaone.com

--
To unsubscribe:
http://www.tildeslash.com/mailman/listinfo/libzdb-general