Transaction support to lb.proxy + migration script.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Tue, 19 Sep 2006 14:02:33 +0000 (14:02 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Tue, 19 Sep 2006 14:02:33 +0000 (14:02 +0000)
Reset locale in script depending on netstat output.

org.glite.lb.proxy/config/glite-lb-dbsetup-proxy.sql
org.glite.lb.proxy/doc/README.deploy
org.glite.lb.proxy/src/lbproxy.c
org.glite.lb.server/Makefile
org.glite.lb.server/config/glite-lb-dbsetup-migrate2transactions.sql [new file with mode: 0644]
org.glite.lb.server/config/startup

index af04974..81266fe 100644 (file)
@@ -7,7 +7,7 @@ create table jobs (
        primary key (jobid),
        unique (dg_jobid),
        index (userid)
-);
+) engine=innodb;
 
 create table users (
        userid          char(32)        binary not null,
@@ -15,7 +15,7 @@ create table users (
 
        primary key (userid),
        unique (cert_subj)
-);
+) engine=innodb;
 
 create table events (
        jobid           char(32)        binary not null,
@@ -35,7 +35,7 @@ create table events (
        index (time_stamp),
        index (host),
        index (arrived)
-);
+) engine=innodb;
 
 create table short_fields (
        jobid           char(32)        binary not null,
@@ -44,7 +44,7 @@ create table short_fields (
        value           varchar(255)    binary null,
 
        primary key (jobid,event,name)
-);
+) engine=innodb;
 
 create table long_fields (
        jobid           char(32)        binary not null,
@@ -53,7 +53,7 @@ create table long_fields (
        value           mediumblob      null,
 
        primary key (jobid,event,name)
-);
+) engine=innodb;
 
 create table states (
        jobid           char(32)        binary not null,
@@ -66,7 +66,7 @@ create table states (
        primary key (jobid),
        index (parent_job)
        
-);
+) engine=innodb;
 
 create table status_tags (
        jobid           char(32)        binary not null,
@@ -75,7 +75,7 @@ create table status_tags (
        value           varchar(255)    binary null,
 
        primary key (jobid,seq,name)
-);
+) engine=innodb;
 
 create table server_state (
        prefix          varchar(100)    not null,
@@ -83,7 +83,7 @@ create table server_state (
        value           varchar(255)    binary not null,
 
        primary key (prefix,name)
-);
+) engine=innodb;
 
 create table acls (
        aclid           char(32)        binary not null,
@@ -91,7 +91,7 @@ create table acls (
        refcnt          int             not null,
 
        primary key (aclid)
-);
+) engine=innodb;
 
 create table notif_registrations (
        notifid         char(32)        binary not null,
@@ -101,7 +101,7 @@ create table notif_registrations (
        conditions      mediumblob      not null,
 
        primary key (notifid)
-);
+) engine=innodb;
 
 create table notif_jobs (
        notifid         char(32)        binary not null,
@@ -109,4 +109,4 @@ create table notif_jobs (
 
        primary key (notifid,jobid),
        index (jobid)
-);
+) engine=innodb;
index 48435a6..2012717 100644 (file)
@@ -24,6 +24,10 @@ LB Proxy install should follow several steps described bellow:
    Grant privileges to user: lbserver
    Database has the same structure as bkserver has (you can use
    sql script etc/glite-lb-dbsetup-proxy.sql to create propper tables).
+
+  For better performance it's recommended to use database backend with
+  transactions. It's set up by default, existing database can be migrated
+  with etc/glite-lb-dbsetup-migrate2transaction.sql (lb-server package).
  
 2) Start servers with scripts from distribution
    /opt/glite/etc/init.d/glite-lb-locallogger start
index bfb5969..c84c9cf 100644 (file)
@@ -80,6 +80,7 @@ static int            slaves = 10,
                        semset;
 static char            host[300];
 static char *          port;
