Re: Exceeded maximum lock level

From: alexander lunyov <lan(at)zato(dot)ru>
To: pgsql-interfaces(at)postgresql(dot)org
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Subject: Re: Exceeded maximum lock level
Date: 2008-04-24 05:34:19
Message-ID: 48101BDB.6080501@zato.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

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

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Alvaro Herrera 2008-04-24 14:12:35 Re: Exceeded maximum lock level
Previous Message Alvaro Herrera 2008-04-23 14:55:10 Re: Exceeded maximum lock level