Changeset: fc4f988783ed for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fc4f988783ed
Modified Files:
monetdb5/modules/mal/wlc.c
sql/backends/monet5/sql_scenario.c
sql/backends/monet5/wlr.c
Branch: default
Log Message:
More checks and indentation fixes in wlc
diffs (truncated from 443 to 300 lines):
diff --git a/monetdb5/modules/mal/wlc.c b/monetdb5/modules/mal/wlc.c
--- a/monetdb5/modules/mal/wlc.c
+++ b/monetdb5/modules/mal/wlc.c
@@ -210,7 +210,7 @@ WLCgetConfig(void){
fd = fopen(l,"r");
GDKfree(l);
if( fd == NULL)
- throw(MAL,"wlc.getConfig","Could not access %s\n",l);
+ throw(MAL,"wlc.getConfig","Could not access wlc.config file\n");
WLCreadConfig(fd);
return MAL_SUCCEED;
}
diff --git a/sql/backends/monet5/sql_scenario.c
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -429,7 +429,10 @@ SQLinitClient(Client c)
if (SQLinitialized == 0 && (msg = SQLprelude(NULL)) != MAL_SUCCEED)
return msg;
MT_lock_set(&sql_contextLock);
- WLRinit();
+ if ((msg = WLRinit()) != MAL_SUCCEED) {
+ MT_lock_unset(&sql_contextLock);
+ return msg;
+ }
/*
* Based on the initialization return value we can prepare a SQLinit
* string with all information needed to initialize the catalog
diff --git a/sql/backends/monet5/wlr.c b/sql/backends/monet5/wlr.c
--- a/sql/backends/monet5/wlr.c
+++ b/sql/backends/monet5/wlr.c
@@ -51,7 +51,7 @@ static MT_Id wlr_thread;
#define MAXLINE 2048
-static void
+static str
WLRgetConfig(void){
char *path;
char line[MAXLINE];
@@ -61,7 +61,7 @@ WLRgetConfig(void){
fd = fopen(path,"r");
GDKfree(path);
if( fd == NULL)
- return ;
+ return MAL_SUCCEED;
while( fgets(line, MAXLINE, fd) ){
line[strlen(line)-1]= 0;
if( strncmp("master=", line,7) == 0)
@@ -80,9 +80,10 @@ WLRgetConfig(void){
strncpy(wlr_error, line+ 6, FILENAME_MAX);
}
fclose(fd);
+ return MAL_SUCCEED;
}
-static void
+static str
WLRsetConfig(void){
char *path;
stream *fd;
@@ -91,7 +92,7 @@ WLRsetConfig(void){
fd = open_wastream(path);
GDKfree(path);
if( fd == NULL){
- return;
+ return MAL_SUCCEED;
}
mnstr_printf(fd,"master=%s\n", wlr_master);
mnstr_printf(fd,"batches=%d\n", wlr_batches);
@@ -103,6 +104,7 @@ WLRsetConfig(void){
if( wlr_error[0])
mnstr_printf(fd,"error=%s\n", wlr_error);
close_stream(fd);
+ return MAL_SUCCEED;
}
/*
@@ -115,7 +117,7 @@ WLRsetConfig(void){
* process by grabbing a new set of log files.
* This calls for keeping track in the replica what log files have been
applied.
*/
-static void
+static str
WLRgetMaster(void)
{
char path[FILENAME_MAX];
@@ -123,18 +125,20 @@ WLRgetMaster(void)
FILE *fd;
if( wlr_master[0] == 0 )
- return ;
+ return MAL_SUCCEED;
/* collect master properties */
snprintf(path,FILENAME_MAX,"..%c%s",DIR_SEP,wlr_master);
dir = GDKfilepath(0,path,"wlc.config",0);
fd = fopen(dir,"r");
+ GDKfree(dir);
if( fd ){
WLCreadConfig(fd);
wlc_state = WLC_CLONE; // not used as master
- }
- GDKfree(dir);
+ } else
+ throw(MAL,"wlr.getMaster","Could not access wlc.config file\n");
+ return MAL_SUCCEED;
}
/*
@@ -187,7 +191,7 @@ WLRprocess(void *arg)
if( msg)
mnstr_printf(GDKerr,"#Failed to access the transaction context:
%s\n",msg);
if ((msg = checkSQLContext(c)) != NULL)
- mnstr_printf(GDKerr,"#Inconsitent SQL contex : %s\n",msg);
+ mnstr_printf(GDKerr,"#Inconsitent SQL context: %s\n",msg);
#ifdef _WLR_DEBUG_
mnstr_printf(c->fdout,"#Ready to start the replay against '%s' batches
%d:%d\n",
@@ -272,7 +276,8 @@ WLRprocess(void *arg)
//printFunction(GDKerr, mb, 0,
LIST_MAL_DEBUG );
msg= runMAL(c,mb,0,0);
wlr_tag++;
- WLRsetConfig( );
+ if( msg == MAL_SUCCEED)
+ msg = WLRsetConfig( );
// ignore warnings
if (msg &&
strstr(msg,"WARNING"))
msg = MAL_SUCCEED;
@@ -288,7 +293,7 @@ WLRprocess(void *arg)
pc = 0;
} else
if( mvc_commit(sql, 0, 0) < 0)
-
mnstr_printf(GDKerr,"#wlr.process transaction commit failed");
+
mnstr_printf(GDKerr,"#wlr.process transaction commit failed\n");
}
} else {
char line[FILENAME_MAX];
@@ -314,7 +319,10 @@ WLRprocess(void *arg)
#endif
// skip to next file when all is read
wlr_batches++;
- WLRsetConfig();
+ if((msg = WLRsetConfig()) != MAL_SUCCEED) {
+ mnstr_printf(GDKerr,"%s\n",msg);
+ GDKfree(msg);
+ }
// stop when we are about to read beyond the limited
transaction (timestamp)
if( (wlr_limit != -1 || (wlr_timelimit[0] && wlr_read[0] &&
strncmp(wlr_read,wlr_timelimit,26)>= 0) ) && wlr_limit <= wlr_tag) {
bstream_destroy(c->fdin);
@@ -346,8 +354,12 @@ WLRprocessScheduler(void *arg)
time_t clk;
struct tm ctm;
char clktxt[26];
+ str msg;
- WLRgetConfig();
+ if((msg = WLRgetConfig()) != MAL_SUCCEED) {
+ mnstr_printf(GDKerr,"%s\n",msg);
+ GDKfree(msg);
+ }
wlr_state = WLR_RUN;
while(!GDKexiting() && wlr_state == WLR_RUN){
// wait at most for the cycle period, also at start
@@ -368,7 +380,10 @@ WLRprocessScheduler(void *arg)
MT_sleep_ms( 100);
}
if( wlr_master[0] && wlr_state != WLR_PAUSE){
- WLRgetMaster();
+ if((msg = WLRgetMaster()) != MAL_SUCCEED) {
+ mnstr_printf(GDKerr,"%s\n",msg);
+ GDKfree(msg);
+ }
if( wlrprocessrunning == 0 &&
( (wlr_batches == wlc_batches && wlr_tag <
wlr_limit) || wlr_limit > wlr_tag ||
(wlr_limit == -1 && wlr_timelimit[0] == 0 &&
wlr_batches < wlc_batches) ||
@@ -381,9 +396,11 @@ WLRprocessScheduler(void *arg)
str
WLRinit(void)
-{ Client cntxt = &mal_clients[0];
-
- WLRgetConfig();
+{
+ str msg;
+ Client cntxt = &mal_clients[0];
+ if((msg = WLRgetConfig()) != MAL_SUCCEED)
+ return msg;
if( wlr_master[0] == 0)
return MAL_SUCCEED;
if( wlr_state != WLR_START)
@@ -404,7 +421,8 @@ WLRreplicate(Client cntxt, MalBlkPtr mb,
(void) mb;
// first stop the background process
- WLRgetConfig();
+ if((msg = WLRgetConfig()) != MAL_SUCCEED)
+ return msg;
if( wlr_state != WLR_START){
wlr_state = WLR_PAUSE;
while(wlr_state != WLR_START){
@@ -442,14 +460,14 @@ WLRreplicate(Client cntxt, MalBlkPtr mb,
if( getArgType(mb, pci, pci->argc-1) == TYPE_lng)
wlr_limit = getVarConstant(mb,getArg(pci,2)).val.lval;
// stop any concurrent WLRprocess first
- WLRsetConfig();
- WLRgetMaster();
+ if((msg = WLRsetConfig()) != MAL_SUCCEED)
+ return msg;
+ if((msg = WLRgetMaster()) != MAL_SUCCEED)
+ return msg;
// The client has to wait initially for all logs known to be processed.
WLRprocess(cntxt);
if( wlr_limit < 0){
- msg = WLRinit();
- if( msg )
- GDKfree(msg);
+ return WLRinit();
}
return MAL_SUCCEED;
}
@@ -493,28 +511,34 @@ str
WLRgetreplicaclock(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
str *ret = getArgReference_str(stk,pci,0);
+ str msg = MAL_SUCCEED;
(void) cntxt;
(void) mb;
- WLRgetConfig();
+ if((msg = WLRgetConfig()) != MAL_SUCCEED)
+ return msg;
if( wlr_read[0])
*ret= GDKstrdup(wlr_read);
else *ret= GDKstrdup(str_nil);
- return MAL_SUCCEED;
+ if (*ret == NULL)
+ throw(MAL, "wlr.getreplicaclock", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
+ return msg;
}
str
WLRgetreplicatick(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
lng *ret = getArgReference_lng(stk,pci,0);
+ str msg = MAL_SUCCEED;
(void) cntxt;
(void) mb;
- WLRgetConfig();
+ if((msg = WLRgetConfig()) != MAL_SUCCEED)
+ return msg;
*ret = wlr_tag;
- return MAL_SUCCEED;
+ return msg;
}
/* the replica cycle can be set to fixed interval.
@@ -615,25 +639,25 @@ WLRgeneric(Client cntxt, MalBlkPtr mb, M
* (variable msg and tag cleanup will not be defined).
*/
#define WLRcolumn(TPE) \
- for( i = 4; i < pci->argc; i++){ \
- TPE val = *getArgReference_##TPE(stk,pci,i); \
- if (BUNappend(ins, (void*) &val, FALSE) != GDK_SUCCEED) { \
- msg = createException(MAL, "WLRappend", "BUNappend
failed"); \
- goto cleanup; \
- } \
- }
+ for( i = 4; i < pci->argc; i++){ \
+ TPE val = *getArgReference_##TPE(stk,pci,i); \
+ if (BUNappend(ins, (void*) &val, FALSE) != GDK_SUCCEED) { \
+ msg = createException(MAL, "WLRappend", "BUNappend
failed"); \
+ goto cleanup; \
+ } \
+ }
str
WLRappend(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
- str sname, tname, cname;
- int tpe,i;
+ str sname, tname, cname;
+ int tpe,i;
mvc *m=NULL;
sql_schema *s;
sql_table *t;
sql_column *c;
BAT *ins = 0;
- str msg = MAL_SUCCEED;
+ str msg = MAL_SUCCEED;
if( cntxt->wlc_kind == WLC_ROLLBACK || cntxt->wlc_kind == WLC_ERROR)
return msg;
@@ -675,10 +699,10 @@ WLRappend(Client cntxt, MalBlkPtr mb, Ma
case TYPE_str:
for( i = 4; i < pci->argc; i++){
str val = *getArgReference_str(stk,pci,i);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list