pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: alexander lunyov <lan@zato.ru>
To: pgsql-interfaces@postgresql.org
Cc: Alvaro Herrera <alvherre@commandprompt.com>
Subject: Re: Exceeded maximum lock level
Date: Thu, 24 Apr 2008 09:34:19 +0400
Message-ID: <48101BDB.6080501@zato.ru> (raw)
In-Reply-To: <20080423145510.GA6572@alvh.no-ip.org>
References: <480F46B4.5080102@zato.ru>
	<20080423145510.GA6572@alvh.no-ip.org>

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



view thread (4+ messages)  latest in thread

Message-ID: <48101BDB.6080501@zato.ru>
Permalink:  ../48101BDB.6080501@zato.ru/
Also on:    postgresql.org/message-id/48101BDB.6080501@zato.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: lan@zato.ru, alvherre@commandprompt.com
  Subject: Re: Exceeded maximum lock level
  In-Reply-To: <48101BDB.6080501@zato.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox