Changeset: ee3e6562e1ea for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ee3e6562e1ea
Modified Files:
monetdb5/modules/mal/wlc.c
sql/backends/monet5/wlr.c
Branch: default
Log Message:
Several fixes at wlcr
diffs (truncated from 356 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
@@ -390,7 +390,7 @@ WLClogger(void *arg)
str
WLCinit(void)
{
- str conf;
+ str conf, msg;
int len;
if( wlc_state == WLC_STARTUP){
@@ -398,7 +398,7 @@ WLCinit(void)
if((conf = GDKfilepath(0,0,"wlc.config",0)) == NULL)
throw(MAL,"wlc.init","Could not access wlc.config\n");
- if(access(conf, F_OK) ){
+ if (access(conf, F_OK) ){
GDKfree(conf);
return MAL_SUCCEED;
}
@@ -408,7 +408,8 @@ WLCinit(void)
if (len == -1 || len >= IDLENGTH)
throw(MAL, "wlc.init", "gdk_dbname variable is too
large");
- WLCgetConfig();
+ if ((msg = WLCgetConfig()) != MAL_SUCCEED)
+ return msg;
if (MT_create_thread(&wlc_logger, WLClogger , (void*) 0,
MT_THR_DETACHED,
"WLClogger") < 0) {
TRC_ERROR(MAL_WLC, "Thread could not be spawned\n");
@@ -588,8 +589,8 @@ WLCpreparewrite(Client cntxt)
resetMalBlk(cntxt->wlc, 0);
cntxt->wlc_kind = WLC_QUERY;
} else
- throw(MAL,"wlc.write","WLC log path missing ");
-
+ throw(MAL,"wlc.write","WLC log path missing ");
+
if( wlc_state == WLC_STOP)
throw(MAL,"wlc.write","Logging for this snapshot has been
stopped. Use a new snapshot to continue logging.");
return msg;
@@ -611,7 +612,7 @@ WLCstart(Client cntxt, str fcn)
/* Find a single transaction sequence ending with COMMIT or ROLLBACK */
if( mb->stop > 1 ){
pci = getInstrPtr(mb, mb->stop -1 );
- if ( ! (strcmp( getFunctionId(pci), "commit") == 0 || strcmp(
getFunctionId(pci), "rollback") == 0))
+ if (!(strcmp( getFunctionId(pci), "commit") == 0 || strcmp(
getFunctionId(pci), "rollback") == 0))
return MAL_SUCCEED;
}
@@ -668,7 +669,7 @@ WLCcatalog(Client cntxt, MalBlkPtr mb, M
str msg = MAL_SUCCEED;
(void) stk;
- msg = WLCstart(cntxt, "wlr.catalog");
+ msg = WLCstart(cntxt, "wlr.catalog");
if(msg)
return msg;
cntxt->wlc_kind = WLC_CATALOG;
@@ -1026,7 +1027,6 @@ WLCclear_table(Client cntxt, MalBlkPtr m
return msg;
}
-
str
WLCcommit(int clientid)
{
@@ -1059,6 +1059,7 @@ WLCrollback(int clientid)
}
return MAL_SUCCEED;
}
+
str
WLCrollbackCmd(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{ str msg = MAL_SUCCEED;
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
@@ -113,8 +113,6 @@ WLRgetConfig(void){
if ( s) *s = 0;
}
}
- fclose(fd);
- return msg;
bailout:
fclose(fd);
return msg;
@@ -165,7 +163,7 @@ WLRgetMaster(void)
{
char path[FILENAME_MAX];
int len;
- str dir;
+ str dir, msg;
FILE *fd;
if( wlr_master[0] == 0 )
@@ -182,7 +180,8 @@ WLRgetMaster(void)
GDKfree(dir);
if( fd == NULL )
throw(MAL,"wlr.getMaster","Could not get read access to
'%s'config file\n", wlr_master);
- WLCreadConfig(fd);
+ if((msg = WLCreadConfig(fd)))
+ return msg;
if( !wlr_master[0] )
throw(MAL,"wlr.getMaster","Master not identified\n");
wlc_state = WLC_CLONE; // not used as master
@@ -221,12 +220,15 @@ WLRprocessBatch(Client cntxt)
if( msg != MAL_SUCCEED){
snprintf(wlr_error, BUFSIZ, "%s", msg);
freeException(msg);
+ return MAL_SUCCEED;
+ }
+ if( wlr_error[0]) {
+ if (!(msg = GDKstrdup(wlr_error)))
+ throw(MAL, "wlr.batch", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
return msg;
}
- if( wlr_error[0])
- return GDKstrdup(wlr_error);
- c =MCforkClient(cntxt);
+ c = MCforkClient(cntxt);
if( c == 0)
throw(MAL, "wlr.batch", "Could not create user for WLR
process\n");
c->promptlength = 0;
@@ -248,33 +250,50 @@ WLRprocessBatch(Client cntxt)
setVarType(mb, 0, TYPE_void);
msg = SQLinitClient(c);
- if( msg != MAL_SUCCEED)
+ if( msg != MAL_SUCCEED) {
+ MCcloseClient(c);
+ freeSymbol(prev);
return msg;
- msg = getSQLContext(c, mb, &sql, NULL);
- if( msg)
+ }
+ if ((msg = getSQLContext(c, mb, &sql, NULL))) {
+ SQLexitClient(c);
+ MCcloseClient(c);
+ freeSymbol(prev);
return msg;
- if ((msg = checkSQLContext(c)) != NULL)
+ }
+ if ((msg = checkSQLContext(c)) != NULL) {
+ SQLexitClient(c);
+ MCcloseClient(c);
+ freeSymbol(prev);
return msg;
+ }
path[0]=0;
for( i= wlr_batches; i < wlc_batches && !GDKexiting() && wlr_state !=
WLR_STOP && wlr_tag <= wlr_limit && msg == MAL_SUCCEED; i++){
len = snprintf(path,FILENAME_MAX,"%s%c%s_%012d", wlc_dir,
DIR_SEP, wlr_master, i);
- if (len == -1 || len >= FILENAME_MAX)
- throw(MAL, "wlr.batch", "Filename path is too large\n");
+ if (len == -1 || len >= FILENAME_MAX) {
+ msg = createException(MAL, "wlr.batch", "Filename path
is too large\n");
+ break;
+ }
fd= open_rastream(path);
- if( fd == NULL)
- throw(MAL, "wlr.batch", "Cannot access path '%s'\n",
path);
+ if( fd == NULL) {
+ msg = createException(MAL, "wlr.batch", "Cannot access
path '%s'\n", path);
+ break;
+ }
sz = getFileSize(fd);
if (sz > (size_t) 1 << 29) {
close_stream(fd);
- throw(MAL, "wlr.batch", "File %s is too large to
process\n", path);
+ msg = createException(MAL, "wlr.batch", "File %s is too
large to process\n", path);
+ break;
}
- if((c->fdin = bstream_create(fd, sz == 0 ? (size_t) (2 * 128 *
BLOCK) : sz)) == NULL) {
+ if ((c->fdin = bstream_create(fd, sz == 0 ? (size_t) (2 * 128 *
BLOCK) : sz)) == NULL) {
close_stream(fd);
- throw(MAL, "wlr.batch", "Failed to open stream for file
%s\n", path);
+ msg = createException(MAL, "wlr.batch", "Failed to open
stream for file %s\n", path);
+ break;
}
if (bstream_next(c->fdin) < 0){
- throw(MAL, "wlr.batch", "Could not read %s\n", path);
+ msg = createException(MAL, "wlr.batch", "Could not read
%s\n", path);
+ break;
}
c->yycur = 0;
@@ -399,8 +418,14 @@ WLRprocessBatch(Client cntxt)
close_stream(c->fdout);
SQLexitClient(c);
MCcloseClient(c);
- if(prev)
+ if (prev)
freeSymbol(prev);
+ if (msg2) { /* throw msg2, if msg is not set */
+ if (!msg)
+ msg = msg2;
+ else
+ freeException(msg2);
+ }
return msg;
}
@@ -431,12 +456,15 @@ WLRprocessScheduler(void *arg)
}
assert(wlr_master[0]);
- cntxt = MCinitClient(MAL_ADMIN, NULL,NULL);
+ if (!(cntxt = MCinitClient(MAL_ADMIN, NULL,NULL))) {
+ snprintf(wlr_error, BUFSIZ, "Failed to init WLR scheduler
client");
+ return;
+ }
- MT_lock_set(&wlr_lock);
+ MT_lock_set(&wlr_lock);
if ( wlr_state != WLR_STOP)
wlr_state = WLR_RUN;
- MT_lock_unset(&wlr_lock);
+ MT_lock_unset(&wlr_lock);
while( wlr_state != WLR_STOP && !wlr_error[0]){
// wait at most for the cycle period, also at start
@@ -465,8 +493,9 @@ WLRprocessScheduler(void *arg)
}
}
MT_thread_setworking("processing wlr");
- (void) WLRprocessBatch(cntxt);
-
+ if ((msg = WLRprocessBatch(cntxt)))
+ freeException(msg);
+
/* Can not use GDKexiting(), because a test may already reach
that point before it did anything.
* Instead wait for the explicit WLR_STOP
*/
@@ -478,10 +507,10 @@ WLRprocessScheduler(void *arg)
}
}
wlr_thread = 0;
- MT_lock_set(&wlr_lock);
+ MT_lock_set(&wlr_lock);
if( wlr_state == WLR_RUN)
wlr_state = WLR_WAIT;
- MT_lock_unset(&wlr_lock);
+ MT_lock_unset(&wlr_lock);
MCcloseClient(cntxt);
}
@@ -499,11 +528,12 @@ WLRmaster(Client cntxt, MalBlkPtr mb, Ma
len = snprintf(wlr_master, IDLENGTH, "%s", *getArgReference_str(stk,
pci, 1));
if (len == -1 || len >= IDLENGTH)
throw(MAL, "wlr.master", SQLSTATE(42000) "Input value is too
large for wlr_master buffer");
- WLRgetMaster();
- msg = WLRgetConfig();
- if( msg ){
- WLRputConfig();
+ if ((msg = WLRgetMaster()))
freeException(msg);
+ if ((msg = WLRgetConfig())) {
+ freeException(msg);
+ if ((msg = WLRputConfig()))
+ freeException(msg);
}
return MAL_SUCCEED;
}
@@ -521,8 +551,11 @@ WLRreplicate(Client cntxt, MalBlkPtr mb,
msg = WLRgetConfig();
if( msg != MAL_SUCCEED)
return msg;
- if( wlr_error[0])
- return GDKstrdup(wlr_error);
+ if( wlr_error[0]) {
+ if (!(msg = GDKstrdup(wlr_error)))
+ throw(MAL, "sql.replicate", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ return msg;
+ }
if( pci->argc == 0)
wlr_limit = INT64_MAX;
@@ -548,19 +581,19 @@ WLRreplicate(Client cntxt, MalBlkPtr mb,
if ( limit < 0 && timelimit[0] == 0)
throw(MAL, "sql.replicate", "Stop tag limit should be positive
or timestamp should be set");
if( wlc_tag == 0) {
- WLRgetMaster();
+ if ((msg = WLRgetMaster()))
+ freeException(msg);
if( wlc_tag == 0)
throw(MAL, "sql.replicate", "Perhaps a missing
wlr.master() call. ");
}
if (limit < INT64_MAX && limit >= wlc_tag)
throw(MAL, "sql.replicate", "Stop tag limit "LLFMT" be less
than wlc_tag "LLFMT, limit, wlc_tag);
- if ( limit >= 0)
+ if (limit >= 0)
wlr_limit = limit;
- if ( wlc_state != WLC_CLONE)
+ if (wlc_state != WLC_CLONE)
throw(MAL, "sql.replicate", "No replication master set");
- msg = WLRputConfig();
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list