Changeset: 39fccc5ff92d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=39fccc5ff92d
Modified Files:
monetdb5/mal/mal_client.c
monetdb5/mal/mal_client.h
monetdb5/mal/mal_interpreter.c
Branch: default
Log Message:
Partially backed out changeset 7f6bb2f9ead7.
diffs (65 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
@@ -80,6 +80,8 @@ MCinit(void)
fprintf(stderr,"!MCinit:" MAL_MALLOC_FAIL);
return false;
}
+ for (int i = 0; i < MAL_MAXCLIENTS; i++)
+ ATOMIC_INIT(&mal_clients[i].lastprint, 0);
return true;
}
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
@@ -76,6 +76,7 @@ typedef struct CLIENT {
bit sqlprofiler; /* control off-line sql
performance monitoring */
BAT *profticks; /* The representation for the SQL TRACE
*/
BAT *profstmt;
+ ATOMIC_TYPE lastprint; /* when we last printed the query */
/*
* 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
@@ -25,7 +25,6 @@ void
setqptimeout(lng usecs)
{
qptimeout = usecs;
- (void) qptimeout;
}
inline
@@ -297,6 +296,7 @@ str runMAL(Client cntxt, MalBlkPtr mb, M
* enough
*/
cntxt->lastcmd= time(0);
+ ATOMIC_SET(&cntxt->lastprint, GDKusec());
if (env != NULL) {
int res = 1;
stk = env;
@@ -560,6 +560,22 @@ str runMALsequence(Client cntxt, MalBlkP
lastcheck = runtimeProfile.ticks;
}
+ if (qptimeout > 0) {
+ lng t = GDKusec();
+ ATOMIC_BASE_TYPE lp = ATOMIC_GET(&cntxt->lastprint);
+ if ((lng) lp + qptimeout < t) {
+ /* if still the same, replace lastprint with
current
+ * time and print the query */
+ if (ATOMIC_CAS(&cntxt->lastprint, &lp, t)) {
+ const char *q = cntxt->getquery ?
cntxt->getquery(cntxt) : NULL;
+ fprintf(stderr, "#%s: query already
running "LLFMT"s: %.200s\n",
+ cntxt->mythread->name,
+ (lng) (time(0) -
cntxt->lastcmd),
+ q ? q : "");
+ }
+ }
+ }
+
/* The interpreter loop
* The interpreter is geared towards execution a MAL
* procedure together with all its descendant
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list