Update of /cvsroot/monetdb/MonetDB5/src/tools
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6644/src/tools
Modified Files:
Tag: GDK-2
Makefile.ag mcheckpoint merovingian.mx monetdb.mx prog.c
Added Files:
Tag: GDK-2
merovingian.1
Log Message:
propagated changes of Thursday Sep 06 2007 - Monday Sep 10 2007
from the development trunk to the GDK-2 branch
Index: prog.c
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/tools/prog.c,v
retrieving revision 1.7.4.2
retrieving revision 1.7.4.3
diff -u -d -r1.7.4.2 -r1.7.4.3
--- prog.c 3 Sep 2007 13:08:39 -0000 1.7.4.2
+++ prog.c 10 Sep 2007 14:27:19 -0000 1.7.4.3
@@ -104,7 +104,6 @@
/* needed to prevent the MonetDB config file from being used */
setlen = mo_add_option(&set, setlen, opt_config, "prefix",
MONETDBPREFIX);
setlen = mo_add_option(&set, setlen, opt_config, "config",
MONETDBCONFIG);
- setlen = mo_system_config(&set, setlen);
for (;;) {
int option_index = 0;
@@ -158,6 +157,8 @@
}
}
+ setlen = mo_system_config(&set, setlen);
+
mid = embedded_mal(set, setlen);
/* now for each file given on the command line (or stdin)
Index: merovingian.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/tools/merovingian.mx,v
retrieving revision 1.27.2.4
retrieving revision 1.27.2.5
diff -u -d -r1.27.2.4 -r1.27.2.5
--- merovingian.mx 6 Sep 2007 13:52:48 -0000 1.27.2.4
+++ merovingian.mx 10 Sep 2007 14:27:18 -0000 1.27.2.5
@@ -871,48 +871,70 @@
controlRunner(void *d)
{
char buf[256];
- char *p;
+ char *p, *q;
sabdb *stats;
int fd = *((int *)d);
- int len;
+ int pos = 0;
/* Try to handle control signals. We can get race conditions due to
* clients coming in at the same time. We might need to fix this
* situation sometime. */
while (_keepListening == 1) {
- if ((len = read(fd, buf, 255)) == 0) {
- /* ignore EOF, but don't spin-lock */
- MT_sleep_ms(500);
+ if (pos == 0) {
+ if ((pos = read(fd, buf, 255)) == 0) {
+ /* ignore EOF, but don't spin-lock */
+ MT_sleep_ms(500);
+ continue;
+ } else if (pos == -1) {
+ /* hmmm error ... give up */
+ fprintf(stderr, "error reading from control
channel: %s\n",
+ strerror(errno));
+ break;
+ } else {
+ buf[pos] = '\0';
+ pos = 0;
+ }
+ }
+ q = buf + pos;
+ p = strchr(q, '\n');
+ if (p == NULL) {
+ /* skip, must be garbage */
+ fprintf(stderr, "skipping garbage on control channel:
%s\n", buf);
+ pos = 0;
continue;
}
- buf[len] = '\0';
+ *p++ = '\0';
+ if (*p == '\0') {
+ pos = 0;
+ } else {
+ pos = p - buf;
+ }
/* format is simple: database<space>command */
- if ((p = strchr(buf, ' ')) == NULL) {
- fprintf(stderr, "malformed control signal: %s\n", buf);
+ if ((p = strchr(q, ' ')) == NULL) {
+ fprintf(stderr, "malformed control signal: %s\n", q);
} else {
*p++ = '\0';
- if (strcmp(p, "start\n") == 0) {
- merlog("starting database %s due to control
signal",
- buf);
- forkMserver(buf, &stats, 1);
+ if (strcmp(p, "start") == 0) {
+ merlog("starting database %s due to control
signal", q);
+ forkMserver(q, &stats, 1);
if (stats != NULL)
SABAOTHfreeStatus(&stats);
- } else if (strcmp(p, "stop\n") == 0 ||
- strcmp(p, "kill\n") == 0)
+ } else if (strcmp(p, "stop") == 0 ||
+ strcmp(p, "kill") == 0)
{
- /* we need to f ind the right dpair, that is we
+ /* we need to find the right dpair, that is we
* sort of assume the control signal is right */
dpair dp = topdp;
while (dp != NULL) {
- if (strcmp(dp->dbname, buf) == 0) {
- if (strcmp(p, "stop\n") == 0) {
+ if (strcmp(dp->dbname, q) == 0) {
+ if (strcmp(p, "stop") == 0) {
merlog("stopping
database %s due to control "
-
"signal", buf);
+
"signal", q);
kill(dp->pid, SIGTERM);
} else {
merlog("killing
database %s due to control "
-
"signal", buf);
+
"signal", q);
kill(dp->pid, SIGKILL);
}
break;
@@ -920,8 +942,9 @@
dp = dp->next;
}
if (dp == NULL) {
- fprintf(stderr, "control stop signal
for "
- "non-existing database:
%s\n", buf);
+ fprintf(stderr, "received control stop
signal for "
+ "database not under
merovingian control: %s\n",
+ q);
}
} else {
fprintf(stderr, "unknown control command: %s",
p);
@@ -1072,7 +1095,7 @@
snprintf(buf, 1024, "%s/.merovingian_lock", dbfarm);
/* we leak ret, but that doesn't matter as the file needs to remain
- * available, otherwise we lose the lock */
+ * available, otherwise we loose the lock */
if ((ret = MT_lockf(buf, F_TLOCK, 4, 1)) < 0) {
/* locking failed */
fprintf(stderr, "another merovingian is already running\n");
Index: monetdb.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/tools/monetdb.mx,v
retrieving revision 1.8.2.5
retrieving revision 1.8.2.6
diff -u -d -r1.8.2.5 -r1.8.2.6
--- monetdb.mx 6 Sep 2007 13:52:48 -0000 1.8.2.5
+++ monetdb.mx 10 Sep 2007 14:27:18 -0000 1.8.2.6
@@ -50,6 +50,7 @@
#define NO_ERR (err)0
static str dbfarm = NULL;
+static str logdir = NULL;
static int mero_running = 0;
static str
@@ -109,13 +110,13 @@
printf(" database is available again for normal use. Use
the\n");
printf(" \"lock\" command to take a database under
maintenance.\n");
} else if (strcmp(argv[1], "status") == 0) {
- printf("Usage: monetdb status [-ls] [database ...]\n");
+ printf("Usage: monetdb status [-lc] [database ...]\n");
printf(" Shows the state of a given database, or all known if
none\n");
- printf(" given. Instead of the normal mode, a long and short
mode\n");
+ printf(" given. Instead of the normal mode, a long and crash
mode\n");
printf(" control what information is displayed.\n");
printf("Options:\n");
- printf(" -l use long listing\n");
- printf(" -s use short one-line listing\n");
+ printf(" -l extended information listing\n");
+ printf(" -c crash statistics listing\n");
} else if (strcmp(argv[1], "start") == 0) {
printf("Usage: monetdb start [-a] [database ...]\n");
printf(" Starts the given database, if the MonetDB Database
Server\n");
@@ -178,7 +179,11 @@
}
/* t must be < 60 */
- sprintf(buf + i, "%ds", (int)(t));
+ if (printlong == 0 || !(i > 0 && t == 0)) {
+ sprintf(buf + i, "%ds", (int)(t));
+ } else {
+ buf[--i] = '\0';
+ }
}
static void
@@ -194,9 +199,9 @@
}
if (mode == 1) {
- /* short one-line mode */
+ /* short one-line (default) mode */
char *state;
- char avg[8];
+ char uptime[12];
char *crash;
switch (stats->state) {
@@ -215,12 +220,10 @@
}
/* override if locked for brevity */
if (stats->locked == 1)
- state = "mainten";
-
- secondsToString(avg, uplog.avguptime, 0);
+ state = "locked ";
if (uplog.lastcrash == -1) {
- crash = "no crash";
+ crash = "";
} else {
struct tm *t;
crash = alloca(sizeof(char) * 20);
@@ -228,11 +231,16 @@
strftime(crash, 20, "%Y-%m-%d %H:%M:%S", t);
}
- /* demo | running | avguptime | start | stop | crash |
lastcrash */
- printf("%-10s %s %7s %4d %4d %4d %s\n",
+ if (stats->state != SABdbRunning) {
+ uptime[0]= '\0';
+ } else {
+ secondsToString(uptime, time(NULL) - uplog.laststart,
1);
+ }
+
+ /* demo | state | uptime | crash */
+ printf("%-10s %s %12s %4d %s\n",
stats->dbname,
- state, avg,
- uplog.startcntr, uplog.stopcntr,
+ state, uptime,
uplog.crashcntr, crash);
} else if (mode == 2) {
/* long mode */
@@ -260,9 +268,9 @@
printf(" location: %s\n", stats->path);
printf(" database name: %s\n", stats->dbname);
printf(" state: %s\n", state);
- printf(" under maintenance: %s\n", stats->locked == 1 ? "yes"
: "no");
+ printf(" locked: %s\n", stats->locked == 1 ? "yes" : "no");
entry = stats->scens;
- printf(" available scenarios:");
+ printf(" scenarios:");
if (entry == NULL) {
printf(" (none)");
} else while (entry != NULL) {
@@ -271,7 +279,7 @@
}
printf("\n");
entry = stats->conns;
- printf(" listening connections:");
+ printf(" connections:");
if (entry == NULL) {
printf(" (none)");
} else while (entry != NULL) {
@@ -339,7 +347,7 @@
break;
}
if (stats->locked == 1)
- strcat(buf, ", under maintenance");
+ strcat(buf, ", locked");
printf("database %s, %s\n", stats->dbname, buf);
printf(" crash average: %d.00 %.2f %.2f (over 1, 15, 30
starts) "
"in total %d crashes\n",
@@ -357,7 +365,7 @@
command_status(int argc, char *argv[])
{
int doall = 1; /* we default to showing all */
- int mode = 0; /* 0=normal, 1=short, 2=long */
+ int mode = 1; /* 0=crash, 1=short, 2=long */
int i;
char *p;
str e;
@@ -372,8 +380,8 @@
if (argv[i][0] == '-') {
for (p = argv[i] + 1; *p != '\0'; p++) {
switch (*p) {
- case 's':
- mode = 1;
+ case 'c':
+ mode = 0;
break;
case 'l':
mode = 2;
@@ -402,8 +410,8 @@
if (mode == 1) {
/* print header for short mode */
- /* demo | running | avguptime | start | stop | crash |
lastcrash */
- printf(" name state avgutme strt stop crsh
crashdate\n");
+ /* demo | state uptime | crash lastcrash */
+ printf(" name state uptime crashes\n");
}
if (doall == 1) {
@@ -452,7 +460,7 @@
} merocom;
static void
-command_merocom(int argc, char *argv[], char *dbfarm, merocom mode)
+command_merocom(int argc, char *argv[], merocom mode)
{
int doall = 0;
char path[8096];
@@ -563,7 +571,7 @@
printf("%s: database is not running:
%s\n", type, argv[i]);
} else if (mode == START && stats->state ==
SABdbRunning) {
printf("%s: database is already
running: %s\n",
- type, argv[1]);
+ type, argv[i]);
} else {
snprintf(buf, 256, "%s %s\n",
stats->dbname, type);
fputs(buf, f);
@@ -579,7 +587,7 @@
}
static void
-command_create(int argc, char *argv[], char *dbfarm)
+command_create(int argc, char *argv[])
{
if (argc == 1 || argc >= 4) {
/* print help message for this command */
@@ -670,9 +678,9 @@
buf[PATHLENGTH] = '\0';
d = opendir(dir);
if (d == NULL) {
- snprintf(data, 8095, "unable to open directory %s: %s",
- dir, strerror(errno));
- return(GDKstrdup(data));
+ /* silently return if we cannot find the directory; it's
+ * probably already deleted */
+ return(NO_ERR);
}
while ((e = readdir(d)) != NULL) {
snprintf(path, PATHLENGTH, "%s/%s", dir, e->d_name);
@@ -761,6 +769,7 @@
if (stats != NULL) {
err e;
+ char buf[8096];
if (stats->state == SABdbRunning) {
fprintf(stderr, "destroy: database '%s' is
still running, "
@@ -794,9 +803,20 @@
fprintf(stderr, "destroy: failed to destroy
'%s': %s\n",
argv[1], e);
GDKfree(e);
+ SABAOTHfreeStatus(&stats);
exit(1);
}
SABAOTHfreeStatus(&stats);
+ /* this is annoying, but till the time we have something
+ * better, we should do it like this; the logdir is a
+ * separate directory */
+ snprintf(buf, 8096, "%s/%s", logdir, argv[1]);
+ if ((e = deletedir(buf)) != NULL) {
+ fprintf(stderr, "destroy: failed to destroy
'%s': %s\n",
+ argv[1], e);
+ GDKfree(e);
+ exit(1);
+ }
printf("successfully destroyed database '%s'\n",
dbname);
} else {
fprintf(stderr, "destroy: no such database: %s\n",
dbname);
@@ -919,13 +939,20 @@
if (*buf && strncmp(buf, "gdk_dbfarm=", 11) == 0) {
p = strchr(buf, '=');
dbfarm = replacePrefix(++p);
+ } else if (*buf && strncmp(buf, "sql_logdir=", 11) == 0) {
+ p = strchr(buf, '=');
+ logdir = replacePrefix(++p);
}
}
fclose(cnf);
if (dbfarm == NULL) {
- fprintf(stderr, "%s: cannot find dbfarm via config file\n",
argv[0]);
+ fprintf(stderr, "%s: cannot find gdk_dbfarm in config file\n",
argv[0]);
+ exit(2);
+ }
+ if (logdir == NULL) {
+ fprintf(stderr, "%s: cannot find sql_logdir in config file\n",
argv[0]);
exit(2);
}
@@ -949,7 +976,7 @@
if (argc <= 1) {
command_help(0, NULL);
} else if (strcmp(argv[1], "create") == 0) {
- command_create(argc - 1, &argv[1], dbfarm);
+ command_create(argc - 1, &argv[1]);
} else if (strcmp(argv[1], "destroy") == 0) {
command_destroy(argc - 1, &argv[1]);
} else if (strcmp(argv[1], "lock") == 0) {
@@ -959,11 +986,11 @@
} else if (strcmp(argv[1], "status") == 0) {
command_status(argc - 1, &argv[1]);
} else if (strcmp(argv[1], "start") == 0) {
- command_merocom(argc - 1, &argv[1], dbfarm, START);
+ command_merocom(argc - 1, &argv[1], START);
} else if (strcmp(argv[1], "stop") == 0) {
- command_merocom(argc - 1, &argv[1], dbfarm, STOP);
+ command_merocom(argc - 1, &argv[1], STOP);
} else if (strcmp(argv[1], "kill") == 0) {
- command_merocom(argc - 1, &argv[1], dbfarm, KILL);
+ command_merocom(argc - 1, &argv[1], KILL);
} else if (strcmp(argv[1], "help") == 0 || strcmp(argv[1], "-h") == 0) {
command_help(argc - 1, &argv[1]);
} else if (strcmp(argv[1], "version") == 0 || strcmp(argv[1], "-v") ==
0) {
Index: Makefile.ag
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/tools/Makefile.ag,v
retrieving revision 1.43.2.4
retrieving revision 1.43.2.5
diff -u -d -r1.43.2.4 -r1.43.2.5
--- Makefile.ag 6 Sep 2007 13:52:48 -0000 1.43.2.4
+++ Makefile.ag 10 Sep 2007 14:27:13 -0000 1.43.2.5
@@ -18,7 +18,7 @@
MTSAFE
INCLUDES = -I../mal $(CLIENTS_INCS) $(MONETDB_INCS) $(OPENSSL_INCS)
$(PCRE_CFLAGS)
-man_MANS = monetdb.1
+man_MANS = monetdb.1 merovingian.1
bin_mserver5 = {
SOURCES = mserver5.mx.in
--- NEW FILE: merovingian.1 ---
.\" Process this file with
.\" groff -man -Tascii foo.1
.\"
.TH MONETDB 1 "SEPTEMBER 2007" Application "MonetDB Applications"
.SH NAME
merovingian \- the MonetDB Database Server daemon
.SH SYNOPSIS
.B merovingian
[database ...]
.SH DESCRIPTION
.B merovingian
is the MonetDB Database Server daemon. It is not meant to be used in
interactive environments, and hence has no help or version commands nor
flags. The typical use of
.B merovingian
is to be started from a startup script, such as from
.I /etc/init.d/
on Linux systems or
.BR smf (5)
on Solaris systems, as part of a system startup.
.P
A
.B merovingian
instance manages one local cluster based on the dbfarm specified in the
.I /etc/monetdb5.conf
config file. Within this local cluster
.B merovingian
takes care of starting up databases when necessary, and stopping them
either upon request via
.BR monetdb (1)
or when being shut down. Client connections initially are made against
.B merovingian
which redirects the client to the appropriate database process, started
on the fly when necessary.
.P
When started,
.B merovingian
runs in the foreground, sending log messages to
.I /var/log/merovingian.log
, until being sent a stop, terminate or interrupt signal. All arguments
given when starting
.B merovingian
are considered to be databases to be pre-started. Pre-started databases
are started as part of the startup of
.B merovingian
, which means their startup is not delayed until the first client
requests for them.
.SH CONFIGURATION
.B merovingian
uses the default configuration file for its behaviour. The following
options can be found under the
.I Merovingian
section in the configuration file.
.IP mero_msglog
.IP mero_errlog
When both options are unset,
.B merovingian
logs messages and errors to the stdout and stderr channels on the
caller's console. By setting one or both of the
.B mero_msglog
and
.B mero_errlog
variables, one can specify messages and/or errors to be logged to a file
instead. It is legitimate to have both
.B mero_msglog
and
.B mero_errlog
pointing to the same file.
.IP mero_timeinterval
Log messages from started databases may not be instantly logged, because
that database process that writes the message does not flush its
buffered stream. Since
.B merovingian
cannot force other processes to flush their output, the time when
.B merovingian
receives the message need not to be (close) to the actual time the
message was generated. For this reason it makes not much sense to tag
each line with the time it is logged by
.B merovingian
either to file or the console. Instead,
.B merovingian
does a rough time indication by inserting TME records in the log output.
The seconds interval in which.
.B merovingian
should print such TME record can be specified in the
.B mero_timeinterval
option. Note that an interval of
.B 0
makes Merovingian print a TME record for every log record, which is the
default of this option when unset.
.IP mero_exittimeout
All database servers that were started by
.B merovingian
are shut down when
.B merovingian
is shut down. This behaviour is desirable if the
.B merovingian
process is ran from a start script that represents the MonetDB Database
Server. Setting the
.B mero_exittimeout
option to a positive
non-zero value, causes each started database server to be shut down by
.B merovingian
when it shuts doen itself with a given time-out in seconds. If the
time-out expires, the database server is killed using the SIGKILL
signal. A time-out value of
.B 0
means that no attempt is made to shut down started database servers. As
a result, database servers will remain active after
.B merovingian
is stopped. This situation may yield in confusing scenarios, hence you
are strongly adviced to set the
.B mero_exittimeout
option as to override the
.B 0
default.
.SH "RETURN VALUE"
.B merovingian
returns exit code
.B 0
if it successfully stopped after a stop signal. When an error occurs
during startup that prevents
.B merovingian
from functioning properly, an exit code
.B 1
is returned.
.SH FILES
.I /etc/monetdb5.conf
.RS
The configuration file for MonetDB, located in the system configuration
directory.
.RE
.I /var/log/merovingian.log
.RS
The configuration file default location to write log output to.
.SH "SEE ALSO"
.BR monetdb (1)
.\".BR mserver5 (1)
Index: mcheckpoint
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/tools/mcheckpoint,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -d -r1.1.2.2 -r1.1.2.3
--- mcheckpoint 3 Sep 2007 13:08:35 -0000 1.1.2.2
+++ mcheckpoint 10 Sep 2007 14:27:13 -0000 1.1.2.3
@@ -50,7 +50,7 @@
DBFARM=$MONETDB5_PREFIX/var/MonetDB5/dbfarm
DBLOGS=$MONETDB5_PREFIX/var/MonetDB5/dblogs
-CHKPNTDIR=$MONETDB5_PREFIX/var/MonetDB5/chkpnt
+CHKPNTDIR=$MONETDB5_PREFIX/var/MonetDB5/dbarchive
TAG=`date +%F-%H%M%S`
# First perform some sanity checks
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins