Changeset: 295decc7031e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=295decc7031e
Modified Files:
gdk/gdk_search.c
Branch: default
Log Message:
Make sure hash heap is available until after it was written to disk.
diffs (57 lines):
diff --git a/gdk/gdk_search.c b/gdk/gdk_search.c
--- a/gdk/gdk_search.c
+++ b/gdk/gdk_search.c
@@ -317,17 +317,25 @@ BATcheckhash(BAT *b)
}
#ifdef PERSISTENTHASH
+struct hashsync {
+ Heap *hp;
+ bat id;
+};
+
static void
BAThashsync(void *arg)
{
- Heap *hp = arg;
+ struct hashsync *hs = arg;
+ Heap *hp = hs->hp;
int fd;
lng t0 = GDKusec();
- if (HEAPsave(hp, hp->filename, NULL) != GDK_SUCCEED)
+ if (HEAPsave(hp, hp->filename, NULL) != GDK_SUCCEED ||
+ (fd = GDKfdlocate(hp->farmid, hp->filename, "rb+", NULL)) < 0) {
+ BBPunfix(hs->id);
+ GDKfree(arg);
return;
- if ((fd = GDKfdlocate(hp->farmid, hp->filename, "rb+", NULL)) < 0)
- return;
+ }
((size_t *) hp->base)[0] |= 1 << 24;
if (write(fd, hp->base, SIZEOF_SIZE_T) < 0)
perror("write hash");
@@ -341,6 +349,8 @@ BAThashsync(void *arg)
#endif
}
close(fd);
+ BBPunfix(hs->id);
+ GDKfree(arg);
ALGODEBUG fprintf(stderr, "#BAThash: persisting hash %s (" LLFMT "
usec)\n", hp->filename, GDKusec() - t0);
}
#endif
@@ -544,7 +554,13 @@ BAThash(BAT *b, BUN masksize)
#ifdef PERSISTENTHASH
if (BBP_status(b->batCacheid) & BBPEXISTING) {
MT_Id tid;
- MT_create_thread(&tid, BAThashsync, hp,
MT_THR_DETACHED);
+ struct hashsync *hs = GDKmalloc(sizeof(*hs));
+ if (hs != NULL) {
+ BBPfix(b->batCacheid);
+ hs->id = b->batCacheid;
+ hs->hp = hp;
+ MT_create_thread(&tid, BAThashsync, hs,
MT_THR_DETACHED);
+ }
} else
ALGODEBUG fprintf(stderr, "#BAThash: NOT persisting
hash %d\n", b->batCacheid);
#endif
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list