From bc474a505bdaae4b010c086632901261b34f9e0e Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Sun, 9 Jul 2017 16:20:11 +0200 Subject: [PATCH 1/7] ctdb: enable mutexes for volatile TDBs by default Bug: https://bugzilla.samba.org/show_bug.cgi?id=12891 Signed-off-by: Ralph Boehme Reviewed-by: Amitay Isaacs (cherry picked from commit 2bce9cb72f3ac7efc2f4f48b0cffa1876364ae8c) --- ctdb/common/tunable.c | 2 +- ctdb/config/ctdbd.conf | 2 +- ctdb/doc/ctdb-tunables.7.xml | 2 +- ctdb/doc/ctdb.1.xml | 2 +- ctdb/tests/tool/ctdb.listvars.001.sh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ctdb/common/tunable.c b/ctdb/common/tunable.c index ed7a52da153..14f6828bd15 100644 --- a/ctdb/common/tunable.c +++ b/ctdb/common/tunable.c @@ -145,7 +145,7 @@ static struct { offsetof(struct ctdb_tunable_list, no_ip_host_on_all_disabled) }, { "Samba3AvoidDeadlocks", 0, true, offsetof(struct ctdb_tunable_list, samba3_hack) }, - { "TDBMutexEnabled", 0, false, + { "TDBMutexEnabled", 1, false, offsetof(struct ctdb_tunable_list, mutex_enabled) }, { "LockProcessesPerDB", 200, false, offsetof(struct ctdb_tunable_list, lock_processes_per_db) }, diff --git a/ctdb/config/ctdbd.conf b/ctdb/config/ctdbd.conf index e75c65c7fd7..2d525c528fd 100644 --- a/ctdb/config/ctdbd.conf +++ b/ctdb/config/ctdbd.conf @@ -29,4 +29,4 @@ # CTDB_DEBUGLEVEL=ERR # Set some CTDB tunable variables during CTDB startup? -# CTDB_SET_TDBMutexEnabled=1 +# CTDB_SET_TDBMutexEnabled=0 diff --git a/ctdb/doc/ctdb-tunables.7.xml b/ctdb/doc/ctdb-tunables.7.xml index d0bb4508e24..7b059b75a9e 100644 --- a/ctdb/doc/ctdb-tunables.7.xml +++ b/ctdb/doc/ctdb-tunables.7.xml @@ -658,7 +658,7 @@ TDBMutexEnabled - Default: 0 + Default: 1 This parameter enables TDB_MUTEX_LOCKING feature on volatile databases if the robust mutexes are supported. This optimizes the diff --git a/ctdb/doc/ctdb.1.xml b/ctdb/doc/ctdb.1.xml index 1af1f5048c5..3aceb7369ac 100644 --- a/ctdb/doc/ctdb.1.xml +++ b/ctdb/doc/ctdb.1.xml @@ -843,7 +843,7 @@ DBRecordSizeWarn = 10000000 DBSizeWarn = 100000000 PullDBPreallocation = 10485760 NoIPHostOnAllDisabled = 0 -TDBMutexEnabled = 0 +TDBMutexEnabled = 1 LockProcessesPerDB = 200 RecBufferSizeLimit = 1000000 QueueBufferSize = 1024 diff --git a/ctdb/tests/tool/ctdb.listvars.001.sh b/ctdb/tests/tool/ctdb.listvars.001.sh index f6010a45c77..fc8f42ce067 100755 --- a/ctdb/tests/tool/ctdb.listvars.001.sh +++ b/ctdb/tests/tool/ctdb.listvars.001.sh @@ -59,7 +59,7 @@ DBRecordSizeWarn = 10000000 DBSizeWarn = 100000000 PullDBPreallocation = 10485760 NoIPHostOnAllDisabled = 0 -TDBMutexEnabled = 0 +TDBMutexEnabled = 1 LockProcessesPerDB = 200 RecBufferSizeLimit = 1000000 QueueBufferSize = 1024 -- 2.13.3 From fcacf9e2aca3a206a9efa2a7ff0a9e2b5117bdf2 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Sun, 9 Jul 2017 16:23:20 +0200 Subject: [PATCH 2/7] dbwrap: enable mutexes by default for volatile TDBs Bug: https://bugzilla.samba.org/show_bug.cgi?id=12891 Signed-off-by: Ralph Boehme Reviewed-by: Amitay Isaacs (cherry picked from commit a70be43246ab74f0a2bbe245ab31f24460b70547) --- source3/lib/dbwrap/dbwrap_open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c index 55e0adb7b71..801ebcbde4c 100644 --- a/source3/lib/dbwrap/dbwrap_open.c +++ b/source3/lib/dbwrap/dbwrap_open.c @@ -98,7 +98,7 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, if (tdb_flags & TDB_CLEAR_IF_FIRST) { const char *base; - bool try_mutex = false; + bool try_mutex = true; bool require_mutex = false; base = strrchr_m(name, '/'); -- 2.13.3 From adec26b4857d09d97aeb0ed7167957a6abeaff2f Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Tue, 11 Jul 2017 00:38:59 +1000 Subject: [PATCH 3/7] dbwrap: CTDB ignores tdb_flags passed to db attach controls Bug: https://bugzilla.samba.org/show_bug.cgi?id=12891 Signed-off-by: Amitay Isaacs Reviewed-by: Ralph Boehme (cherry picked from commit 6ae063a109ca88bf815fd1bf5e8865053bea41b9) --- source3/lib/ctdbd_conn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index 3adb57da247..d38789aa861 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -832,7 +832,7 @@ int ctdbd_db_attach(struct ctdbd_connection *conn, persistent ? CTDB_CONTROL_DB_ATTACH_PERSISTENT : CTDB_CONTROL_DB_ATTACH, - tdb_flags, 0, data, NULL, &data, &cstatus); + 0, 0, data, NULL, &data, &cstatus); if (ret != 0) { DEBUG(0, (__location__ " ctdb_control for db_attach " "failed: %s\n", strerror(ret))); -- 2.13.3 From e11161e31faa47c4003d6df0847be748bf9c3f65 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 11 Jul 2017 20:36:35 +0200 Subject: [PATCH 4/7] ctdbd_conn: move CTDB_CONTROL_ENABLE_SEQNUM control to db_open_ctdb No change in behaviour. Bug: https://bugzilla.samba.org/show_bug.cgi?id=12891 Signed-off-by: Ralph Boehme Reviewed-by: Amitay Isaacs (cherry picked from commit 0077296cee1cd54a5adb12fc706cbf99203a8213) --- source3/lib/ctdbd_conn.c | 15 --------------- source3/lib/dbwrap/dbwrap_ctdb.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index d38789aa861..70d3d83f031 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -847,21 +847,6 @@ int ctdbd_db_attach(struct ctdbd_connection *conn, *db_id = *(uint32_t *)data.dptr; talloc_free(data.dptr); - if (!(tdb_flags & TDB_SEQNUM)) { - return 0; - } - - data.dptr = (uint8_t *)db_id; - data.dsize = sizeof(*db_id); - - ret = ctdbd_control_local(conn, CTDB_CONTROL_ENABLE_SEQNUM, 0, 0, data, - NULL, NULL, &cstatus); - if ((ret != 0) || cstatus != 0) { - DEBUG(0, (__location__ " ctdb_control for enable seqnum " - "failed: %s\n", strerror(ret))); - return (ret == 0) ? EIO : ret; - } - return 0; } diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c index 8e303e6e1c4..001d2c42fb2 100644 --- a/source3/lib/dbwrap/dbwrap_ctdb.c +++ b/source3/lib/dbwrap/dbwrap_ctdb.c @@ -1779,6 +1779,7 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx, struct db_ctdb_ctx *db_ctdb; char *db_path; struct loadparm_context *lp_ctx; + TDB_DATA data; int32_t cstatus; int ret; @@ -1818,6 +1819,21 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx, return NULL; } + if (tdb_flags & TDB_SEQNUM) { + data.dptr = (uint8_t *)&db_ctdb->db_id; + data.dsize = sizeof(db_ctdb->db_id); + + ret = ctdbd_control_local(conn, CTDB_CONTROL_ENABLE_SEQNUM, + 0, 0, data, + NULL, NULL, &cstatus); + if ((ret != 0) || cstatus != 0) { + DBG_ERR("ctdb_control for enable seqnum " + "failed: %s\n", strerror(ret)); + TALLOC_FREE(result); + return NULL; + } + } + db_path = ctdbd_dbpath(db_ctdb->conn, db_ctdb, db_ctdb->db_id); result->persistent = ((tdb_flags & TDB_CLEAR_IF_FIRST) == 0); -- 2.13.3 From cc2e29e8b79ffc3ffec232fa2127562a4c19712e Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 11 Jul 2017 20:41:43 +0200 Subject: [PATCH 5/7] ctdbd_conn: pass persistent bool instead of tdb_flags ctdbd_db_attach() only needs to know the ctdb database model, not the rest of the flags. Bug: https://bugzilla.samba.org/show_bug.cgi?id=12891 Signed-off-by: Ralph Boehme Reviewed-by: Amitay Isaacs (cherry picked from commit b2b7e3b9710fa22716f931177265dcd8de74532b) --- source3/include/ctdbd_conn.h | 2 +- source3/lib/ctdbd_conn.c | 3 +-- source3/lib/dbwrap/dbwrap_ctdb.c | 5 +++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h index 06fbcc373a4..38477d313de 100644 --- a/source3/include/ctdbd_conn.h +++ b/source3/include/ctdbd_conn.h @@ -55,7 +55,7 @@ char *ctdbd_dbpath(struct ctdbd_connection *conn, TALLOC_CTX *mem_ctx, uint32_t db_id); int ctdbd_db_attach(struct ctdbd_connection *conn, const char *name, - uint32_t *db_id, int tdb_flags); + uint32_t *db_id, bool persistent); int ctdbd_migrate(struct ctdbd_connection *conn, uint32_t db_id, TDB_DATA key); diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index 70d3d83f031..b81feca65ba 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -819,12 +819,11 @@ char *ctdbd_dbpath(struct ctdbd_connection *conn, * attach to a ctdb database */ int ctdbd_db_attach(struct ctdbd_connection *conn, - const char *name, uint32_t *db_id, int tdb_flags) + const char *name, uint32_t *db_id, bool persistent) { int ret; TDB_DATA data; int32_t cstatus; - bool persistent = (tdb_flags & TDB_CLEAR_IF_FIRST) == 0; data = string_term_tdb_data(name); diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c index 001d2c42fb2..07e35f8ffb0 100644 --- a/source3/lib/dbwrap/dbwrap_ctdb.c +++ b/source3/lib/dbwrap/dbwrap_ctdb.c @@ -1780,6 +1780,7 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx, char *db_path; struct loadparm_context *lp_ctx; TDB_DATA data; + bool persistent = (tdb_flags & TDB_CLEAR_IF_FIRST); int32_t cstatus; int ret; @@ -1811,7 +1812,7 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx, db_ctdb->db = result; db_ctdb->conn = conn; - ret = ctdbd_db_attach(db_ctdb->conn, name, &db_ctdb->db_id, tdb_flags); + ret = ctdbd_db_attach(db_ctdb->conn, name, &db_ctdb->db_id, persistent); if (ret != 0) { DEBUG(0, ("ctdbd_db_attach failed for %s: %s\n", name, strerror(ret))); @@ -1836,7 +1837,7 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx, db_path = ctdbd_dbpath(db_ctdb->conn, db_ctdb, db_ctdb->db_id); - result->persistent = ((tdb_flags & TDB_CLEAR_IF_FIRST) == 0); + result->persistent = persistent; result->lock_order = lock_order; /* only pass through specific flags */ -- 2.13.3 From 60c1cbf4d6e4e0e59488decd75429953b4567c33 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 11 Jul 2017 21:35:17 +0200 Subject: [PATCH 6/7] dbwrap: Ask CTDB for local tdb open flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: https://bugzilla.samba.org/show_bug.cgi?id=12891 Signed-off-by: Ralph Boehme Reviewed-by: Amitay Isaacs Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Wed Jul 12 13:25:11 CEST 2017 on sn-devel-144 (cherry picked from commit de9d21957706bd5d811db01b7b5d88a0bb17034b) --- source3/lib/dbwrap/dbwrap_ctdb.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c index 07e35f8ffb0..6bdaab000a9 100644 --- a/source3/lib/dbwrap/dbwrap_ctdb.c +++ b/source3/lib/dbwrap/dbwrap_ctdb.c @@ -1840,9 +1840,25 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx, result->persistent = persistent; result->lock_order = lock_order; - /* only pass through specific flags */ - tdb_flags &= TDB_SEQNUM|TDB_VOLATILE| - TDB_MUTEX_LOCKING|TDB_CLEAR_IF_FIRST; + data.dptr = (uint8_t *)&db_ctdb->db_id; + data.dsize = sizeof(db_ctdb->db_id); + + ret = ctdbd_control_local(conn, CTDB_CONTROL_DB_OPEN_FLAGS, + 0, 0, data, NULL, &data, &cstatus); + if (ret != 0) { + DBG_ERR(" ctdb control for db_open_flags " + "failed: %s\n", strerror(ret)); + TALLOC_FREE(result); + return NULL; + } + + if (cstatus != 0 || data.dsize != sizeof(int)) { + DBG_ERR("ctdb_control for db_open_flags failed\n"); + TALLOC_FREE(result); + return NULL; + } + + tdb_flags = *(int *)data.dptr; if (!result->persistent) { ret = ctdb_async_ctx_init(NULL, messaging_tevent_context(msg_ctx)); -- 2.13.3 From d74c16be252f411007490f52fb6fed6d983b3845 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Wed, 19 Jul 2017 12:04:35 +1000 Subject: [PATCH 7/7] dbwrap_ctdb: Fix calculation of persistent flag BUG: https://bugzilla.samba.org/show_bug.cgi?id=12891 Signed-off-by: Amitay Isaacs Reviewed-by: Ralph Boehme (cherry picked from commit f7daa453045c787ddab6e04c1fdaa386c231371f) --- source3/lib/dbwrap/dbwrap_ctdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c index 6bdaab000a9..a5ac2b27074 100644 --- a/source3/lib/dbwrap/dbwrap_ctdb.c +++ b/source3/lib/dbwrap/dbwrap_ctdb.c @@ -1780,7 +1780,7 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx, char *db_path; struct loadparm_context *lp_ctx; TDB_DATA data; - bool persistent = (tdb_flags & TDB_CLEAR_IF_FIRST); + bool persistent = (tdb_flags & TDB_CLEAR_IF_FIRST) == 0; int32_t cstatus; int ret; -- 2.13.3