Changeset: 65613f9d19bd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=65613f9d19bd
Modified Files:
        gdk/gdk_bbp.c
Branch: Apr2019
Log Message:

On startup check whether all BAT files exist and are large enough.


diffs (74 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -823,6 +823,60 @@ BBPreadEntries(FILE *fp, unsigned bbpver
        }
 }
 
+/* check that the necessary files for all BATs exist and are large
+ * enough */
+static gdk_return
+BBPcheckbats(void)
+{
+       for (bat bid = 1; bid < (bat) ATOMIC_GET(BBPsize, BBPsizeLock); bid++) {
+               struct stat statb;
+               BAT *b;
+               char *path;
+
+               if ((b = BBP_desc(bid)) == NULL) {
+                       /* not a valid BAT */
+                       continue;
+               }
+               if (b->ttype == TYPE_void) {
+                       /* no files needed */
+                       continue;
+               }
+               path = GDKfilepath(0, BATDIR, BBP_physical(b->batCacheid), 
"tail");
+               if (path == NULL)
+                       return GDK_FAIL;
+               if (stat(path, &statb) < 0) {
+                       GDKsyserror("BBPcheckbats: cannot stat file %s\n",
+                                   path);
+                       GDKfree(path);
+                       return GDK_FAIL;
+               }
+               if ((size_t) statb.st_size < b->theap.free) {
+                       GDKerror("BBPcheckbats: file %s too small (expected 
%zu, actual %zu)\n", path, b->theap.free, (size_t) statb.st_size);
+                       GDKfree(path);
+                       return GDK_FAIL
+               }
+               GDKfree(path);
+               if (b->tvheap != NULL) {
+                       path = GDKfilepath(0, BATDIR, 
BBP_physical(b->batCacheid), "theap");
+                       if (path == NULL)
+                               return GDK_FAIL;
+                       if (stat(path, &statb) < 0) {
+                               GDKsyserror("BBPcheckbats: cannot stat file 
%s\n",
+                                           path);
+                               GDKfree(path);
+                               return GDK_FAIL;
+                       }
+                       if ((size_t) statb.st_size < b->tvheap->free) {
+                               GDKerror("BBPcheckbats: file %s too small 
(expected %zu, actual %zu)\n", path, b->tvheap->free, (size_t) statb.st_size);
+                               GDKfree(path);
+                               return GDK_FAIL;
+                       }
+                       GDKfree(path);
+               }
+       }
+       return GDK_SUCCEED;
+}
+
 #ifdef HAVE_HGE
 #define SIZEOF_MAX_INT SIZEOF_HGE
 #else
@@ -1042,6 +1096,9 @@ BBPinit(void)
        if (BBPprepare(false) != GDK_SUCCEED)
                GDKfatal("BBPinit: cannot properly prepare process %s. Please 
check whether your disk is full or write-protected", BAKDIR);
 
+       if (BBPcheckbats() != GDK_SUCCEED)
+               GDKfatal("BBPinit: BBPcheckbats failed");
+
        /* cleanup any leftovers (must be done after BBPrecover) */
        for (i = 0; i < MAXFARMS && BBPfarms[i].dirname != NULL; i++) {
                int j;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to