Changeset: 8e24f88d44aa for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8e24f88d44aa
Added Files:
sql/test/wlcr/Tests/wlc60.py
sql/test/wlcr/Tests/wlc60.stable.err
sql/test/wlcr/Tests/wlc60.stable.out
sql/test/wlcr/Tests/wlr60.py
sql/test/wlcr/Tests/wlr60.stable.err
sql/test/wlcr/Tests/wlr60.stable.out
Modified Files:
monetdb5/modules/mal/wlcr.c
monetdb5/modules/mal/wlcr.h
monetdb5/modules/mal/wlcr.mal
sql/backends/monet5/sql_wlcr.c
sql/scripts/60_wlcr.sql
sql/test/wlcr/Tests/All
Branch: wlcr
Log Message:
Implement state changes
Logging can be suspended/resumed with proper warnings.
diffs (truncated from 574 to 300 lines):
diff --git a/monetdb5/modules/mal/wlcr.c b/monetdb5/modules/mal/wlcr.c
--- a/monetdb5/modules/mal/wlcr.c
+++ b/monetdb5/modules/mal/wlcr.c
@@ -363,38 +363,16 @@ WLCdrift(Client cntxt, MalBlkPtr mb, Mal
str
WLCmaster(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
-{
- int role = 0;
+{
char path[PATHLENGTH];
- (void) stk;
- (void) pci;
(void) cntxt;
(void) mb;
- if( pci->argc ==2){
- role = *getArgReference_int(stk, pci,1);
- switch(wlcr_role){
- case 0:
- if( role != WLCR_STARTED)
- throw(MAL,"master","WARNING: use master() or
master(1) to start master role");
- break;
- case WLCR_STARTED:
- if( role != WLCR_PAUSED && role != WLCR_STOPPED)
- throw(MAL,"master","WARNING: use master(2) to
pause, and master(4) to stop");
- break;
- case WLCR_PAUSED:
- if( role != WLCR_RESUMED && role != WLCR_STOPPED)
- throw(MAL,"master","WARNING: use master(3) to
resume, and master(4) to stop");
- break;
- case WLCR_RESUMED:
- if( role != WLCR_PAUSED && role != WLCR_STOPPED)
- throw(MAL,"master","WARNING: use master(2) to
pause, and master(4) to stop");
- break;
- default:
- case WLCR_STOPPED:
- // end of life cycle;
- ;
- }
- }
+ if( wlcr_role == WLCR_STOP)
+ throw(MAL,"master","WARNING: logging has been stopped. Use new
snapshot");
+ if( wlcr_role == WLCR_RUN)
+ throw(MAL,"master","WARNING: already in master mode, call
ignored");
+ if( pci->argc == 2)
+ wlcr_logs = GDKstrdup( *getArgReference_str(stk, pci,1));
if ( wlcr_logs == NULL){
wlcr_dbname = GDKgetenv("gdk_dbname");
@@ -406,25 +384,54 @@ WLCmaster(Client cntxt, MalBlkPtr mb, Ma
wlcr_logs = NULL;
throw(SQL,"wlcr.master","Could not create %s\n",
wlcr_logs);
}
- wlcr_role = WLCR_STARTED;
- WLCsetConfig();
- } else{
- WLCgetConfig();
- if( role){
- if(role == WLCR_RESUMED){
- wlcr_role = WLCR_STARTED;
- } else
- wlcr_role = role;
- if( role == WLCR_PAUSED)
- wlcr_pausetag = wlcr_tag;
- WLCsetConfig();
- }
- }
-#ifdef _WLC_DEBUG_
- mnstr_printf(cntxt->fdout,"#master batches %d file open %d\n",
wlcr_batches, wlcr_fd != NULL);
-#endif
- if(role == WLCR_RESUMED)
- throw(MAL,"wlcr.master","#WARNING: %d update transaction missed
due to paused logging", wlcr_tag - wlcr_pausetag);
+ }
+ wlcr_role= WLCR_RUN;
+ WLCsetConfig();
+ return MAL_SUCCEED;
+}
+
+str
+WLCpausemaster(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+ (void) cntxt;
+ (void) mb;
+ (void) stk;
+ (void) pci;
+ if( wlcr_role != WLCR_RUN )
+ throw(MAL,"master","WARNING: master role not active");
+ wlcr_role = WLCR_PAUSE;
+ wlcr_pausetag = wlcr_tag;
+ WLCsetConfig();
+ return MAL_SUCCEED;
+}
+
+str
+WLCresumemaster(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+ (void) cntxt;
+ (void) mb;
+ (void) stk;
+ (void) pci;
+ if( wlcr_role != WLCR_PAUSE )
+ throw(MAL,"master","WARNING: master role not suspended");
+ wlcr_role = WLCR_RUN;
+ WLCsetConfig();
+ if( wlcr_tag - wlcr_pausetag)
+ throw(MAL,"wlcr.master","#WARNING: %d updates missed due to
paused logging", wlcr_tag - wlcr_pausetag);
+ return MAL_SUCCEED;
+}
+
+str
+WLCstopmaster(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+ (void) cntxt;
+ (void) mb;
+ (void) stk;
+ (void) pci;
+ if( wlcr_role != WLCR_RUN )
+ throw(MAL,"master","WARNING: master role not active");
+ wlcr_role = WLCR_STOP;
+ WLCsetConfig();
return MAL_SUCCEED;
}
@@ -806,6 +813,12 @@ WLCwrite(Client cntxt)
if( cntxt->wlcr == 0 || cntxt->wlcr->stop <= 1)
return MAL_SUCCEED;
+ if( wlcr_role != WLCR_RUN){
+ trimMalVariables(cntxt->wlcr, NULL);
+ resetMalBlk(cntxt->wlcr, 0);
+ cntxt->wlcr_kind = WLCR_QUERY;
+ return MAL_SUCCEED;
+ }
if( wlcr_logs ){
if( wlcr_start + wlcr_drift < GDKms()/1000)
WLCcloselogger();
@@ -821,7 +834,7 @@ WLCwrite(Client cntxt)
else {
// filter out queries that run too shortly
p = getInstrPtr(cntxt->wlcr,0);
- if ( wlcr_role != WLCR_STOPPED && ( cntxt->wlcr_kind !=
WLCR_QUERY || wlcr_threshold == 0 || wlcr_threshold < GDKms() - p->ticks ) ){
+ if ( cntxt->wlcr_kind != WLCR_QUERY || wlcr_threshold
== 0 || wlcr_threshold < GDKms() - p->ticks ){
MT_lock_set(&wlcr_lock);
p = getInstrPtr(cntxt->wlcr,0);
p = pushLng(cntxt->wlcr,p, GDKms() - p->ticks);
@@ -842,7 +855,7 @@ WLCwrite(Client cntxt)
#ifdef _WLC_DEBUG_
printFunction(cntxt->fdout, cntxt->wlcr, 0, LIST_MAL_ALL );
#endif
- if( wlcr_role == WLCR_STOPPED)
+ if( wlcr_role == WLCR_STOP)
throw(MAL,"wlcr.write","Logging for this snapshot has been
stopped. Use a new snapshot to continue logging.");
return msg;
}
diff --git a/monetdb5/modules/mal/wlcr.h b/monetdb5/modules/mal/wlcr.h
--- a/monetdb5/modules/mal/wlcr.h
+++ b/monetdb5/modules/mal/wlcr.h
@@ -23,10 +23,9 @@
#define WLCR_IGNORE 4
/* WLCR modes */
-#define WLCR_STARTED 1 // started for the current snapshot
-#define WLCR_PAUSED 2 // suspend the creation of log files
-#define WLCR_RESUMED 3 // restart log file creation
-#define WLCR_STOPPED 4 // finished last log file for this snapsho
+#define WLCR_RUN 1 // started for the current snapshot
+#define WLCR_PAUSE 2 // suspend the creation of log files
+#define WLCR_STOP 3 // finished last log file for this
snapsho
mal_export int wlcr_threshold;
mal_export int wlcr_batches;
@@ -40,6 +39,9 @@ mal_export int WLCused(void);
mal_export str WLCgetConfig(void);
mal_export str WLCinitCmd(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
mal_export str WLCmaster(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
+mal_export str WLCpausemaster(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
+mal_export str WLCresumemaster(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
+mal_export str WLCstopmaster(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
mal_export str WLClogthreshold(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
mal_export str WLClogrollback(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
mal_export str WLCdrift(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
diff --git a/monetdb5/modules/mal/wlcr.mal b/monetdb5/modules/mal/wlcr.mal
--- a/monetdb5/modules/mal/wlcr.mal
+++ b/monetdb5/modules/mal/wlcr.mal
@@ -19,6 +19,22 @@ pattern master()
address WLCmaster
comment "Activate the workload-capture-replay";
+pattern master(path:str)
+address WLCmaster
+comment "Activate the workload-capture-replay. Use a different location for
the logs.";
+
+pattern pausemaster()
+address WLCpausemaster
+comment "Suspend capturing the logs";
+
+pattern resumemaster()
+address WLCresumemaster
+comment "Resume capturing the logs";
+
+pattern stopmaster()
+address WLCstopmaster
+comment "Stop capturing the logs";
+
pattern drift(duration:int)
address WLCdrift
comment "Maximal duration of collecting a transaction log befor releasing it";
diff --git a/sql/backends/monet5/sql_wlcr.c b/sql/backends/monet5/sql_wlcr.c
--- a/sql/backends/monet5/sql_wlcr.c
+++ b/sql/backends/monet5/sql_wlcr.c
@@ -283,13 +283,19 @@ WLRprocess(void *arg)
msg= runMAL(c,mb,0,0);
wlr_tag++;
WLRsetConfig();
+ // ignore warnings
+ if (msg && strstr(msg,"WARNING"))
+ msg = MAL_SUCCEED;
if( msg != MAL_SUCCEED){
// they should always succeed
mnstr_printf(GDKerr,"ERROR in
processing batch %d :%s\n", i, msg);
printFunction(GDKerr, mb, 0,
LIST_MAL_DEBUG );
mvc_rollback(sql,0,NULL);
- break;
- }
+ // cleanup
+ resetMalBlk(mb, 1);
+ trimMalVariables(mb, NULL);
+ pc = 0;
+ } else
if( mvc_commit(sql, 0, 0) < 0)
mnstr_printf(GDKerr,"#wlcr.process transaction commit failed");
} else {
@@ -303,6 +309,12 @@ WLRprocess(void *arg)
resetMalBlk(mb, 1);
trimMalVariables(mb, NULL);
pc = 0;
+ } else
+ if ( getModuleId(q) == wlrRef && getFunctionId(q) ==
rollbackRef ){
+ // cleanup
+ resetMalBlk(mb, 1);
+ trimMalVariables(mb, NULL);
+ pc = 0;
}
} while( mb->errors == 0 && pc != mb->stop);
wlr_nextbatch++;
diff --git a/sql/scripts/60_wlcr.sql b/sql/scripts/60_wlcr.sql
--- a/sql/scripts/60_wlcr.sql
+++ b/sql/scripts/60_wlcr.sql
@@ -7,6 +7,21 @@
-- Workload Capture and Replay
-- Master commands
+create procedure master()
+external name wlcr.master;
+
+create procedure master(path string)
+external name wlcr.master;
+
+create procedure pausemaster()
+external name wlcr.pausemaster;
+
+create procedure resumemaster()
+external name wlcr.resumemaster;
+
+create procedure stopmaster()
+external name wlcr.stopmaster;
+
create procedure logthreshold(duration int)
external name wlcr.logthreshold;
@@ -16,9 +31,6 @@ external name wlcr.logrollback;
create procedure drift(duration int)
external name wlcr.drift;
-create procedure master()
-external name wlcr.master;
-
create procedure master(role integer)
external name wlcr.master;
diff --git a/sql/test/wlcr/Tests/All b/sql/test/wlcr/Tests/All
--- a/sql/test/wlcr/Tests/All
+++ b/sql/test/wlcr/Tests/All
@@ -27,3 +27,7 @@ wlr40
#clear the complete table
wlc50
wlr50
+
+#shuffle the master state
+wlc60
+wlr60
diff --git a/sql/test/wlcr/Tests/wlc60.py b/sql/test/wlcr/Tests/wlc60.py
new file mode 100644
--- /dev/null
+++ b/sql/test/wlcr/Tests/wlc60.py
@@ -0,0 +1,46 @@
+try:
+ from MonetDBtesting import process
+except ImportError:
+ import process
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list