Subject | heavy problem ... |
---|---|
Author | Alessandro GARDICH |
Post date | 2003-08-20T09:21:10Z |
hi to all ...
i have many problems with firebird
it just stop to work !!!
process is still alive, cpu occupation to 0%, all clients stopped,
difficult to make new connection ...
that is the table, the only one in the database ...
CREATE TABLE "TEST"
(
"ID" INTEGER NOT NULL,
"VAL" INTEGER,
"TS" TIMESTAMP,
PRIMARY KEY ("ID")
);
i have 1000 etry in that table.
i write a simple example that make hang all
#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
#define MAX_DELAY 100
#define MIN_DELAY 1
using namespace std;
IBPP::Database dbv; /* database */
IBPP::Transaction trv;
IBPP::Statement stv;
sighandler_t old_sigterm;
void close_db(int sig) {
stv->Close();
trv->Commit();
dbv->Disconnect();
exit(0);
}
int main(int argc, char *argv[]) {
string s;
long delay;
long val[MAX_ID],delta;
int id;
old_sigterm=signal(SIGTERM, close_db);
srand(time(NULL));
for(id=0;id<MAX_ID;id++)
val[id]=rand()%100;
try {
dbv = IBPP::DatabaseFactory("localhost","/usr/local/firebird/fbtest.gdb","sysdba","masterkey");
dbv->Connect();
trv = IBPP::TransactionFactory(dbv, IBPP::amWrite, IBPP::ilReadDirty, IBPP::lrNoWait);
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 {
delay=rand()%(MAX_DELAY-MIN_DELAY)+MIN_DELAY;
id=rand()%MAX_ID;
delta=(rand()%3)-1;
val[id]+=delta;
val[id]=(val[id]>MAX_VAL)?MAX_VAL:val[id];
val[id]=(val[id]<MIN_VAL)?MIN_VAL:val[id];
cout << "[" << id << "] " << val[id] << "\tt=" << delay << endl;
stv->Set(1,val[id]);
stv->Set(2,id);
stv->Execute();
trv->CommitRetain();
usleep(delay*1000);
} catch (IBPP::Exception &e) { cerr << e.ErrorMessage(); }
}
close_db(0);
return 0;
}
please help me !!!
tanks in advance
--
/-------------------------------------------------------------\
| Alessandro Gardich : gremlin@... |
| A small bird will drop frozen dead from a bough |
| without ever having felt sorry for itself. |
\-------------------------------------------------------------/
i have many problems with firebird
it just stop to work !!!
process is still alive, cpu occupation to 0%, all clients stopped,
difficult to make new connection ...
that is the table, the only one in the database ...
CREATE TABLE "TEST"
(
"ID" INTEGER NOT NULL,
"VAL" INTEGER,
"TS" TIMESTAMP,
PRIMARY KEY ("ID")
);
i have 1000 etry in that table.
i write a simple example that make hang all
>---begin---<#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
#define MAX_DELAY 100
#define MIN_DELAY 1
using namespace std;
IBPP::Database dbv; /* database */
IBPP::Transaction trv;
IBPP::Statement stv;
sighandler_t old_sigterm;
void close_db(int sig) {
stv->Close();
trv->Commit();
dbv->Disconnect();
exit(0);
}
int main(int argc, char *argv[]) {
string s;
long delay;
long val[MAX_ID],delta;
int id;
old_sigterm=signal(SIGTERM, close_db);
srand(time(NULL));
for(id=0;id<MAX_ID;id++)
val[id]=rand()%100;
try {
dbv = IBPP::DatabaseFactory("localhost","/usr/local/firebird/fbtest.gdb","sysdba","masterkey");
dbv->Connect();
trv = IBPP::TransactionFactory(dbv, IBPP::amWrite, IBPP::ilReadDirty, IBPP::lrNoWait);
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 {
delay=rand()%(MAX_DELAY-MIN_DELAY)+MIN_DELAY;
id=rand()%MAX_ID;
delta=(rand()%3)-1;
val[id]+=delta;
val[id]=(val[id]>MAX_VAL)?MAX_VAL:val[id];
val[id]=(val[id]<MIN_VAL)?MIN_VAL:val[id];
cout << "[" << id << "] " << val[id] << "\tt=" << delay << endl;
stv->Set(1,val[id]);
stv->Set(2,id);
stv->Execute();
trv->CommitRetain();
usleep(delay*1000);
} catch (IBPP::Exception &e) { cerr << e.ErrorMessage(); }
}
close_db(0);
return 0;
}
>---end---<i run 100 istances of 'feed' and after some minutes server stop ...
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. |
\-------------------------------------------------------------/