Re: Exceeded maximum lock level

alexander lunyov <[email protected]>
Newsgroups gmane.comp.db.postgresql.interfaces
Message-ID <[email protected]>
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

-- 
Sent via pgsql-interfaces mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-interfaces
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.