[PATCH] Enable TDB mutexes by default in dbwrap and ctdb
Ralph Böhme
slow at samba.org
Tue Jul 11 19:58:55 UTC 2017
On Tue, Jul 11, 2017 at 04:05:45AM +1000, Amitay Isaacs wrote:
> Till we figure out if TDB_SEQNUM is required or not, here are the updated
> patches that maintain the existing behaviour.
the way tdb_flags is used as an in/out parameter is somewhat hard to follow.
What about the attached patchset that moves all the controls to the caller?
Cheerio!
-slow
-------------- next part --------------
From 0c23e7def419b1a1bde2593686a58bcd8651c658 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sun, 9 Jul 2017 16:20:11 +0200
Subject: [PATCH 1/6] ctdb: enable mutexes for volatile TDBs by default
Bug: https://bugzilla.samba.org/show_bug.cgi?id=12891
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
---
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 ed7a52d..14f6828 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 e75c65c..2d525c5 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 d0bb450..7b059b7 100644
--- a/ctdb/doc/ctdb-tunables.7.xml
+++ b/ctdb/doc/ctdb-tunables.7.xml
@@ -658,7 +658,7 @@
<refsect2>
<title>TDBMutexEnabled</title>
- <para>Default: 0</para>
+ <para>Default: 1</para>
<para>
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 1af1f50..3aceb73 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 f6010a4..fc8f42c 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.9.4
From 5bd9a561695a4662a220b56bdf0925591ca11105 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sun, 9 Jul 2017 16:23:20 +0200
Subject: [PATCH 2/6] dbwrap: enable mutexes by default for volatile TDBs
Bug: https://bugzilla.samba.org/show_bug.cgi?id=12891
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
---
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 55e0adb..801ebcb 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.9.4
From 3567e47c485aafcd997df82f871aba755961db52 Mon Sep 17 00:00:00 2001
From: Amitay Isaacs <amitay at gmail.com>
Date: Tue, 11 Jul 2017 00:38:59 +1000
Subject: [PATCH 3/6] 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 <amitay at gmail.com>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
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 3adb57d..d38789a 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.9.4
From 078214a66e28f1d1acf117713fdd2a8de90f80e2 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Tue, 11 Jul 2017 20:36:35 +0200
Subject: [PATCH 4/6] 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 <slow at samba.org>
---
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 d38789a..70d3d83 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 8e303e6..001d2c4 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.9.4
From 2e0cf247ab422b80124afb0a54824ceabba81f05 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Tue, 11 Jul 2017 20:41:43 +0200
Subject: [PATCH 5/6] 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 <slow at samba.org>
---
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 06fbcc3..38477d3 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 70d3d83..b81feca 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 001d2c4..07e35f8 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.9.4
From 23c0852f6232ee678d6f87e1ec4cec9564e3ba35 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Tue, 11 Jul 2017 21:35:17 +0200
Subject: [PATCH 6/6] dbwrap: Ask CTDB for local tdb open flags
Bug: https://bugzilla.samba.org/show_bug.cgi?id=12891
Signed-off-by: Ralph Boehme <slow at samba.org>
---
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 07e35f8..6bdaab0 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.9.4
More information about the samba-technical
mailing list