Changeset: 486de99deae2 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=486de99deae2
Modified Files:
monetdb5/mal/mal_client.c
monetdb5/mal/mal_client.h
monetdb5/optimizer/opt_pipes.c
Branch: Feb2013
Log Message:
Fix optimizer compilation phase
The optimizer pipelines are compiled once. For this we used a
client record, taken from the pool. In a highly concurrent setting
it may happen that all client records have been claimed before
the compilation phase starts.
Solved by creating a static client record instead.
diffs (106 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
@@ -198,14 +198,10 @@ MCexitClient(Client c)
}
Client
-MCinitClient(oid user, bstream *fin, stream *fout)
+MCinitClientRecord(Client c, oid user, bstream *fin, stream *fout)
{
- Client c = NULL;
str prompt;
- if ((c = MCnewClient()) == NULL)
- return NULL;
-
c->user = user;
c->scenario = NULL;
c->oldscenario = NULL;
@@ -256,6 +252,16 @@ MCinitClient(oid user, bstream *fin, str
return c;
}
+Client
+MCinitClient(oid user, bstream *fin, stream *fout)
+{
+ Client c = NULL;
+
+ if ((c = MCnewClient()) == NULL)
+ return NULL;
+ return MCinitClientRecord(c, user, fin,fout);
+}
+
/*
* The administrator should be initialized to enable interpretation of
* the command line arguments, before it starts serviceing statements
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
@@ -202,6 +202,7 @@ mal_export int MCdefault;
mal_export Client MCgetClient(int id);
mal_export Client MCinitClient(oid user, bstream *fin, stream *fout);
+mal_export Client MCinitClientRecord(Client c, oid user, bstream *fin, stream
*fout);
mal_export int MCinitClientThread(Client c);
mal_export void MCcloseClient(Client c);
mal_export Client MCforkClient(Client c);
diff --git a/monetdb5/optimizer/opt_pipes.c b/monetdb5/optimizer/opt_pipes.c
--- a/monetdb5/optimizer/opt_pipes.c
+++ b/monetdb5/optimizer/opt_pipes.c
@@ -515,28 +515,29 @@ compileOptimizer(Client cntxt, str name)
int i, j;
Symbol sym;
str msg = MAL_SUCCEED;
+ ClientRec c;
+ memset((char*)&c, 0, sizeof(c));
for (i = 0; i < MAXOPTPIPES && pipes[i].name; i++) {
if (strcmp(pipes[i].name, name) == 0 && pipes[i].mb == 0) {
/* precompile the pipeline as MAL string */
- Client c = MCinitClient((oid) 1, 0, 0);
- assert(c != NULL);
- c->nspace = newModule(NULL, putName("user", 4));
- c->father = cntxt; /* to avoid conflicts on GDKin
*/
- c->fdout = cntxt->fdout;
- if (setScenario(c, "mal"))
+ MCinitClientRecord(&c,(oid) 1, 0, 0);
+ c.nspace = newModule(NULL, putName("user", 4));
+ c.father = cntxt; /* to avoid conflicts on GDKin
*/
+ c.fdout = cntxt->fdout;
+ if (setScenario(&c, "mal"))
throw(MAL, "optimizer.addOptimizerPipe",
"failed to set scenario");
- (void) MCinitClientThread(c);
+ (void) MCinitClientThread(&c);
for (j = 0; j < MAXOPTPIPES && pipes[j].def; j++) {
if (pipes[j].mb == NULL) {
- if (pipes[j].prerequisite &&
getAddress(c->fdout, NULL, optimizerRef, pipes[j].prerequisite, TRUE) == NULL)
+ if (pipes[j].prerequisite &&
getAddress(c.fdout, NULL, optimizerRef, pipes[j].prerequisite, TRUE) == NULL)
continue;
- MSinitClientPrg(c, "user",
pipes[j].name);
- msg = compileString(&sym, c,
pipes[j].def);
+ MSinitClientPrg(&c, "user",
pipes[j].name);
+ msg = compileString(&sym, &c,
pipes[j].def);
if (msg != MAL_SUCCEED) {
- c->errbuf = NULL;
- c->mythread = 0;
- MCcloseClient(c);
+ c.errbuf = NULL;
+ c.mythread = 0;
+ MCcloseClient(&c);
return msg;
}
pipes[j].mb = copyMalBlk(sym->def);
@@ -544,9 +545,9 @@ compileOptimizer(Client cntxt, str name)
}
/* don't cleanup thread info since the thread continues
to
* exist, just this client record is closed */
- c->errbuf = NULL;
- c->mythread = 0;
- MCcloseClient(c);
+ c.errbuf = NULL;
+ c.mythread = 0;
+ MCcloseClient(&c);
msg = validateOptimizerPipes();
if (msg != MAL_SUCCEED)
return msg;
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list