[SCM] CTDB repository - branch master updated - ctdb-1.12-211-g9b85aa1
Ronnie Sahlberg
sahlberg at samba.org
Mon Feb 20 13:13:26 MST 2012
The branch, master has been updated
via 9b85aa1aa14091dc1de470a587f7c054b9e40078 (commit)
via 9e372a08c40087e6b5335aa298e94d88273566a5 (commit)
via b3307d78fd15f446b423f8cdd1e403f89fbe8ac8 (commit)
via 5990fe65a9cc37933ceff15d4cb2ab3b3a0addb6 (commit)
from 0fd3bf919b1b8e5aaa98444c306c6770a6a3209f (commit)
http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 9b85aa1aa14091dc1de470a587f7c054b9e40078
Merge: 0fd3bf919b1b8e5aaa98444c306c6770a6a3209f 9e372a08c40087e6b5335aa298e94d88273566a5
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Tue Feb 21 07:12:50 2012 +1100
Merge branch 'master' of 10.1.1.27:/shared/ctdb/ctdb-master
commit 9e372a08c40087e6b5335aa298e94d88273566a5
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Tue Feb 21 07:03:44 2012 +1100
READONLY: only send a control to schedule fast-vacuuming from child context iff we have a connection open to the main daemon
there are some child processes where we do not create a connection to the main daemon (switch_from_server_to_client()) because it is expensive to set up and we normally might not need to talk to the daemon at all via a domainsocket.
but we might want to still call to ctdb_ltdb_store() from such chil processes.
commit b3307d78fd15f446b423f8cdd1e403f89fbe8ac8
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Tue Feb 21 06:54:09 2012 +1100
READONLY: dont schedule for fast vacuum deletion if any of the readonly record flags are set
commit 5990fe65a9cc37933ceff15d4cb2ab3b3a0addb6
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Tue Feb 21 06:49:18 2012 +1100
Revert "ReadOnly: We can not use ctdb_ltdb_store from a client/child context since"
This reverts commit 11dee7f3f881494cf5089d6c69fd40e74f07e670.
Try to solve this a different way so that ctdb_ltb_store() becomes safe to use also from child context
-----------------------------------------------------------------------
Summary of changes:
client/ctdb_client.c | 4 +++-
common/ctdb_util.c | 1 +
include/ctdb_private.h | 3 +++
server/ctdb_ltdb_server.c | 5 +++--
server/ctdb_persistent.c | 33 ++++++++++-----------------------
server/ctdb_vacuum.c | 10 +++++++++-
6 files changed, 29 insertions(+), 27 deletions(-)
Changeset truncated at 500 lines:
diff --git a/client/ctdb_client.c b/client/ctdb_client.c
index 0d0f2fe..1b41439 100644
--- a/client/ctdb_client.c
+++ b/client/ctdb_client.c
@@ -4123,7 +4123,9 @@ int switch_from_server_to_client(struct ctdb_context *ctdb, const char *fmt, ...
return -1;
}
- return 0;
+ ctdb->can_send_controls = true;
+
+ return 0;
}
/*
diff --git a/common/ctdb_util.c b/common/ctdb_util.c
index bb32b6a..dadaf18 100644
--- a/common/ctdb_util.c
+++ b/common/ctdb_util.c
@@ -346,6 +346,7 @@ pid_t ctdb_fork(struct ctdb_context *ctdb)
if (ctdb->do_setsched) {
ctdb_restore_scheduler(ctdb);
}
+ ctdb->can_send_controls = false;
}
return pid;
}
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index f420e6c..272b94a 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -483,6 +483,9 @@ struct ctdb_context {
/* Used to defer db attach requests while in recovery mode */
struct ctdb_deferred_attach_context *deferred_attach;
+
+ /* if we are a child process, do we have a domain socket to send controls on */
+ bool can_send_controls;
};
struct ctdb_db_context {
diff --git a/server/ctdb_ltdb_server.c b/server/ctdb_ltdb_server.c
index e699c2a..8e183e8 100644
--- a/server/ctdb_ltdb_server.c
+++ b/server/ctdb_ltdb_server.c
@@ -83,7 +83,7 @@ static int ctdb_ltdb_store_server(struct ctdb_db_context *ctdb_db,
*/
if (data.dsize != 0) {
keep = true;
- } else if (header->flags & (CTDB_REC_RO_HAVE_DELEGATIONS|CTDB_REC_RO_HAVE_READONLY)) {
+ } else if (header->flags & (CTDB_REC_RO_HAVE_DELEGATIONS|CTDB_REC_RO_HAVE_READONLY|CTDB_REC_RO_REVOKING_READONLY|CTDB_REC_RO_REVOKE_COMPLETE)) {
keep = true;
} else if (ctdb_db->persistent) {
keep = true;
@@ -128,7 +128,8 @@ static int ctdb_ltdb_store_server(struct ctdb_db_context *ctdb_db,
if (keep) {
if ((data.dsize == 0) &&
!ctdb_db->persistent &&
- (ctdb_db->ctdb->pnn == header->dmaster))
+ (ctdb_db->ctdb->pnn == header->dmaster) &&
+ !(header->flags & (CTDB_REC_RO_HAVE_DELEGATIONS|CTDB_REC_RO_HAVE_READONLY|CTDB_REC_RO_REVOKING_READONLY|CTDB_REC_RO_REVOKE_COMPLETE)))
{
schedule_for_deletion = true;
}
diff --git a/server/ctdb_persistent.c b/server/ctdb_persistent.c
index 0f4f4da..dd8d479 100644
--- a/server/ctdb_persistent.c
+++ b/server/ctdb_persistent.c
@@ -456,12 +456,12 @@ static int ctdb_persistent_store(struct ctdb_persistent_write_state *state)
}
for (i=0;i<m->count;i++) {
- struct ctdb_ltdb_header *oldheader;
- struct ctdb_ltdb_header *header;
+ struct ctdb_ltdb_header oldheader;
+ struct ctdb_ltdb_header header;
TDB_DATA key, data, olddata;
TALLOC_CTX *tmp_ctx = talloc_new(state);
- rec = ctdb_marshall_loop_next(m, rec, NULL, NULL, &key, &data);
+ rec = ctdb_marshall_loop_next(m, rec, NULL, &header, &key, &data);
if (rec == NULL) {
DEBUG(DEBUG_ERR,("Failed to get next record %d for db_id 0x%08x in ctdb_persistent_store\n",
@@ -469,42 +469,29 @@ static int ctdb_persistent_store(struct ctdb_persistent_write_state *state)
talloc_free(tmp_ctx);
goto failed;
}
- header = (struct ctdb_ltdb_header *)&data.dptr[0];
/* fetch the old header and ensure the rsn is less than the new rsn */
- olddata = tdb_fetch(state->ctdb_db->ltdb->tdb, key);
- if (olddata.dptr == NULL) {
+ ret = ctdb_ltdb_fetch(state->ctdb_db, key, &oldheader, tmp_ctx, &olddata);
+ if (ret != 0) {
DEBUG(DEBUG_ERR,("Failed to fetch old record for db_id 0x%08x in ctdb_persistent_store\n",
state->ctdb_db->db_id));
talloc_free(tmp_ctx);
goto failed;
}
- if (olddata.dsize < sizeof(struct ctdb_ltdb_header)) {
- DEBUG(DEBUG_ERR,("Not enough header for record for db_id 0x%08x in ctdb_persistent_store\n",
- state->ctdb_db->db_id));
- talloc_free(tmp_ctx);
- free(olddata.dptr);
- goto failed;
- }
- oldheader = (struct ctdb_ltdb_header *)&olddata.dptr[0];
- if (oldheader->rsn >= header->rsn &&
- (olddata.dsize != data.dsize ||
- memcmp(&olddata.dptr[sizeof(struct ctdb_ltdb_header)],
- &data.dptr[sizeof(struct ctdb_ltdb_header)],
- data.dsize - sizeof(struct ctdb_ltdb_header)) != 0)) {
+ if (oldheader.rsn >= header.rsn &&
+ (olddata.dsize != data.dsize ||
+ memcmp(olddata.dptr, data.dptr, data.dsize) != 0)) {
DEBUG(DEBUG_CRIT,("existing header for db_id 0x%08x has larger RSN %llu than new RSN %llu in ctdb_persistent_store\n",
state->ctdb_db->db_id,
- (unsigned long long)oldheader->rsn, (unsigned long long)header->rsn));
+ (unsigned long long)oldheader.rsn, (unsigned long long)header.rsn));
talloc_free(tmp_ctx);
- free(olddata.dptr);
goto failed;
}
talloc_free(tmp_ctx);
- free(olddata.dptr);
- ret = tdb_store(state->ctdb_db->ltdb->tdb, key, data, TDB_REPLACE);
+ ret = ctdb_ltdb_store(state->ctdb_db, key, &header, data);
if (ret != 0) {
DEBUG(DEBUG_CRIT,("Failed to store record for db_id 0x%08x in ctdb_persistent_store\n",
state->ctdb_db->db_id));
diff --git a/server/ctdb_vacuum.c b/server/ctdb_vacuum.c
index ff37356..e0e1e3b 100644
--- a/server/ctdb_vacuum.c
+++ b/server/ctdb_vacuum.c
@@ -1560,8 +1560,16 @@ int32_t ctdb_local_schedule_for_deletion(struct ctdb_db_context *ctdb_db,
return ret;
}
- /* child process: send the main daemon a control */
+ /* if we dont have a connection to the daemon we can not send
+ a control. For example sometimes from update_record control child
+ process.
+ */
+ if (!ctdb_db->ctdb->can_send_controls) {
+ return -1;
+ }
+
+ /* child process: send the main daemon a control */
indata.dsize = offsetof(struct ctdb_control_schedule_for_deletion, key) + key.dsize;
indata.dptr = talloc_zero_array(ctdb_db, uint8_t, indata.dsize);
if (indata.dptr == NULL) {
--
CTDB repository
More information about the samba-cvs
mailing list