Changeset: 6ac725057a5f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6ac725057a5f
Modified Files:
        gdk/ChangeLog.Sep2022
        gdk/gdk_logger.c
        gdk/gdk_posix.c
        sql/include/sql_catalog.h
        sql/storage/bat/bat_storage.c
        sql/storage/objectset.c
        sql/storage/sql_storage.h
        sql/storage/store.c
        testing/suppress.txt
        tools/merovingian/client/Tests/monetdb_snapshot.py
        tools/merovingian/daemon/handlers.c
Branch: Sep2022
Log Message:

Merge with Jan2022 branch.


diffs (111 lines):

diff --git a/gdk/ChangeLog.Sep2022 b/gdk/ChangeLog.Sep2022
--- a/gdk/ChangeLog.Sep2022
+++ b/gdk/ChangeLog.Sep2022
@@ -1,6 +1,13 @@
 # ChangeLog file for GDK
 # This file is updated with Maddlog
 
+* Mon Feb 20 2023 Sjoerd Mullender <sjo...@acm.org>
+- A race condition was fixed where certain write-ahead log messages
+  could get intermingled, resulting in a corrupted WAL file.
+- If opening of a file failed when it was supposed to get memory mapped,
+  an incorrect value was returned to indicate the failure, causing
+  crashes later on.  This has been fixed.
+
 * Thu Feb 16 2023 Sjoerd Mullender <sjo...@acm.org>
 - A race condition was fixed that could result in a missing tail file
   for a string bat (i.e. a file with .tail1, .tail2, or .tail4 extension).
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -2457,16 +2457,19 @@ log_constant(logger *lg, int type, ptr v
 
        gdk_return (*wt) (const void *, stream *, size_t) = 
BATatoms[type].atomWrite;
 
+       log_lock(lg);
        if (log_write_format(lg, &l) != GDK_SUCCEED ||
            !mnstr_writeLng(lg->output_log, nr) ||
            mnstr_write(lg->output_log, &tpe, 1, 1) != 1 ||
            !mnstr_writeLng(lg->output_log, offset)) {
                (void) ATOMIC_DEC(&lg->refcount);
+               log_unlock(lg);
                ok = GDK_FAIL;
                goto bailout;
        }
 
        ok = wt(val, lg->output_log, 1);
+       log_unlock(lg);
 
        if (lg->debug & 1)
                fprintf(stderr, "#Logged %d " LLFMT " inserts\n", id, nr);
@@ -2839,7 +2842,7 @@ new_logfile(logger *lg, stream* output_l
        const lng p = (lng) getfilepos(getFile(lg->output_log));
        if (p == -1)
                return GDK_FAIL;
-       if (lg->drops > 100000 || p > log_large || (lg->end*1024) > log_large) {
+       if (((!lg->pending || !lg->pending->next) && lg->drops > 100000) || p > 
log_large || (lg->end*1024) > log_large) {
                log_lock(lg);
                if (ATOMIC_GET(&lg->refcount) == 1) {
                        lg->id++;
diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c
--- a/gdk/gdk_posix.c
+++ b/gdk/gdk_posix.c
@@ -332,7 +332,7 @@ MT_mmap(const char *path, int mode, size
        fd = open(path, O_CREAT | ((mode & MMAP_WRITE) ? O_RDWR : O_RDONLY) | 
O_CLOEXEC, MONETDB_MODE);
        if (fd < 0) {
                GDKsyserror("open %s failed\n", path);
-               return MAP_FAILED;
+               return NULL;
        }
        ret = mmap(NULL,
                   len,
@@ -343,9 +343,10 @@ MT_mmap(const char *path, int mode, size
        if (ret == MAP_FAILED) {
                GDKsyserror("mmap(%s,%zu) failed\n", path, len);
                ret = NULL;
+       } else {
+               VALGRIND_MALLOCLIKE_BLOCK(ret, len, 0, 1);
        }
        close(fd);
-       VALGRIND_MALLOCLIKE_BLOCK(ret, len, 0, 1);
        return ret;
 }
 
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -3689,7 +3689,7 @@ sql_trans_rollback(sql_trans *tr, bool c
                        if (!c->cleanup) {
                                _DELETE(c);
                        } else if (c->cleanup && !c->cleanup(store, c, oldest)) 
{
-                               /* TODO change too node stealing (no allocs 
here) */
+                               /* TODO change to node stealing (no allocs 
here) */
                                store->changes = sa_list_append(tr->sa, 
store->changes, c);
                        } else
                                _DELETE(c);
diff --git a/tools/merovingian/daemon/handlers.c 
b/tools/merovingian/daemon/handlers.c
--- a/tools/merovingian/daemon/handlers.c
+++ b/tools/merovingian/daemon/handlers.c
@@ -311,7 +311,7 @@ childhandler(void)
                                if (WIFEXITED(wstatus)) {
                                        Mlevelfprintf(INFORMATION, stdout, 
"database '%s' (%lld) has exited with "
                                                         "exit status %d\n", 
p->dbname,
-                                                        (long long int)p->pid, 
WEXITSTATUS(wstatus));
+                                                        (long long int)pid, 
WEXITSTATUS(wstatus));
                                } else if (WIFSIGNALED(wstatus)) {
                                        const char *sigstr = 
sigtostr(WTERMSIG(wstatus));
                                        char signum[8];
@@ -322,11 +322,11 @@ childhandler(void)
                                        if (WCOREDUMP(wstatus)) {
                                                Mlevelfprintf(ERROR, stdout, 
"database '%s' (%lld) has crashed "
                                                                 "with signal 
%s (dumped core)\n",
-                                                                p->dbname, 
(long long int)p->pid, sigstr);
+                                                                p->dbname, 
(long long int)pid, sigstr);
                                        } else {
                                                Mlevelfprintf(WARNING, stdout, 
"database '%s' (%lld) was killed "
                                                                 "by signal 
%s\n",
-                                                                p->dbname, 
(long long int)p->pid, sigstr);
+                                                                p->dbname, 
(long long int)pid, sigstr);
                                        }
                                }
                                break;
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to