Subject firebird frozing ...
Author Alessandro GARDICH
hi to all ...

I have many problems with firebird and ibpp
firebird server simply stop to work !!!
the process 'fbserver' is still alive, cpu occupation to 0%, all clients stopped,
difficult to make new connection ... seem is in a deadlock :( ...

I'm using firebird 1.5 rc4 (prebuild version from firebirdsql.org)
ibpp 2.1.10
RedHat Linux 9.0

that is the table with 1000 entries (rows) , the only one in the database ...
CREATE TABLE "TEST"
(
"ID" INTEGER NOT NULL,
"VAL" INTEGER,
"TS" TIMESTAMP,
PRIMARY KEY ("ID")
);


that is a simple stress program i made ...

>--!!!--<
#include <iostream>
#include <string>
#include <unistd.h>
#include <signal.h>

#define IBPP_LINUX
#define IBPP_GCC
#include <ibpp.h>

#define MAX_ID 1000
#define MIN_VAL 0L
#define MAX_VAL 100L

using namespace std;

IBPP::Database dbv; /* database */
IBPP::Transaction trv;
IBPP::Statement stv;

sighandler_t old_sigterm;

void close_db(int sig) {
trv->Commit();
stv->Close();
dbv->Disconnect();
cerr << "*** CLOSING ***" << endl;
exit(0);
}

int main(int argc, char *argv[]) {
string s;
long val[MAX_ID],delta,cnt=0;
int id;
long t1,t2;
int tag=0;

signal(SIGTERM, close_db);
signal(SIGINT, close_db);

t1=time(NULL);

srand(time(NULL));
for(id=0;id<MAX_ID;id++)
val[id]=rand()%100;

if (argc > 1)
tag = atoi(argv[1]);

try {
dbv = IBPP::DatabaseFactory("locahost","/usr/local/firebird/fbtest.gdb","sysdba","masterkey");
dbv->Connect();
trv = IBPP::TransactionFactory(dbv, IBPP::amWrite, IBPP::ilReadDirty, IBPP::lrWait);
trv->Start();
stv = IBPP::StatementFactory(dbv,trv);
s="update test set val=? where id=?";
stv->Prepare(s);
} catch (IBPP::Exception &e) { cerr << e.ErrorMessage(); }

for (;;) {
try {
cnt++;
if (cnt%1000==0) {
float rate;
t2=time(NULL);
rate=1000.0/(t2-t1);
t1=t2;
cerr << "### " << tag << " " << cnt << " " << rate << " ###" << endl;
}
id=rand()%MAX_ID;
delta=(rand()%3)-1;
val[id]+=delta;
cout << "[" << id << "] " << val[id] << endl;
stv->Set(1,val[id]);
stv->Set(2,id);
stv->Execute();
trv->Commit();
trv->Start();
} catch (IBPP::Exception &e) { cerr << " EXCEPION!!! " << tag << endl; cerr << e.ErrorMessage(); }
}

close_db(0);

return 0;
}
>--^^^--<

i run 10 istances of 'feed' and after some minutes server stop ...
that's the script ...
for i in 0 1 2 3 4 5 6 7 8 9; do ./feed $i > feed.$i.log & done


I obtain also a lot of that exceptions :

>--!!!--<
EXCEPION!!! 2
*** IBPP::Exception inside Statement::Execute ***

IBPP Message : isc_dsql_execute2 failed.

SQL Message : -913
deadlock
.

Engine Code : 335544336
Engine Message :
deadlock
update conflicts with concurrent update
>--^^^--<


please help me !!!

tanks in advance


--
/--\
| Alessandro Gardich : gremlin@... |
>--<
| I never saw a wild thing sorry for itself. |
| A small bird will drop frozen dead from a bough |
| without ever having felt sorry for itself. |
\--/