Changeset: 837c9782cb4b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=837c9782cb4b
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk.h
gdk/gdk_bbp.c
gdk/gdk_bbp.h
gdk/gdk_logger.c
gdk/gdk_tm.c
monetdb5/mal/mal_authorize.c
monetdb5/modules/mal/querylog.c
monetdb5/modules/mal/transaction.c
Branch: unlock
Log Message:
Extended TMsubcommit_list (and BBPsync) with an extra "int info" argument.
This value is saved in the BBP.dir file. The last successfully
committed value can be retrieved with the new function getBBPinfo().
diffs (truncated from 341 to 300 lines):
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
@@ -208,7 +208,7 @@ int BBPrename(bat bid, const char *nme);
int BBPretain(bat b);
gdk_return BBPsave(BAT *b);
void BBPshare(bat b);
-gdk_return BBPsync(int cnt, bat *restrict subcommit, BUN *restrict sizes);
+gdk_return BBPsync(int cnt, bat *restrict subcommit, BUN *restrict sizes, int
info);
int BBPunfix(bat b);
void BBPunlock(void);
gdk_return BUNappend(BAT *b, const void *right, bool force)
__attribute__((__warn_unused_result__));
@@ -375,7 +375,7 @@ void THRsetdata(int, void *);
void TMabort(void);
gdk_return TMcommit(void);
gdk_return TMsubcommit(BAT *bl);
-gdk_return TMsubcommit_list(bat *restrict subcommit, BUN *restrict sizes, int
cnt);
+gdk_return TMsubcommit_list(bat *restrict subcommit, BUN *restrict sizes, int
cnt, int info);
void VALclear(ValPtr v);
int VALcmp(const ValRecord *p, const ValRecord *q);
void *VALconvert(int typ, ValPtr t);
@@ -487,6 +487,7 @@ geomsqlfix_fptr geomsqlfix_get(void);
void geomsqlfix_set(geomsqlfix_fptr);
bool geomversion_get(void);
void geomversion_set(void);
+int getBBPinfo(void);
bat getBBPsize(void);
char *get_bin_path(void);
int gettimeofday(struct timeval *tv, int *ignore_zone);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -713,7 +713,8 @@ typedef struct {
#define GDKLIBRARY_BLOB_SORT 061040U /* blob compare changed */
#define GDKLIBRARY_OLDDATE 061041U /* the representation of times changed
*/
-#define GDKLIBRARY 061042U
+#define GDKLIBRARY_NOINFO 061042U /* no extra info in header */
+#define GDKLIBRARY 061043U
typedef struct BAT {
/* static bat properties */
@@ -1832,7 +1833,7 @@ Tpos(BATiter *bi, BUN p)
gdk_export gdk_return TMcommit(void);
gdk_export void TMabort(void);
gdk_export gdk_return TMsubcommit(BAT *bl);
-gdk_export gdk_return TMsubcommit_list(bat *restrict subcommit, BUN *restrict
sizes, int cnt);
+gdk_export gdk_return TMsubcommit_list(bat *restrict subcommit, BUN *restrict
sizes, int cnt, int info);
/*
* @- Delta Management
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -114,7 +114,9 @@ static void BBPuncacheit(bat bid, bool u
static gdk_return BBPprepare(bool subcommit);
static BAT *getBBPdescriptor(bat i, bool lock);
static gdk_return BBPbackup(BAT *b, bool subcommit);
-static gdk_return BBPdir(int cnt, bat *restrict subcommit, BUN *restrict
sizes);
+static gdk_return BBPdir(int cnt, bat *restrict subcommit, BUN *restrict
sizes, int info);
+
+static int BBPinfo; /* one integer of extra info in BBP.dir */
#ifdef HAVE_HGE
/* start out by saying we have no hge, but as soon as we've seen one,
@@ -154,6 +156,12 @@ getBBPsize(void)
return (bat) ATOMIC_GET(&BBPsize);
}
+int
+getBBPinfo(void)
+{
+ return BBPinfo;
+}
+
/*
* @+ BBP Consistency and Concurrency
@@ -1053,6 +1061,7 @@ BBPheader(FILE *fp)
return 0;
}
if (bbpversion != GDKLIBRARY &&
+ bbpversion != GDKLIBRARY_NOINFO &&
bbpversion != GDKLIBRARY_OLDDATE &&
bbpversion != GDKLIBRARY_BLOB_SORT) {
TRC_CRITICAL(GDK, "incompatible BBP version: expected 0%o, got
0%o.\n"
@@ -1092,7 +1101,16 @@ BBPheader(FILE *fp)
sz = (int) (sz * BATMARGIN);
if (sz > (bat) ATOMIC_GET(&BBPsize))
ATOMIC_SET(&BBPsize, sz);
- assert(bbpversion != 0);
+ if (bbpversion > GDKLIBRARY_NOINFO) {
+ if (fgets(buf, sizeof(buf), fp) == NULL) {
+ TRC_CRITICAL(GDK, "short BBP");
+ return 0;
+ }
+ if (sscanf(buf, "BBPinfo=%d", &BBPinfo) != 1) {
+ TRC_CRITICAL(GDK, "no info value found\n");
+ return 0;
+ }
+ }
return bbpversion;
}
@@ -1257,7 +1275,7 @@ BBPinit(void)
/* no BBP.bak (nor BBP.dir or BACKUP/BBP.dir):
* create a new one */
TRC_DEBUG(IO_, "initializing BBP.\n"); /*
BBPdir instead of BBPinit for backward compatibility of error messages */
- if (BBPdir(0, NULL, NULL) != GDK_SUCCEED) {
+ if (BBPdir(0, NULL, NULL, 0) != GDK_SUCCEED) {
GDKfree(bbpdirstr);
GDKfree(backupbbpdirstr);
goto bailout;
@@ -1503,14 +1521,14 @@ new_bbpentry(FILE *fp, bat i, BUN size)
}
static gdk_return
-BBPdir_header(FILE *f, int n)
+BBPdir_header(FILE *f, int n, int info)
{
- if (fprintf(f, "BBP.dir, GDKversion %u\n%d %d %d\nBBPsize=%d\n",
+ if (fprintf(f, "BBP.dir, GDKversion %u\n%d %d
%d\nBBPsize=%d\nBBPinfo=%d\n",
GDKLIBRARY, SIZEOF_SIZE_T, SIZEOF_OID,
#ifdef HAVE_HGE
havehge ? SIZEOF_HGE :
#endif
- SIZEOF_LNG, n) < 0 ||
+ SIZEOF_LNG, n, info) < 0 ||
ferror(f)) {
GDKsyserror("BBPdir_header: Writing BBP.dir header failed\n");
return GDK_FAIL;
@@ -1519,7 +1537,7 @@ BBPdir_header(FILE *f, int n)
}
static gdk_return
-BBPdir_subcommit(int cnt, bat *restrict subcommit, BUN *restrict sizes)
+BBPdir_subcommit(int cnt, bat *restrict subcommit, BUN *restrict sizes, int
info)
{
FILE *obbpf, *nbbpf;
bat j = 1;
@@ -1556,10 +1574,16 @@ BBPdir_subcommit(int cnt, bat *restrict
}
if (n < (bat) ATOMIC_GET(&BBPsize))
n = (bat) ATOMIC_GET(&BBPsize);
+ /* fourth line contains BBPinfo */
+ if (fgets(buf, sizeof(buf), obbpf) == NULL ||
+ sscanf(buf, "BBPinfo=%d", &n) != 1) {
+ GDKerror("BBPdir: cannot read BBPinfo in backup BBP.dir.");
+ goto bailout;
+ }
TRC_DEBUG(IO_, "writing BBP.dir (%d bats).\n", n);
- if (BBPdir_header(nbbpf, n) != GDK_SUCCEED) {
+ if (BBPdir_header(nbbpf, n, info) != GDK_SUCCEED) {
goto bailout;
}
n = 0;
@@ -1635,20 +1659,20 @@ BBPdir_subcommit(int cnt, bat *restrict
}
gdk_return
-BBPdir(int cnt, bat *restrict subcommit, BUN *restrict sizes)
+BBPdir(int cnt, bat *restrict subcommit, BUN *restrict sizes, int info)
{
FILE *fp;
bat i;
if (subcommit)
- return BBPdir_subcommit(cnt, subcommit, sizes);
+ return BBPdir_subcommit(cnt, subcommit, sizes, info);
TRC_DEBUG(IO_, "writing BBP.dir (%d bats).\n", (int) (bat)
ATOMIC_GET(&BBPsize));
if ((fp = GDKfilelocate(0, "BBP", "w", "dir")) == NULL) {
goto bailout;
}
- if (BBPdir_header(fp, (bat) ATOMIC_GET(&BBPsize)) != GDK_SUCCEED) {
+ if (BBPdir_header(fp, (bat) ATOMIC_GET(&BBPsize), info) != GDK_SUCCEED)
{
goto bailout;
}
@@ -3118,7 +3142,7 @@ fail:
* The BBP.dir is also moved into the BAKDIR.
*/
gdk_return
-BBPsync(int cnt, bat *restrict subcommit, BUN *restrict sizes)
+BBPsync(int cnt, bat *restrict subcommit, BUN *restrict sizes, int info)
{
gdk_return ret = GDK_SUCCEED;
int t0 = 0, t1 = 0;
@@ -3196,7 +3220,7 @@ BBPsync(int cnt, bat *restrict subcommit
TRC_DEBUG(PERF, "write time %d\n", (t0 = GDKms()) - t1);
if (ret == GDK_SUCCEED) {
- ret = BBPdir(cnt, subcommit, sizes);
+ ret = BBPdir(cnt, subcommit, sizes, info);
}
TRC_DEBUG(PERF, "dir time %d, %d bats\n", (t1 = GDKms()) - t0, (bat)
ATOMIC_GET(&BBPsize));
@@ -3221,6 +3245,7 @@ BBPsync(int cnt, bat *restrict subcommit
/* AFTERMATH */
if (ret == GDK_SUCCEED) {
+ BBPinfo = info; /* the new value */
backup_files = subcommit ? (backup_files - backup_subdir) : 0;
backup_dir = backup_subdir = 0;
if (GDKremovedir(0, DELDIR) != GDK_SUCCEED)
diff --git a/gdk/gdk_bbp.h b/gdk/gdk_bbp.h
--- a/gdk/gdk_bbp.h
+++ b/gdk/gdk_bbp.h
@@ -54,6 +54,7 @@
#define BBPTRIM_ALL (((size_t)1) << (sizeof(size_t)*8 - 2)) /* very large
positive size_t */
gdk_export bat getBBPsize(void); /* current occupied size of BBP array */
+gdk_export int getBBPinfo(void); /* one integer of extra info in BBP.dir */
/* global calls */
gdk_export gdk_return BBPaddfarm(const char *dirname, int rolemask);
@@ -69,7 +70,7 @@ gdk_export bat BBPindex(const char *nme)
gdk_export BAT *BBPdescriptor(bat b);
/* swapping interface */
-gdk_export gdk_return BBPsync(int cnt, bat *restrict subcommit, BUN *restrict
sizes);
+gdk_export gdk_return BBPsync(int cnt, bat *restrict subcommit, BUN *restrict
sizes, int info);
gdk_export int BBPfix(bat b);
gdk_export int BBPunfix(bat b);
gdk_export int BBPretain(bat b);
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1667,7 +1667,7 @@ bm_subcommit(logger *lg, BAT *list_bid,
BATcommit(catalog_oid, BUN_NONE);
}
BATcommit(dcatalog, BUN_NONE);
- res = TMsubcommit_list(n, NULL, i);
+ res = TMsubcommit_list(n, NULL, i, getBBPinfo());
GDKfree(n);
if (res != GDK_SUCCEED)
fprintf(stderr, "!ERROR: bm_subcommit: commit failed\n");
diff --git a/gdk/gdk_tm.c b/gdk/gdk_tm.c
--- a/gdk/gdk_tm.c
+++ b/gdk/gdk_tm.c
@@ -139,7 +139,7 @@ TMcommit(void)
/* commit with the BBP globally locked */
BBPlock();
if (prelude(getBBPsize(), NULL, NULL) == GDK_SUCCEED &&
- BBPsync(getBBPsize(), NULL, NULL) == GDK_SUCCEED) {
+ BBPsync(getBBPsize(), NULL, NULL, getBBPinfo()) == GDK_SUCCEED) {
epilogue(getBBPsize(), NULL);
ret = GDK_SUCCEED;
}
@@ -174,7 +174,7 @@ TMcommit(void)
* a real global TMcommit.
*/
gdk_return
-TMsubcommit_list(bat *restrict subcommit, BUN *restrict sizes, int cnt)
+TMsubcommit_list(bat *restrict subcommit, BUN *restrict sizes, int cnt, int
info)
{
int xx;
gdk_return ret = GDK_FAIL;
@@ -209,7 +209,7 @@ TMsubcommit_list(bat *restrict subcommit
* (sub-)commits */
for (xx = 0; xx <= BBP_THREADMASK; xx++)
MT_lock_set(&GDKtrimLock(xx));
- if (BBPsync(cnt, subcommit, sizes) == GDK_SUCCEED) { /* write
BBP.dir (++) */
+ if (BBPsync(cnt, subcommit, sizes, info) == GDK_SUCCEED) { /*
write BBP.dir (++) */
epilogue(cnt, subcommit);
ret = GDK_SUCCEED;
}
@@ -242,7 +242,7 @@ TMsubcommit(BAT *b)
subcommit[cnt++] = bid;
}
- ret = TMsubcommit_list(subcommit, NULL, cnt);
+ ret = TMsubcommit_list(subcommit, NULL, cnt, getBBPinfo());
GDKfree(subcommit);
return ret;
}
diff --git a/monetdb5/mal/mal_authorize.c b/monetdb5/mal/mal_authorize.c
--- a/monetdb5/mal/mal_authorize.c
+++ b/monetdb5/mal/mal_authorize.c
@@ -158,7 +158,7 @@ AUTHcommit(void)
blist[7] = rt_hashedpwd->batCacheid;
assert(rt_deleted);
blist[8] = rt_deleted->batCacheid;
- TMsubcommit_list(blist, NULL, 9);
+ TMsubcommit_list(blist, NULL, 9, getBBPinfo());
}
/*
diff --git a/monetdb5/modules/mal/querylog.c b/monetdb5/modules/mal/querylog.c
--- a/monetdb5/modules/mal/querylog.c
+++ b/monetdb5/modules/mal/querylog.c
@@ -239,7 +239,7 @@ static str
}
QLOG_init = true;
- TMsubcommit_list(commitlist, NULL, committop);
+ TMsubcommit_list(commitlist, NULL, committop, getBBPinfo());
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list