Changeset: 22f397e516f4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=22f397e516f4
Modified Files:
monetdb5/mal/mal_client.c
monetdb5/mal/mal_client.h
monetdb5/mal/mal_interpreter.c
monetdb5/mal/mal_runtime.c
monetdb5/modules/mal/clients.c
monetdb5/optimizer/opt_pipes.c
sql/backends/monet5/sql_optimizer.c
sql/backends/monet5/sql_scenario.c
Branch: default
Log Message:
Introduction of more session-based properties. They should be set upon system
start or
explictily with a MAL/SQL call.
diffs (truncated from 397 to 300 lines):
diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -244,8 +244,11 @@ MCinitClientRecord(Client c, oid user, b
c->father = NULL;
c->login = c->lastcmd = time(0);
c->session = GDKusec();
- c->qtimeout = 0;
- c->stimeout = 0;
+ strncpy(c->optimizer, "default_pipe", IDLENGTH);
+ c->workerlimit = 0;
+ c->memorylimit = 0;
+ c->querytimeout = 0;
+ c->sessiontimeout = 0;
c->itrace = 0;
c->errbuf = 0;
@@ -268,7 +271,6 @@ MCinitClientRecord(Client c, oid user, b
c->profticks = c->profstmt = NULL;
c->error_row = c->error_fld = c->error_msg = c->error_input = NULL;
c->sqlprofiler = 0;
- c->malprofiler = 0;
c->wlc_kind = 0;
c->wlc = NULL;
#ifndef HAVE_EMBEDDED /* no authentication in embedded mode */
@@ -363,6 +365,12 @@ MCforkClient(Client father)
son->yycur = 0;
son->father = father;
son->scenario = father->scenario;
+ strcpy(father->optimizer, son->optimizer);
+ son->workerlimit = father->workerlimit;
+ son->memorylimit = father->memorylimit;
+ son->querytimeout = father->querytimeout;
+ son->sessiontimeout = father->sessiontimeout;
+
if (son->prompt)
GDKfree(son->prompt);
son->prompt = prompt;
@@ -426,8 +434,11 @@ MCfreeClient(Client c)
c->usermodule = c->curmodule = 0;
c->father = 0;
c->login = c->lastcmd = 0;
- c->qtimeout = 0;
- c->stimeout = 0;
+ strncpy(c->optimizer, "default_pipe", IDLENGTH);
+ c->workerlimit = 0;
+ c->memorylimit = 0;
+ c->querytimeout = 0;
+ c->sessiontimeout = 0;
c->user = oid_nil;
if( c->username){
GDKfree(c->username);
@@ -453,7 +464,6 @@ MCfreeClient(Client c)
if( c->wlc)
freeMalBlk(c->wlc);
c->sqlprofiler = 0;
- c->malprofiler = 0;
c->wlc_kind = 0;
c->wlc = NULL;
MT_sema_destroy(&c->s);
diff --git a/monetdb5/mal/mal_client.h b/monetdb5/mal/mal_client.h
--- a/monetdb5/mal/mal_client.h
+++ b/monetdb5/mal/mal_client.h
@@ -62,21 +62,31 @@ typedef struct CLIENT {
char itrace; /* trace execution using interactive mdb */
/* if set to 'S' it will put
the process to sleep */
/*
- * For program debugging and performance trace we need information on
the timer and memory
- * usage patterns.
+ * Each session comes with resource limitations and predefined settings.
*/
+ char optimizer[IDLENGTH];/* The optimizer pipe preferred for this
session */
+ int workerlimit; /* maximum number of workthreads
processing a query */
+ lng memorylimit; /* Memory claim highwater mark,
0 = no limit */
+ lng querytimeout; /* query abort after x usec, 0 = no
limit*/
+ lng sessiontimeout; /* session abort after x usec,
0 = no limit */
+ bit sqlprofiler; /* control off-line sql
performance monitoring */
+
+ /*
+ * For program debugging and performance trace we keep the actual
resource claims.
+ */
+ int workers; /* Actual number of concurrent
workers */
+ lng memory; /* Actual memory claim
highwater mark */
time_t login;
time_t lastcmd; /* set when input is received */
lng session; /* usec since start of server */
- lng qtimeout; /* query abort after x usec*/
- lng stimeout; /* session abort after x usec */
+
- bit malprofiler; /* control MAL performance
monitoring */
- bit sqlprofiler; /* control off-line sql
performance monitoring */
- BAT *profticks; /* The representation for the SQL TRACE
*/
+ /* The user can request a TRACE SQL statement, calling for collecting
the events locally */
+ BAT *profticks;
BAT *profstmt;
- ATOMIC_TYPE lastprint; /* when we last printed the query */
+
+ ATOMIC_TYPE lastprint; /* when we last printed the query, to
be depricated */
/*
* Communication channels for the interconnect are stored here.
* It is perfectly legal to have a client without input stream.
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -341,7 +341,7 @@ str runMAL(Client cntxt, MalBlkPtr mb, M
garbageCollector(cntxt, mb, stk, env != stk);
if (stk && stk != env)
freeStack(stk);
- if (ret == MAL_SUCCEED && cntxt->qtimeout && mb->starttime &&
GDKusec()- mb->starttime > cntxt->qtimeout)
+ if (ret == MAL_SUCCEED && cntxt->querytimeout && mb->starttime &&
GDKusec()- mb->starttime > cntxt->querytimeout)
throw(MAL, "mal.interpreter", SQLSTATE(HYT00)
RUNTIME_QRY_TIMEOUT);
return ret;
}
@@ -438,7 +438,7 @@ callMAL(Client cntxt, MalBlkPtr mb, MalS
}
if (stk)
garbageCollector(cntxt, mb, stk, TRUE);
- if ( ret == MAL_SUCCEED && cntxt->qtimeout && mb->starttime &&
GDKusec()- mb->starttime > cntxt->qtimeout)
+ if ( ret == MAL_SUCCEED && cntxt->querytimeout && mb->starttime &&
GDKusec()- mb->starttime > cntxt->querytimeout)
throw(MAL, "mal.interpreter", SQLSTATE(HYT00)
RUNTIME_QRY_TIMEOUT);
return ret;
}
@@ -507,7 +507,7 @@ str runMALsequence(Client cntxt, MalBlkP
runtimeProfileInit(cntxt, mb, stk);
runtimeProfileBegin(cntxt, mb, stk, getInstrPtr(mb,0),
&runtimeProfileFunction);
mb->starttime = GDKusec();
- if (cntxt->stimeout && mb->starttime - cntxt->session >
cntxt->stimeout) {
+ if (cntxt->sessiontimeout && mb->starttime - cntxt->session >
cntxt->sessiontimeout) {
if ( backup != backups) GDKfree(backup);
if ( garbage != garbages) GDKfree(garbage);
throw(MAL, "mal.interpreter", SQLSTATE(HYT00)
RUNTIME_SESSION_TIMEOUT);
@@ -784,7 +784,7 @@ str runMALsequence(Client cntxt, MalBlkP
runtimeProfileExit(cntxt, mb, stk, getInstrPtr(mb,0),
&runtimeProfileFunction);
if (pcicaller && garbageControl(getInstrPtr(mb, 0)))
garbageCollector(cntxt, mb, stk, TRUE);
- if (cntxt->qtimeout && mb->starttime && GDKusec()-
mb->starttime > cntxt->qtimeout){
+ if (cntxt->querytimeout && mb->starttime && GDKusec()-
mb->starttime > cntxt->querytimeout){
freeException(ret); /* overrule exception */
ret= createException(MAL, "mal.interpreter",
SQLSTATE(HYT00) RUNTIME_QRY_TIMEOUT);
break;
@@ -805,7 +805,7 @@ str runMALsequence(Client cntxt, MalBlkP
ret = createException(MAL,"interpreter",
"failed instruction2str");
}
// runtimeProfileBegin already sets the time in the
instruction
- if (cntxt->qtimeout && mb->starttime && GDKusec()-
mb->starttime > cntxt->qtimeout){
+ if (cntxt->querytimeout && mb->starttime && GDKusec()-
mb->starttime > cntxt->querytimeout){
freeException(ret); /* in case it's set */
ret = createException(MAL, "mal.interpreter",
SQLSTATE(HYT00) RUNTIME_QRY_TIMEOUT);
break;
@@ -927,7 +927,7 @@ str runMALsequence(Client cntxt, MalBlkP
/* unknown exceptions lead to propagation */
if (exceptionVar == -1) {
- if (cntxt->qtimeout && mb->starttime && GDKusec()-
mb->starttime > cntxt->qtimeout)
+ if (cntxt->querytimeout && mb->starttime && GDKusec()-
mb->starttime > cntxt->querytimeout)
ret= createException(MAL, "mal.interpreter",
SQLSTATE(HYT00) RUNTIME_QRY_TIMEOUT);
stkpc = mb->stop;
continue;
@@ -976,7 +976,7 @@ str runMALsequence(Client cntxt, MalBlkP
}
}
if (stkpc == mb->stop) {
- if (cntxt->qtimeout && mb->starttime &&
GDKusec()- mb->starttime > cntxt->qtimeout){
+ if (cntxt->querytimeout && mb->starttime &&
GDKusec()- mb->starttime > cntxt->querytimeout){
ret= createException(MAL,
"mal.interpreter", SQLSTATE(HYT00) RUNTIME_QRY_TIMEOUT);
stkpc = mb->stop;
}
@@ -1208,7 +1208,7 @@ str runMALsequence(Client cntxt, MalBlkP
default:
stkpc++;
}
- if (cntxt->qtimeout && mb->starttime && GDKusec()-
mb->starttime > cntxt->qtimeout){
+ if (cntxt->querytimeout && mb->starttime && GDKusec()-
mb->starttime > cntxt->querytimeout){
if (ret == MAL_SUCCEED)
ret= createException(MAL, "mal.interpreter",
SQLSTATE(HYT00) RUNTIME_QRY_TIMEOUT);
stkpc= mb->stop;
diff --git a/monetdb5/mal/mal_runtime.c b/monetdb5/mal/mal_runtime.c
--- a/monetdb5/mal/mal_runtime.c
+++ b/monetdb5/mal/mal_runtime.c
@@ -188,6 +188,7 @@ runtimeProfileBegin(Client cntxt, MalBlk
workingset[tid].mb = mb;
workingset[tid].stk = stk;
workingset[tid].pci = pci;
+ cntxt->workers ++;
MT_lock_unset(&mal_delayLock);
}
/* always collect the MAL instruction execution time */
@@ -210,6 +211,7 @@ runtimeProfileExit(Client cntxt, MalBlkP
workingset[tid].mb = 0;
workingset[tid].stk = 0;
workingset[tid].pci = 0;
+ cntxt->workers --;
MT_lock_unset(&mal_delayLock);
}
diff --git a/monetdb5/modules/mal/clients.c b/monetdb5/modules/mal/clients.c
--- a/monetdb5/modules/mal/clients.c
+++ b/monetdb5/modules/mal/clients.c
@@ -229,7 +229,7 @@ CLTstop(Client cntxt, MalBlkPtr mb, MalS
(void) mb;
if (cntxt->user == mal_clients[id].user || cntxt->user == MAL_ADMIN)
- mal_clients[id].qtimeout = 1; /* stop client in one microsecond
*/
+ mal_clients[id].querytimeout = 1; /* stop client in one
microsecond */
/* this forces the designated client to stop at the next instruction */
return MAL_SUCCEED;
}
@@ -258,8 +258,8 @@ CLTstopSession(Client cntxt, MalBlkPtr m
if (mal_clients[idx].mode == FREECLIENT)
throw(MAL,"timeout","Session not active anymore ");
if (cntxt->user == mal_clients[idx].user || cntxt->user == MAL_ADMIN){
- mal_clients[idx].qtimeout = 1; /* stop client in one microsecond */
- mal_clients[idx].stimeout = 1; /* stop client session */
+ mal_clients[idx].querytimeout = 1; /* stop client in one microsecond */
+ mal_clients[idx].sessiontimeout = 1; /* stop client session */
}
/* this forces the designated client to stop at the next instruction */
return MAL_SUCCEED;
@@ -293,7 +293,7 @@ CLTsetSessionTimeout(Client cntxt, MalBl
sto= *getArgReference_lng(stk,pci,1);
if( sto < 0)
throw(MAL,"timeout","Session time out should be >= 0");
- cntxt->stimeout = sto * 1000 * 1000;
+ cntxt->sessiontimeout = sto * 1000 * 1000;
return MAL_SUCCEED;
}
@@ -306,7 +306,7 @@ CLTsetTimeout(Client cntxt, MalBlkPtr mb
qto= *getArgReference_lng(stk,pci,1);
if( qto < 0)
throw(MAL,"timeout","Query time out should be >= 0");
- cntxt->qtimeout = qto * 1000 * 1000;
+ cntxt->querytimeout = qto * 1000 * 1000;
return MAL_SUCCEED;
}
@@ -333,7 +333,7 @@ CLTqueryTimeout(Client cntxt, MalBlkPtr
qto= *getArgReference_lng(stk,pci,2);
if( qto < 0)
throw(MAL,"timeout","Query time out should be >= 0");
- mal_clients[idx].qtimeout = qto * 1000 * 1000;
+ mal_clients[idx].querytimeout = qto * 1000 * 1000;
return MAL_SUCCEED;
}
@@ -381,7 +381,7 @@ CLTsessionTimeout(Client cntxt, MalBlkPt
throw(MAL,"timeout","Illegal session id");
if (mal_clients[idx].mode == FREECLIENT)
throw(MAL,"timeout","Session not active anymore ");
- mal_clients[idx].stimeout = sto * 1000 * 1000;
+ mal_clients[idx].sessiontimeout = sto * 1000 * 1000;
return MAL_SUCCEED;
}
@@ -392,8 +392,8 @@ CLTgetTimeout(Client cntxt, MalBlkPtr mb
lng *qto= getArgReference_lng(stk,pci,0);
lng *sto= getArgReference_lng(stk,pci,1);
(void) mb;
- *qto = cntxt->qtimeout;
- *sto = cntxt->stimeout;
+ *qto = cntxt->querytimeout;
+ *sto = cntxt->sessiontimeout;
return MAL_SUCCEED;
}
@@ -648,13 +648,13 @@ CLTshutdown(Client cntxt, MalBlkPtr mb,
str
CLTsessions(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
- BAT *id = NULL, *user = NULL, *login = NULL, *stimeout = NULL,
*qtimeout = NULL, *last= NULL, *active= NULL;
+ BAT *id = NULL, *user = NULL, *login = NULL, *sessiontimeout = NULL,
*querytimeout = NULL, *last= NULL, *active= NULL;
bat *idId = getArgReference_bat(stk,pci,0);
bat *userId = getArgReference_bat(stk,pci,1);
bat *loginId = getArgReference_bat(stk,pci,2);
- bat *stimeoutId = getArgReference_bat(stk,pci,3);
+ bat *sessiontimeoutId = getArgReference_bat(stk,pci,3);
bat *lastId = getArgReference_bat(stk,pci,4);
- bat *qtimeoutId = getArgReference_bat(stk,pci,5);
+ bat *querytimeoutId = getArgReference_bat(stk,pci,5);
bat *activeId = getArgReference_bat(stk,pci,6);
Client c;
timestamp ret;
@@ -668,16 +668,16 @@ CLTsessions(Client cntxt, MalBlkPtr mb,
id = COLnew(0, TYPE_int, 0, TRANSIENT);
user = COLnew(0, TYPE_str, 0, TRANSIENT);
login = COLnew(0, TYPE_timestamp, 0, TRANSIENT);
- stimeout = COLnew(0, TYPE_lng, 0, TRANSIENT);
+ sessiontimeout = COLnew(0, TYPE_lng, 0, TRANSIENT);
last = COLnew(0, TYPE_timestamp, 0, TRANSIENT);
- qtimeout = COLnew(0, TYPE_lng, 0, TRANSIENT);
+ querytimeout = COLnew(0, TYPE_lng, 0, TRANSIENT);
active = COLnew(0, TYPE_int, 0, TRANSIENT);
- if (id == NULL || user == NULL || login == NULL || stimeout == NULL ||
last == NULL || qtimeout == NULL || active == NULL){
+ if (id == NULL || user == NULL || login == NULL || sessiontimeout ==
NULL || last == NULL || querytimeout == NULL || active == NULL){
if ( id) BBPunfix(id->batCacheid);
if ( user) BBPunfix(user->batCacheid);
if ( login) BBPunfix(login->batCacheid);
- if ( stimeout) BBPunfix(stimeout->batCacheid);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list