changeset 86189:72c33149e1a9 Jul2021

When destroying a bat, make sure there are no remnants in the BACKUP directory.
author Sjoerd Mullender <sjoerd@acm.org>
date Thu, 28 Jul 2022 20:23:53 +0200
parents 9b9e105ed339
children daea8245a12f
files gdk/gdk_bbp.c gdk/gdk_storage.c
diffstat 2 files changed, 26 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -2992,10 +2992,6 @@ BBPdestroy(BAT *b)
 	bat tp = VIEWtparent(b);
 	bat vtp = VIEWvtparent(b);
 
-	HASHdestroy(b);
-	IMPSdestroy(b);
-	OIDXdestroy(b);
-	PROPdestroy_nolock(b);
 	if (tp == 0) {
 		/* bats that get destroyed must unfix their atoms */
 		gdk_return (*tunfix) (const void *) = BATatoms[b->ttype].atomUnfix;
@@ -3012,12 +3008,7 @@ BBPdestroy(BAT *b)
 	}
 	if (tp || vtp)
 		VIEWunlink(b);
-	if (b->theap) {
-		HEAPfree(b->theap, true);
-	}
-	if (b->tvheap)
-		HEAPfree(b->tvheap, true);
-	b->batCopiedtodisk = false;
+	BATdelete(b);
 
 	BBPclear(b->batCacheid, true);	/* if destroyed; de-register from BBP */
 
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -955,8 +955,11 @@ BATdelete(BAT *b)
 {
 	bat bid = b->batCacheid;
 	BAT *loaded = BBP_cache(bid);
+	char o[10];
+	char *f;
 
 	assert(bid > 0);
+	snprintf(o, sizeof(o), "%o", (unsigned) bid);
 	if (loaded) {
 		b = loaded;
 	}
@@ -964,9 +967,29 @@ BATdelete(BAT *b)
 	IMPSdestroy(b);
 	OIDXdestroy(b);
 	PROPdestroy_nolock(b);
-	HEAPfree(b->theap, true);
-	if (b->tvheap)
+	if (b->theap) {
+		HEAPfree(b->theap, true);
+		if ((f = GDKfilepath(b->theap->farmid, BAKDIR, o, "tail1")) != NULL) {
+			MT_remove(f);
+			size_t i = strlen(f) - 1;
+			f[i] = '2';
+			MT_remove(f);
+#if SIZEOF_VAR_T == 8
+			f[i] = '4';
+			MT_remove(f);
+#endif
+			f[i] = '\0';
+			MT_remove(f);
+			GDKfree(f);
+		}
+	}
+	if (b->tvheap) {
 		HEAPfree(b->tvheap, true);
+		if ((f = GDKfilepath(b->theap->farmid, BAKDIR, o, "theap")) != NULL) {
+			MT_remove(f);
+			GDKfree(f);
+		}
+	}
 	b->batCopiedtodisk = false;
 }