Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 062612E005C for ; Thu, 24 Apr 2008 02:43:04 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 04230-01-7 for ; Thu, 24 Apr 2008 02:42:53 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mail.zato.ru (mail.zato.ru [80.82.172.12]) by developer.postgresql.org (Postfix) with ESMTP id 0C3CD2E00A9 for ; Thu, 24 Apr 2008 02:34:25 -0300 (ADT) Received: by mail.zato.ru (Postfix, from userid 9232) id 9E307217795; Thu, 24 Apr 2008 09:36:37 +0400 (MSD) Received: from [192.168.0.73] (luna.zato.ru [80.82.172.11]) by mail.zato.ru (Postfix) with ESMTP id 7133C21777E; Thu, 24 Apr 2008 09:36:37 +0400 (MSD) Message-ID: <48101BDB.6080501@zato.ru> Date: Thu, 24 Apr 2008 09:34:19 +0400 From: alexander lunyov User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Cc: Alvaro Herrera Subject: Re: Exceeded maximum lock level References: <480F46B4.5080102@zato.ru> <20080423145510.GA6572@alvh.no-ip.org> In-Reply-To: <20080423145510.GA6572@alvh.no-ip.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/10 X-Sequence-Number: 6721 Alvaro Herrera wrote: >> Fatal error 'Exceeded maximum lock level' at line 519 in file >> /usr/src/lib/libpthread/thread/thr_mutex.c (errno = 844913743) > > This is clearly not a PG problem -- I'd think there's a bug in your own > code. This is very helpful :) My code is just this: int SQLLog( PGconn *conn, struct auth *a, struct client *c, struct request *r, struct data *d ) { char * str; char log[256]; char *request; unsigned char *esc_bytea; size_t length; PGresult *res; if ((esc_bytea = PQescapeByteaConn(conn,d->data,d->len,&length)) == NULL) { snprintf(log,256, "Error: %s",PQerrorMessage(conn)); logging(log); return 0; } request = malloc ( sizeof(a->user) + sizeof(c->src) + sizeof(r->dst) + sizeof(esc_bytea) + 110); sprintf(request, "INSERT INTO raw (username,from_addr,to_addr,rawdata,direction) VALUES ('%s','%s','%s',E'%s',%d)", a->user,c->src,r->dst,esc_bytea,d->dir); res = PQexec(conn, request); if (PQresultStatus(res) != PGRES_COMMAND_OK) { snprintf(log,256,"failed: %s", PQerrorMessage(conn)); logging(log); } free(request); PQfreemem(esc_bytea); PQclear(res); return 0; } int OpenSQL( PGconn **conn ) { char log[256]; char *conninfo; conninfo = "host=localhost dbname=db user=user password=password"; *conn = PQconnectdb(conninfo); if (PQstatus(*conn) != CONNECTION_OK) { snprintf(log,256, "Connection to database failed: %s", PQerrorMessage(*conn)); logging(log); return 1; } else return 0; } int CloseSQL( PGconn *conn ) { PQfinish(conn); return 0; } I didn't touch any mutex (i don't even sure about what is mutex). While not calling any of sql functions, application works just fine. In non-threaded mode it is working with sql functions. Where did i go wrong? -- wbr, alexander