MonetDB: Jun2020 - Merge with linear-hashing branch.

2020-05-15 Thread Sjoerd Mullender
Changeset: 6f4adbfbee9f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6f4adbfbee9f
Modified Files:
geom/monetdb5/geom.c
monetdb5/mal/mal_client.c
sql/backends/monet5/UDF/pyapi3/pyheader.h
sql/server/rel_select.c
sql/server/sql_partition.c
sql/server/sql_semantic.c
sql/storage/bat/bat_storage.c
sql/storage/sql_storage.h
sql/storage/store.c

sql/test/BugTracker-2016/Tests/decimal_vs_integer.Bug-3941.stable.out.single
sql/test/wlcr/Tests/wlr110.py
sql/test/wlcr/Tests/wlr35.py
testing/Mtest.py.in
Branch: Jun2020
Log Message:

Merge with linear-hashing branch.


diffs (46 lines):

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
@@ -133,14 +133,13 @@ static Client
 MCnewClient(void)
 {
Client c;
-   MT_lock_set(_contextLock);
+
for (c = mal_clients; c < mal_clients + MAL_MAXCLIENTS; c++) {
if (c->mode == FREECLIENT) {
c->mode = RUNCLIENT;
break;
}
}
-   MT_lock_unset(_contextLock);
 
if (c == mal_clients + MAL_MAXCLIENTS)
return NULL;
@@ -207,6 +206,7 @@ MCinitClientRecord(Client c, oid user, b
 {
const char *prompt;
 
+   /* mal_contextLock is held when this is called */
c->user = user;
c->username = 0;
c->scenario = NULL;
@@ -286,11 +286,15 @@ MCinitClient(oid user, bstream *fin, str
 {
Client c = NULL;
 
-   if ((c = MCnewClient()) == NULL)
-   return NULL;
-   return MCinitClientRecord(c, user, fin, fout);
+   MT_lock_set(_contextLock);
+   c = MCnewClient();
+   if (c)
+   c = MCinitClientRecord(c, user, fin, fout);
+   MT_lock_unset(_contextLock);
+   return c;
 }
 
+
 /*
  * The administrator should be initialized to enable interpretation of
  * the command line arguments, before it starts servicing statements
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - Merge with linear-hashing branch.

2020-03-30 Thread Sjoerd Mullender
Changeset: 7025f88e518e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7025f88e518e
Modified Files:
monetdb5/tools/Tests/mserver5-ipv6.py
sql/backends/monet5/Tests/dbextra_lock_test.py
sql/storage/store.c
sql/test/BugTracker-2009/Tests/create_on_ro_db_crash.SF-2830238.SQL.py
sql/test/BugTracker-2009/Tests/lost_update.SF-2790020.SQL.py
sql/test/BugTracker-2010/Tests/new-readonly-db.Bug-2695.SQL.py

sql/test/BugTracker-2011/Tests/interrupted-initialization.Bug-2875.SQL.py
sql/test/BugTracker-2013/Tests/corrupt-after-restart.Bug-3282.SQL.py
sql/test/BugTracker-2014/Tests/acidity-fail.Bug-3635.py
sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.SQL.py
sql/test/BugTracker-2017/Tests/shutdown.Bug-6182.SQL.py

sql/test/BugTracker-2018/Tests/local_replica_table_not_detected.Bug-6620.py
sql/test/BugTracker-2018/Tests/remote-table-where-is-null.Bug-6601.py
sql/test/BugTracker-2018/Tests/remote-table-where-not-equal.Bug-6621.py
sql/test/BugTracker-2019/Tests/alter_table_drop_column.Bug-6749.py

sql/test/BugTracker-2019/Tests/remote-table-non-existent-column.Bug-6750.py
sql/test/BugTracker-2020/Tests/functions-not-persist.Bug-6819.SQL.py
sql/test/BugTracker/Tests/mdb_starts_with_sql_debug_64.SF-1999354.SQL.py
sql/test/BugTracker/Tests/set_a_new_user_password.SF-1844050.SQL.py

sql/test/BugTracker/Tests/set_sql_debug_64__breaking_the_DB.SF-1906287.SQL.py
sql/test/merge-partitions/Tests/mergepart23.SQL.py
sql/test/merge-partitions/Tests/mergepart29.SQL.py
sql/test/mserver5-sql-readonly/Tests/mserver5-sql-readonly-table.py
sql/test/mserver5-sql-readonly/Tests/mserver5-sql-readonly-view.py
sql/test/remote/Tests/creds.SQL.py
sql/test/remote/Tests/different_user.SQL.py
sql/test/remote/Tests/invalid_creds.SQL.py
sql/test/remote/Tests/ssbm.SQL.py
sql/test/rename/Tests/rename00.SQL.py
sql/test/rename/Tests/rename11.py
sql/test/scripts/Tests/alastair_udf_mergetable_bug.py
sql/test/scripts/Tests/copy-from-lz4.py
sql/test/testdb-reload/Tests/reload.py
sql/test/wlcr/Tests/wlc01.py
sql/test/wlcr/Tests/wlc100.py
sql/test/wlcr/Tests/wlc20.py
sql/test/wlcr/Tests/wlc21.py
sql/test/wlcr/Tests/wlc30.py
sql/test/wlcr/Tests/wlc40.py
sql/test/wlcr/Tests/wlc50.py
sql/test/wlcr/Tests/wlc70.py
sql/test/wlcr/Tests/wlr01.py
sql/test/wlcr/Tests/wlr10.py
sql/test/wlcr/Tests/wlr100.py
sql/test/wlcr/Tests/wlr110.py
sql/test/wlcr/Tests/wlr20.py
sql/test/wlcr/Tests/wlr30.py
sql/test/wlcr/Tests/wlr35.py
sql/test/wlcr/Tests/wlr40.py
sql/test/wlcr/Tests/wlr50.py
sql/test/wlcr/Tests/wlr70.py
sql/test/wlcr/Tests/wlr80.py
Branch: Jun2020
Log Message:

Merge with linear-hashing branch.


diffs (truncated from 2924 to 300 lines):

diff --git a/monetdb5/tools/Tests/mserver5-ipv6.py 
b/monetdb5/tools/Tests/mserver5-ipv6.py
--- a/monetdb5/tools/Tests/mserver5-ipv6.py
+++ b/monetdb5/tools/Tests/mserver5-ipv6.py
@@ -4,18 +4,24 @@ try:
 except ImportError:
 import process
 
-server = process.server(stdin=process.PIPE, stdout=process.PIPE, 
stderr=process.PIPE, ipv6=True)
-client = process.client('sql', host='::1', server=server, stdin=process.PIPE, 
stdout=process.PIPE, stderr=process.PIPE)
-cout, cerr = client.communicate('''
+server = None
+try:
+server = process.server(stdin=process.PIPE, stdout=process.PIPE, 
stderr=process.PIPE, ipv6=True)
+client = process.client('sql', host='::1', server=server, 
stdin=process.PIPE, stdout=process.PIPE, stderr=process.PIPE)
+cout, cerr = client.communicate('''
 start transaction;
 create table "things" ("col1" int);
 insert into "things" values (1); select "col1" from "things";
 rollback;
 ''')
 
-sout, serr = server.communicate()
-sys.stdout.write(sout)
-sys.stderr.write(serr)
+sout, serr = server.communicate()
+server = None
+sys.stdout.write(sout)
+sys.stderr.write(serr)
 
-sys.stdout.write(cout)
-sys.stderr.write(cerr)
+sys.stdout.write(cout)
+sys.stderr.write(cerr)
+finally:
+if server is not None:
+server.terminate()
diff --git a/sql/backends/monet5/Tests/dbextra_lock_test.py 
b/sql/backends/monet5/Tests/dbextra_lock_test.py
--- a/sql/backends/monet5/Tests/dbextra_lock_test.py
+++ b/sql/backends/monet5/Tests/dbextra_lock_test.py
@@ -8,18 +8,22 @@ import os
 
 p = os.path.join(os.getenv('GDK_DBFARM'), 'transient_dir')
 
-s1 = process.server(stdin = process.PIPE, stdout = process.PIPE,
-stderr = process.PIPE, dbextra=p)
-
-
-
-s2 = process.server(stdin = process.PIPE, stdout = process.PIPE,
-stderr = process.PIPE, dbextra=p)
+s1 = s2 = None
+try:
+s1 = process.server(stdin = process.PIPE, 

MonetDB: Jun2020 - Merge with linear-hashing branch.

2020-03-19 Thread Sjoerd Mullender
Changeset: c57cfbc65dac for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c57cfbc65dac
Modified Files:
common/utils/msabaoth.c
tools/merovingian/daemon/client.c
tools/merovingian/daemon/controlrunner.c
tools/merovingian/daemon/forkmserver.c
tools/merovingian/daemon/handlers.c
tools/merovingian/daemon/merovingian.c
tools/merovingian/daemon/merovingian.h
tools/merovingian/daemon/multiplex-funnel.c
Branch: Jun2020
Log Message:

Merge with linear-hashing branch.


diffs (truncated from 1068 to 300 lines):

diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c
--- a/common/utils/msabaoth.c
+++ b/common/utils/msabaoth.c
@@ -617,7 +617,7 @@ msab_getSingleStatus(const char *pathbuf
 */
snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname,
 _sabaoth_internal_uuid);
-   if (stat(buf, ) != -1) {
+   if (stat(buf, ) == 0) {
/* database has the same process signature as ours, which
 * means, it must be us, rely on the uplog state */
snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, 
UPLOGFILE);
@@ -641,7 +641,7 @@ msab_getSingleStatus(const char *pathbuf
(void)fclose(f);
}
} else if (snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, 
".gdk_lock"),
-  ((fd = MT_lockf(buf, F_TEST)) == -2)) {
+  ((fd = MT_lockf(buf, F_TLOCK)) == -2)) {
/* Locking failed; this can be because the lockfile couldn't
 * be created.  Probably there is no Mserver running for
 * that case also.
@@ -650,15 +650,18 @@ msab_getSingleStatus(const char *pathbuf
} else if (fd == -1) {
/* file is locked, so mserver is running, see if the database
 * has finished starting */
-   snprintf(buf, sizeof(buf), "%s/%s/%s",
-pathbuf, dbname, STARTEDFILE);
+   snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, 
STARTEDFILE);
if (stat(buf, ) == -1) {
sdb->state = SABdbStarting;
} else {
sdb->state = SABdbRunning;
}
} else {
-   /* file is not locked, check for a crash in the uplog */
+   /* file was not locked (we just locked it), check for a crash
+* in the uplog */
+   snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, 
STARTEDFILE);
+   /* just to be sure, remove the .started file */
+   (void) remove(log); /* may fail, that's fine */
snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, 
UPLOGFILE);
if ((f = fopen(log, "r")) != NULL) {
(void)fseek(f, -1, SEEK_END);
@@ -675,28 +678,27 @@ msab_getSingleStatus(const char *pathbuf
/* no uplog, so presumably never started */
sdb->state = SABdbInactive;
}
+   MT_lockf(buf, F_ULOCK);
+   close(fd);
}
snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, 
MAINTENANCEFILE);
-   sdb->locked = stat(buf, ) != -1;
+   sdb->locked = stat(buf, ) == 0;
 
/* add scenarios that are supported */
sdb->scens = NULL;
snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, SCENARIOFILE);
if ((f = fopen(buf, "r")) != NULL) {
sablist* np = NULL;
-   while (fgets(data, 8095, f) != NULL) {
+   while (fgets(data, (int) sizeof(data), f) != NULL) {
if (*data != '\0' && data[strlen(data) - 1] == '\n')
data[strlen(data) - 1] = '\0';
if (sdb->scens == NULL) {
-   sdb->scens = malloc(sizeof(sablist));
-   sdb->scens->val = strdup(data);
-   sdb->scens->next = NULL;
-   np = sdb->scens;
+   np = sdb->scens = malloc(sizeof(sablist));
} else {
np = np->next = malloc(sizeof(sablist));
-   np->val = strdup(data);
-   np->next = NULL;
}
+   np->val = strdup(data);
+   np->next = NULL;
}
(void)fclose(f);
}
@@ -706,19 +708,16 @@ msab_getSingleStatus(const char *pathbuf
snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, CONNECTIONFILE);
if ((f = fopen(buf, "r")) != NULL) {
sablist* np = NULL;
-   while (fgets(data, 8095, f) != NULL) {
+   while (fgets(data, (int) sizeof(data), f) != NULL) {