Changeset: 84db3ebd9b79 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=84db3ebd9b79
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
clients/Tests/exports.stable.out
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
Branch: wlcr
Log Message:
Added a replicate stop command.
diffs (137 lines):
diff --git a/clients/Tests/MAL-signatures.stable.out
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -8793,6 +8793,7 @@ Ready.
[ "wlcr", "revoke_function", "pattern
wlcr.revoke_function(sname:str, fcnid:int, grantee:str, privs:int, grant:int,
grantor:int):void ", "WLCRgeneric;", "Catalog operation revoke_function"
]
[ "wlcr", "revoke_roles", "pattern wlcr.revoke_roles(sname:str, auth:str,
grantor:int, admin:int):void ", "WLCRgeneric;", "Catalog operation
revoke_roles" ]
[ "wlcr", "rollback", "pattern wlcr.rollback():void ",
"WLCRcommitCmd;", "Rollback the workload-capture-replay record" ]
+[ "wlcr", "stop", "pattern wlcr.stop():void ", "WLCRstop;",
"Terminate keeping a log on this branch" ]
[ "wlcr", "transaction", "pattern wlcr.transaction():void ",
"WLCRgeneric;", "Start an autocommit transaction" ]
[ "wlcr", "transaction_begin", "pattern
wlcr.transaction_begin(chain:int, name:str):void ", "WLCRgeneric;", "A
transaction statement (type can be commit,release,rollback or start)" ]
[ "wlcr", "transaction_commit", "pattern
wlcr.transaction_commit(chain:int, name:str):void ", "WLCRgeneric;", "A
transaction statement (type can be commit,release,rollback or start)" ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -11158,6 +11158,7 @@ Ready.
[ "wlcr", "revoke_function", "pattern
wlcr.revoke_function(sname:str, fcnid:int, grantee:str, privs:int, grant:int,
grantor:int):void ", "WLCRgeneric;", "Catalog operation revoke_function"
]
[ "wlcr", "revoke_roles", "pattern wlcr.revoke_roles(sname:str, auth:str,
grantor:int, admin:int):void ", "WLCRgeneric;", "Catalog operation
revoke_roles" ]
[ "wlcr", "rollback", "pattern wlcr.rollback():void ",
"WLCRcommitCmd;", "Rollback the workload-capture-replay record" ]
+[ "wlcr", "stop", "pattern wlcr.stop():void ", "WLCRstop;",
"Terminate keeping a log on this branch" ]
[ "wlcr", "transaction", "pattern wlcr.transaction():void ",
"WLCRgeneric;", "Start an autocommit transaction" ]
[ "wlcr", "transaction_begin", "pattern
wlcr.transaction_begin(chain:int, name:str):void ", "WLCRgeneric;", "A
transaction statement (type can be commit,release,rollback or start)" ]
[ "wlcr", "transaction_commit", "pattern
wlcr.transaction_commit(chain:int, name:str):void ", "WLCRgeneric;", "A
transaction statement (type can be commit,release,rollback or start)" ]
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1896,6 +1896,7 @@ str WLCRmaster(Client cntxt, MalBlkPtr m
str WLCRquery(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
str WLCRrollback(Client cntxt);
str WLCRrollbackCmd(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
+str WLCRstop(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
str WLCRupdate(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
str XMLattribute(xml *ret, str *name, str *val);
str XMLcomment(xml *x, str *s);
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
@@ -142,14 +142,16 @@ WLCRinit(Client cntxt)
if (dbname){
dir = GDKfilepath(0,0,"master",0);
snprintf(path, PATHLENGTH,"%s%cwlcr",dir, DIR_SEP);
-#ifdef _WLCR_DEBUG_
- mnstr_printf(cntxt->fdout,"#Testing WLCR %s\n", path);
-#endif
wlcr_start = 0;
fd = fopen(path,"r");
if( fd){
// database is in master tracking mode
if( fscanf(fd,"%d %d", &wlcr_batch, &wlcr_threshold) ==
2){
+ if( wlcr_batch < 0){
+ // logging was stopped
+ (void) fclose(fd);
+ return MAL_SUCCEED;
+ }
wlcr_dir = dir;
#ifdef _WLCR_DEBUG_
mnstr_printf(cntxt->fdout,"#Master control
active:%d %d\n", wlcr_batch, wlcr_threshold);
@@ -171,6 +173,29 @@ WLCRinit(Client cntxt)
return msg;
}
+str
+WLCRstop (Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+ FILE *fd;
+ str dir = GDKfilepath(0,0,"master",0);
+ char path[PATHLENGTH];
+ (void) cntxt;
+ (void) mb;
+ (void) stk;
+ (void) pci;
+
+ if( wlcr_dir == NULL)
+ throw(MAL,"wlcr.stop","Replica control not active");
+
+ snprintf(path, PATHLENGTH,"%s%cwlcr",dir, DIR_SEP);
+ fd = fopen(path,"w");
+ if( fd == NULL)
+ throw(MAL,"wlcr.stop","File can not be access");
+ fprintf(fd,"%d %d\n", - wlcr_batch, wlcr_threshold);
+ (void) fflush(fd);
+ return MAL_SUCCEED;
+}
+
str
WLCRinitCmd(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
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
@@ -27,6 +27,7 @@ mal_export str wlcr_dir;
mal_export str WLCRinit(Client cntxt);
mal_export str WLCRinitCmd(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
mal_export str WLCRmaster(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
+mal_export str WLCRstop(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
mal_export str WLCRjob(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
mal_export str WLCRexec(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
mal_export str WLCRquery(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
@@ -14,6 +14,10 @@ pattern master()
address WLCRmaster
comment "Activate the workload-capture-replay";
+pattern stop()
+address WLCRstop
+comment "Terminate keeping a log on this branch":
+
pattern master(threshold:int)
address WLCRmaster
comment "Activate the workload-capture-replay. Only queries surpassing the
threshold are kept for replay.";
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
@@ -96,6 +96,9 @@ CLONEinit(Client cntxt, MalBlkPtr mb, Ma
if( fscanf(fd,"%d %d", &j,&k) != 2){
throw(SQL,"wlcr.init","'%s' does not have proper number of
arguments\n",path);
}
+ if ( j < 0)
+ // log capturing stopped at j steps
+ j = -j;
wlcr_replaybatches = j;
if ( i < pci->argc && getArgType(mb, pci, i) == TYPE_int){
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
@@ -12,6 +12,9 @@ external name wlcr.master;
create procedure master(threshold integer)
external name wlcr.master;
+create procedure stopmaster()
+external name wlcr.stop;
+
declare replaylog string;
set replaylog = '/tmp/wlcr';
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list