Changeset: a5153b2f902c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a5153b2f902c
Modified Files:
        MonetDB.spec
        gdk/gdk_bbp.c
        gdk/gdk_private.h
        monetdb5/mal/mal_client.c
        monetdb5/mal/mal_interpreter.c
        sql/server/rel_optimize_proj.c
        sql/server/rel_optimize_sel.c
Branch: default
Log Message:

Merge with Dec2023 branch.


diffs (272 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -808,9 +808,7 @@ do
   /usr/sbin/semodule -s ${selinuxvariant} -i \
     %{_datadir}/selinux/${selinuxvariant}/monetdb.pp &> /dev/null || :
 done
-# use /var/run/monetdb since that's what it says in the monetdb.fc file
-# it says that because /run/monetdb for some reason doesn't work
-/sbin/restorecon -R %{_localstatedir}/monetdb5 %{_localstatedir}/log/monetdb 
/var/run/monetdb %{_bindir}/monetdbd %{_bindir}/mserver5 
%{_unitdir}/monetdbd.service &> /dev/null || :
+/sbin/restorecon -R %{_localstatedir}/monetdb5 %{_localstatedir}/log/monetdb 
%{_rundir}/monetdb %{_bindir}/monetdbd %{_bindir}/mserver5 
%{_unitdir}/monetdbd.service &> /dev/null || :
 /usr/bin/systemctl try-restart monetdbd.service
 
 %postun selinux
@@ -839,6 +837,13 @@ fi
 %setup -q
 
 %build
+# from Fedora 40, selinux uses /run where before it used /var/run
+# the code is now for Fedora 40 but needs a patch for older versions
+%if (0%{?fedora} < 40)
+sed -i 
's;@CMAKE_INSTALL_FULL_RUNSTATEDIR@/monetdb;@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/run/monetdb;'
 misc/selinux/monetdb.fc.in
+sed -i 's/1\.2/1.1/' misc/selinux/monetdb.te
+%endif
+
 %cmake3 \
         -DCMAKE_INSTALL_RUNSTATEDIR=/run \
         -DRELEASE_VERSION=ON \
diff --git a/gdk/ChangeLog.Dec2023 b/gdk/ChangeLog.Dec2023
--- a/gdk/ChangeLog.Dec2023
+++ b/gdk/ChangeLog.Dec2023
@@ -1,6 +1,12 @@
 # ChangeLog file for GDK
 # This file is updated with Maddlog
 
+* Thu Mar 28 2024 Sjoerd Mullender <sjo...@acm.org>
+- Threads have their own list of free bats.  The list was not returned
+  to the system when a thread exited, meaning that the free bats that
+  were in the list would not be reused by any thread.  This has been
+  fixed.
+
 * Mon Mar 18 2024 Sjoerd Mullender <sjo...@acm.org>
 - Fixed a couple of deadlock situations, one actually observed, one
   never observed.
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1746,6 +1746,10 @@ BBPtrim(bool aggressive, bat nbat)
                flag |= BBPHOT;
        lng t0 = GDKusec();
        for (bat bid = 1; bid < nbat && !GDKexiting(); bid++) {
+               /* quick check to see if we might possibly have to do
+                * work (includes free bats) */
+               if ((BBP_status(bid) & BBPLOADED) == 0)
+                       continue;
                /* don't do this during a (sub)commit */
                BBPtmlock();
                MT_lock_set(&GDKswapLock(bid));
@@ -2930,10 +2934,8 @@ BBPclear(bat i)
 }
 
 void
-BBPrelinquish(void)
+BBPrelinquish(struct freebats *t)
 {
-       struct freebats *t = MT_thread_getfreebats();
-
        if (t->nfreebats == 0)
                return;
        MT_lock_set(&GDKcacheLock);
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -112,8 +112,6 @@ bat BBPallocbat(int tt)
        __attribute__((__visibility__("hidden")));
 void BBPprintinfo(void)
        __attribute__((__visibility__("hidden")));
-void BBPrelinquish(void)
-       __attribute__((__visibility__("hidden")));
 int BBPselectfarm(role_t role, int type, enum heaptype hptype)
        __attribute__((__visibility__("hidden")));
 gdk_return BBPsync(int cnt, bat *restrict subcommit, BUN *restrict sizes, lng 
logno)
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -285,9 +285,10 @@ dump_threads(void)
                MT_Cond *cn = t->condwait;
                struct mtthread *jn = t->joinwait;
                int pos = snprintf(buf, sizeof(buf),
-                                  "%s, tid %zu, waiting for %s%s, working on 
%.200s",
+                                  "%s, tid %zu, %"PRIu32" free bats, waiting 
for %s%s, working on %.200s",
                                   t->threadname,
                                   t->tid,
+                                  t->freebats.nfreebats,
                                   lk ? "lock " : sm ? "semaphore " : cn ? 
"condvar " : jn ? "thread " : "",
                                   lk ? lk->name : sm ? sm->name : cn ? 
cn->name : jn ? jn->threadname : "nothing",
                                   ATOMIC_GET(&t->exited) ? "exiting" :
@@ -314,6 +315,7 @@ rm_mtthread(struct mtthread *t)
        struct mtthread **pt;
 
        assert(t != &mainthread);
+       BBPrelinquish(&t->freebats);
        thread_lock();
        for (pt = &mtthreads; *pt && *pt != t; pt = &(*pt)->next)
                ;
diff --git a/gdk/gdk_system_private.h b/gdk/gdk_system_private.h
--- a/gdk/gdk_system_private.h
+++ b/gdk/gdk_system_private.h
@@ -45,3 +45,5 @@ struct freebats {
 };
 struct freebats *MT_thread_getfreebats(void)
        __attribute__((__visibility__("hidden")));
+void BBPrelinquish(struct freebats *t)
+       __attribute__((__visibility__("hidden")));
diff --git a/misc/selinux/monetdb.fc.in b/misc/selinux/monetdb.fc.in
--- a/misc/selinux/monetdb.fc.in
+++ b/misc/selinux/monetdb.fc.in
@@ -12,8 +12,7 @@
 @CMAKE_INSTALL_FULL_BINDIR@/mserver5                           --      
gen_context(system_u:object_r:mserver5_exec_t,s0)
 @CMAKE_INSTALL_FULL_LIBDIR@/systemd/system/monetdbd.*                  
gen_context(system_u:object_r:monetdbd_unit_file_t,s0)
 @CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/monetdb(/.*)?                           
        gen_context(system_u:object_r:monetdbd_log_t,s0)
-# for some reason we cannot use /run/monetdb here, even though that is the 
real name
-@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/run/monetdb(/.*)?                           
        gen_context(system_u:object_r:monetdbd_var_run_t,s0)
+@CMAKE_INSTALL_FULL_RUNSTATEDIR@/monetdb(/.*)?                                 
gen_context(system_u:object_r:monetdbd_var_run_t,s0)
 # database "farm"
 @CMAKE_INSTALL_FULL_LOCALSTATEDIR@/monetdb5/dbfarm(/.*)?                       
        gen_context(system_u:object_r:mserver5_db_t,s0)
 @CMAKE_INSTALL_FULL_LOCALSTATEDIR@/monetdb5/dbfarm/\.merovingian_properties    
--      gen_context(system_u:object_r:monetdbd_etc_t,s0)
diff --git a/misc/selinux/monetdb.te b/misc/selinux/monetdb.te
--- a/misc/selinux/monetdb.te
+++ b/misc/selinux/monetdb.te
@@ -8,7 +8,7 @@
 # Copyright August 2008 - 2023 MonetDB B.V.;
 # Copyright 1997 - July 2008 CWI.
 
-policy_module(monetdb, 1.1)
+policy_module(monetdb, 1.2)
 # The above line declares that this file is a SELinux policy file. Its
 # name is monetdb, so the file should be saved as monetdb.te
 
diff --git a/misc/selinux/post_install_script_file.in 
b/misc/selinux/post_install_script_file.in
--- a/misc/selinux/post_install_script_file.in
+++ b/misc/selinux/post_install_script_file.in
@@ -3,7 +3,5 @@ do
   /usr/sbin/semodule -s ${selinuxvariant} -i \
     @CMAKE_INSTALL_DATADIR@/selinux/${selinuxvariant}/monetdb.pp &> /dev/null 
|| :
 done
-# use /var/run/monetdb since that's what it says in the monetdb.fc file
-# it says that because /run/monetdb for some reason doesn't work
 /sbin/restorecon -R @CMAKE_INSTALL_FULL_LOCALSTATEDIR@/monetdb5 
@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/monetdb 
@CMAKE_INSTALL_FULL_RUNSTATEDIR@/monetdb @CMAKE_INSTALL_FULL_BINDIR@/monetdbd 
@CMAKE_INSTALL_FULL_BINDIR@/mserver5 %{_unitdir}/monetdbd.service &> /dev/null 
|| :
 /usr/bin/systemctl try-restart monetdbd.service
diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -356,7 +356,7 @@ MCshutdowninprogress(void)
  * When a client needs to be terminated then the file descriptors for
  * its input/output are simply closed.  This leads to a graceful
  * degradation, but may take some time when the client is busy.  A more
- * forcefull method is to kill the client thread, but this may leave
+ * forceful method is to kill the client thread, but this may leave
  * locks and semaphores in an undesirable state.
  *
  * The routine freeClient ends a single client session, but through side
@@ -443,7 +443,7 @@ MCcloseClient(Client c)
 
 /*
  * If a client disappears from the scene (eof on stream), we should
- * terminate all its children. This is in principle a forcefull action,
+ * terminate all its children. This is in principle a forceful action,
  * because the children may be ignoring the primary IO streams.
  * (Instead they may be blocked in an infinite loop)
  *
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -1362,7 +1362,7 @@ runMALsequence(Client cntxt, MalBlkPtr m
  * an error raised deeply inside the system.
  *
  * The policy is to require all C-functions to return a string-pointer.
- * Upon a successfull call, it is a NULL string. Otherwise it contains an
+ * Upon a successful call, it is a NULL string. Otherwise it contains an
  * encoding of the exceptional state encountered. This message
  * starts with the exception identifer, followed by contextual details.
  */
@@ -1377,7 +1377,7 @@ runMALsequence(Client cntxt, MalBlkPtr m
  * A key issue is to deal with temporary BATs in an efficient way.
  * References to bats in the buffer pool may cause dangling references
  * at the language level. This appears as soons as your share
- * a reference and delete the BAT from one angle. If not carefull, the
+ * a reference and delete the BAT from one angle. If not careful, the
  * dangling pointer may subsequently be associated with another BAT
  *
  * All string values are private to the VALrecord, which means they
diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c
--- a/sql/server/rel_optimize_proj.c
+++ b/sql/server/rel_optimize_proj.c
@@ -90,6 +90,8 @@ rel_push_project_down_(visitor *v, sql_r
                        }
                }
        }
+       /* ToDo handle useful renames, ie new relation name and unique set of 
attribute names (could reduce set of * attributes) */
+       /* handle both useless and useful with project [ group by ] */
        return rel;
 }
 
@@ -391,6 +393,7 @@ exp_rename(mvc *sql, sql_exp *e, sql_rel
                }
                if (!ne)
                        return e;
+               sql_exp *oe = e;
                e = NULL;
                if (exp_name(ne) && ne->r && ne->l)
                        e = rel_bind_column2(sql, t, ne->l, ne->r, 0);
@@ -401,6 +404,7 @@ exp_rename(mvc *sql, sql_exp *e, sql_rel
                        sql->errstr[0] = 0;
                        if (exp_is_atom(ne))
                                return ne;
+                       return oe;
                }
                return exp_ref(sql, e);
        case e_cmp:
@@ -1564,7 +1568,7 @@ rel_simplify_sum(visitor *v, sql_rel *re
                                                /* the new generate function 
calls are valid, update relations */
                                                /* we need a new relation for 
the multiplication and addition/subtraction */
                                                if (!upper) {
-                                                       /* be carefull with 
relations with more than 1 reference, so do in-place replacement */
+                                                       /* be careful with 
relations with more than 1 reference, so do in-place replacement */
                                                        list *projs = 
rel_projections(v->sql, rel, NULL, 1, 1);
                                                        sql_rel *nrel = 
rel_groupby(v->sql, rel->l, NULL);
                                                        nrel->exps = rel->exps;
diff --git a/sql/server/rel_optimize_sel.c b/sql/server/rel_optimize_sel.c
--- a/sql/server/rel_optimize_sel.c
+++ b/sql/server/rel_optimize_sel.c
@@ -2627,7 +2627,7 @@ rel_rewrite_semijoin(visitor *v, sql_rel
  * also push simple expressions of a semijoin down if they only
  * involve the left sided of the semijoin.
  *
- * in some cases the other way is usefull, ie push join down
+ * in some cases the other way is useful, ie push join down
  * semijoin. When the join reduces (ie when there are selects on it).
  *
  * At the moment, we only flag changes by this optimizer on the first level of 
optimization
diff --git a/sql/test/BugTracker-2024/Tests/exp_ref-Bug-7479.test 
b/sql/test/BugTracker-2024/Tests/exp_ref-Bug-7479.test
--- a/sql/test/BugTracker-2024/Tests/exp_ref-Bug-7479.test
+++ b/sql/test/BugTracker-2024/Tests/exp_ref-Bug-7479.test
@@ -10,23 +10,16 @@ WITH x AS ( SELECT 1 x UNION SELECT - '1
 1
 1
 
-query IRI nosort
+statment error syntax error, unexpected ')' in: "with x as ( select 1 x union 
select - '199419' ) select 1 from x as where x in ("
 WITH x AS ( SELECT 1 x UNION SELECT - '199419' ) SELECT 1 FROM x AS WHERE x IN 
( SELECT min ( x ) OVER ( PARTITION BY x ) AS )
 ----
-1
-1.000
-1
-1
--199419.000
-1
 
-skipif knownfail
 query T nosort
 WITH x AS ( SELECT 1 x UNION SELECT - '199419' ) SELECT 1 FROM x AS WHERE x IN 
( SELECT x FROM x , ( SELECT min ( x ) OVER ( PARTITION BY x ) ) AS )
 ----
+1
+1
 
-skipif knownfail
-query T nosort
+statment error GDK reported error: BATsubcross: more than one match
 SELECT ( WITH x AS ( SELECT 1 x UNION SELECT - '199419' ) SELECT 1 FROM x AS 
WHERE x IN ( SELECT x FROM x , ( SELECT min ( x ) OVER ( PARTITION BY x ) ) AS 
) )
 ----
-
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to