+int                    transactions = -1;
 
 
 static struct option opts[] = {
@@ -96,10 +97,11 @@ static struct option opts[] = {
 #ifdef LB_PERF
        {"perf-sink",           1, NULL,        'K'},
 #endif
+       {"transactions",        1,      NULL,   'b'},
        {NULL,0,NULL,0}
 };
 
-static const char *get_opt_string = "p:c:dm:s:l:i:X:Y:z"
+static const char *get_opt_string = "p:c:dm:s:l:i:X:Y:zb:"
 #ifdef LB_PERF
        "K:"
 #endif
@@ -121,6 +123,7 @@ static void usage(char *me)
 #ifdef LB_PERF
                "\t--perf-sink\t where to sink events\n"
 #endif
+               "\t-b, --transactions\t transactions force switch\n"
        ,me);
 }
 
@@ -180,6 +183,7 @@ int main(int argc, char *argv[])
 
        while ((opt = getopt_long(argc, argv, get_opt_string, opts, NULL)) != EOF) switch (opt) {
                case 'p': strcpy(socket_path_prefix, optarg); break;
+               case 'b': transactions = atoi(optarg); break;
                case 'c': con_queue = atoi(optarg); break;
                case 'd': debug = 1; break;
                case 'z': silent = 1; break;
@@ -206,7 +210,7 @@ int main(int argc, char *argv[])
 
                if ( fscanf(fpid,"%d",&opid) == 1 ) {
                        if ( !kill(opid,0) ) {
-                               fprintf(stderr,"%s: another instance running, pid = %d\n",argv[0],opid);
+                               fprintf(stderr,"%s: another instance running, pid = %d\n",name,opid);
                                return 1;
                        }
                        else if (errno != ESRCH) { perror("kill()"); return 1; }
@@ -307,9 +311,15 @@ int main(int argc, char *argv[])
                char    *et,*ed;
                edg_wll_Error(ctx,&et,&ed);
 
-               fprintf(stderr,"%s: open database: %s (%s)\n",argv[0],et,ed);
+               fprintf(stderr,"%s: open database: %s (%s)\n",name,et,ed);
                return 1;
        }
+       if (!ctx->use_transactions && transactions != 0) {
+               fprintf(stderr, "%s: transactions aren't supported!\n", name);
+       }
+       if (transactions >= 0) {
+               fprintf(stderr, "%s: transactions forced from %d to %d\n", name, ctx->use_transactions, transactions);
+       }
        edg_wll_Close(ctx);
        edg_wll_FreeContext(ctx);
 
@@ -598,6 +608,8 @@ static void wait_for_open(edg_wll_Context ctx, const char *dbstring)
                dprintf(("[%d]: DB connection established\n",getpid()));
                if (!debug) syslog(LOG_INFO,"DB connection established\n");
        }
+
+       if (transactions >= 0) ctx->use_transactions = transactions;
 }
 
 static int decrement_timeout(struct timeval *timeout, struct timeval before, struct timeval after)
index 2fb12e3..74da7b4 100644 (file)
@@ -358,7 +358,7 @@ install:
                ${INSTALL} -m 755 "glite_lb_$$p" "${PREFIX}/bin/glite-lb-$$p"; \
        done
 
-       for f in dbsetup.sql index.conf.template; do \
+       for f in dbsetup.sql dbsetup-migrate2transactions.sql index.conf.template; do \
                ${INSTALL} -m 644 ${top_srcdir}/config/"glite-lb-$$f" ${PREFIX}/etc; \
        done
 
diff --git a/org.glite.lb.server/config/glite-lb-dbsetup-migrate2transactions.sql b/org.glite.lb.server/config/glite-lb-dbsetup-migrate2transactions.sql
new file mode 100644 (file)
index 0000000..51eec7a
--- /dev/null
@@ -0,0 +1,11 @@
+alter table jobs engine=innodb;
+alter table users engine=innodb;
+alter table events engine=innodb;
+alter table short_fields engine=innodb;
+alter table long_fields engine=innodb;
+alter table states engine=innodb;
+alter table status_tags engine=innodb;
+alter table server_state engine=innodb;
+alter table acls engine=innodb;
+alter table notif_registrations engine=innodb;
+alter table notif_jobs engine=innodb;
index fc3b0a5..f39c10e 100755 (executable)
@@ -93,6 +93,7 @@ status()
 {
        retval=0
 
+       LC_ALL=C
        if netstat -an --unix | grep "^unix .* LISTEN.* ${GLITE_LB_NOTIF_SOCK}$" >/dev/null 2>&1 ;then
                echo glite-lb-notif-interlogd running
        else