BIND 10 trac2862, updated. d8183b83d92016696106a6665fde369fa7d49779 [2862] Abort on bad segment reset
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Jul 23 11:34:58 UTC 2013
The branch, trac2862 has been updated
via d8183b83d92016696106a6665fde369fa7d49779 (commit)
via 9cccfbbc4e13274cc1c5750704f03fbc577189ef (commit)
from f1c0d7070d9a3968ff900663bffcba20e53851b0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit d8183b83d92016696106a6665fde369fa7d49779
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Jul 23 13:33:35 2013 +0200
[2862] Abort on bad segment reset
commit 9cccfbbc4e13274cc1c5750704f03fbc577189ef
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Jul 23 13:08:28 2013 +0200
[2862] Signal if segment was reset by result
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/auth_messages.mes | 18 ++++++++-----
src/bin/auth/datasrc_clients_mgr.h | 21 ++++++++++-----
.../auth/tests/datasrc_clients_builder_unittest.cc | 27 +++++++++++++-------
src/lib/datasrc/client_list.cc | 5 ++--
src/lib/datasrc/client_list.h | 3 ++-
src/lib/datasrc/tests/client_list_unittest.cc | 10 +++++++-
6 files changed, 58 insertions(+), 26 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/auth/auth_messages.mes b/src/bin/auth/auth_messages.mes
index 7a36a81..b21fb50 100644
--- a/src/bin/auth/auth_messages.mes
+++ b/src/bin/auth/auth_messages.mes
@@ -147,19 +147,25 @@ the data source clients, and is now running with the new configuration.
% AUTH_DATASRC_CLIENTS_BUILDER_SEGMENT_BAD_CLASS invalid RRclass %1 at segment update
A memory segment update message was sent to the authoritative server. But the
-class contained there is no valid class, so the update is dropped. This is
-likely a bug in the code.
+class contained there is no valid class. This means the system is in
+inconsistent state and the authoritative server aborts to minimise the problem
+This is likely a bug in the code.
% AUTH_DATASRC_CLIENTS_BUILDER_SEGMENT_ERROR error updating the memory segment: %1
The authoritative server tried to update the memory segment. But the update
-failed. The update is dropped. This is likely a bug in the code.
+failed. The authoritative server aborts to avoid system inconsistency. This is
+likely a bug in the code.
+
+% AUTH_DATASRC_CLIENTS_BUILDER_SEGMENT_NO_DATASRC there's no data source named %2 in class %1
+The authoritative server was asked to update the memory segment of the given
+data source. The authoritative server aborts as this means the system is in
+inconsistent state. This is likely a bug in the code.
% AUTH_DATASRC_CLIENTS_BUILDER_SEGMENT_UNKNOWN_CLASS unknown class %1 at segment update
A memory segment update message was sent to the authoritative server. The class
name for which the update should happen is valid, but no client lists are
-configured for that class. The update is dropped. This may be caused by a bug
-in the code or by a temporary inconsistancy between the memory manager and the
-authoritative server after change of configuration.
+configured for that class. The system is in inconsistent state and the
+authoritative server aborts. This may be caused by a bug in the code.
% AUTH_DATASRC_CLIENTS_BUILDER_STARTED data source builder thread started
A separate thread for maintaining data source clients has been started.
diff --git a/src/bin/auth/datasrc_clients_mgr.h b/src/bin/auth/datasrc_clients_mgr.h
index 6ea51fa..b03ec01 100644
--- a/src/bin/auth/datasrc_clients_mgr.h
+++ b/src/bin/auth/datasrc_clients_mgr.h
@@ -638,22 +638,29 @@ private:
const boost::shared_ptr<isc::datasrc::ConfigurableClientList>&
list = (**clients_map_)[rrclass];
if (!list) {
- LOG_ERROR(auth_logger,
+ LOG_FATAL(auth_logger,
AUTH_DATASRC_CLIENTS_BUILDER_SEGMENT_UNKNOWN_CLASS)
.arg(rrclass);
- return;
+ std::terminate();
+ }
+ if (!list->resetMemorySegment(name,
+ isc::datasrc::memory::ZoneTableSegment::READ_ONLY,
+ segment_params)) {
+ LOG_FATAL(auth_logger,
+ AUTH_DATASRC_CLIENTS_BUILDER_SEGMENT_NO_DATASRC)
+ .arg(rrclass).arg(name);
+ std::terminate();
}
- list->resetMemorySegment(name,
- isc::datasrc::memory::ZoneTableSegment::READ_ONLY,
- segment_params);
} catch (const isc::dns::InvalidRRClass& irce) {
- LOG_ERROR(auth_logger,
+ LOG_FATAL(auth_logger,
AUTH_DATASRC_CLIENTS_BUILDER_SEGMENT_BAD_CLASS)
.arg(arg->get("data-source-class"));
+ std::terminate();
} catch (const isc::Exception& e) {
- LOG_ERROR(auth_logger,
+ LOG_FATAL(auth_logger,
AUTH_DATASRC_CLIENTS_BUILDER_SEGMENT_ERROR)
.arg(e.what());
+ std::terminate();
}
}
diff --git a/src/bin/auth/tests/datasrc_clients_builder_unittest.cc b/src/bin/auth/tests/datasrc_clients_builder_unittest.cc
index f3e098a..fc9e134 100644
--- a/src/bin/auth/tests/datasrc_clients_builder_unittest.cc
+++ b/src/bin/auth/tests/datasrc_clients_builder_unittest.cc
@@ -710,28 +710,37 @@ TEST_F(DataSrcClientsBuilderTest,
const ElementPtr bad_name = Element::fromJSON(command_args->toWire());
// Set bad name
bad_name->set("data-source-name", Element::create("bad"));
- // Nothing breaks
- builder.handleCommand(Command(SEGMENT_INFO_UPDATE, bad_name,
- FinishedCallback()));
+ EXPECT_DEATH_IF_SUPPORTED({
+ builder.handleCommand(Command(SEGMENT_INFO_UPDATE, bad_name,
+ FinishedCallback()));
+ }, "");
// Another copy with wrong class
const ElementPtr bad_class = Element::fromJSON(command_args->toWire());
// Set bad class
bad_class->set("data-source-class", Element::create("bad"));
- // Nothing breaks
- builder.handleCommand(Command(SEGMENT_INFO_UPDATE, bad_class,
- FinishedCallback()));
+ // Aborts (we are out of sync somehow).
+ EXPECT_DEATH_IF_SUPPORTED({
+ builder.handleCommand(Command(SEGMENT_INFO_UPDATE, bad_class,
+ FinishedCallback()));
+ }, "");
// Class CH is valid, but not present.
bad_class->set("data-source-class", Element::create("CH"));
- // Nothing breaks
- builder.handleCommand(Command(SEGMENT_INFO_UPDATE, bad_class,
- FinishedCallback()));
+ EXPECT_DEATH_IF_SUPPORTED({
+ builder.handleCommand(Command(SEGMENT_INFO_UPDATE, bad_class,
+ FinishedCallback()));
+ }, "");
// And break the segment params
const ElementPtr bad_params = Element::fromJSON(command_args->toWire());
bad_params->set("segment-params",
Element::fromJSON("{\"mapped-file\": \"/bad/file\"}"));
+
+ EXPECT_DEATH_IF_SUPPORTED({
+ builder.handleCommand(Command(SEGMENT_INFO_UPDATE, bad_class,
+ FinishedCallback()));
+ }, "");
}
} // unnamed namespace
diff --git a/src/lib/datasrc/client_list.cc b/src/lib/datasrc/client_list.cc
index 4fe1eb3..531821c 100644
--- a/src/lib/datasrc/client_list.cc
+++ b/src/lib/datasrc/client_list.cc
@@ -330,7 +330,7 @@ ConfigurableClientList::findInternal(MutableResult& candidate,
// and the need_updater parameter is true, get the zone there.
}
-void
+bool
ConfigurableClientList::resetMemorySegment
(const std::string& datasrc_name,
ZoneTableSegment::MemorySegmentOpenMode mode,
@@ -340,9 +340,10 @@ ConfigurableClientList::resetMemorySegment
if (info.name_ == datasrc_name) {
ZoneTableSegment& segment = *info.ztable_segment_;
segment.reset(mode, config_params);
- break;
+ return true;
}
}
+ return false;
}
ConfigurableClientList::ZoneWriterPair
diff --git a/src/lib/datasrc/client_list.h b/src/lib/datasrc/client_list.h
index b4dadff..77c2fd5 100644
--- a/src/lib/datasrc/client_list.h
+++ b/src/lib/datasrc/client_list.h
@@ -385,7 +385,8 @@ public:
/// \param datasrc_name The name of the data source whose segment to reset
/// \param mode The open mode for the new memory segment
/// \param config_params The configuration for the new memory segment.
- void resetMemorySegment
+ /// \return If the data source was found and reset.
+ bool resetMemorySegment
(const std::string& datasrc_name,
memory::ZoneTableSegment::MemorySegmentOpenMode mode,
isc::data::ConstElementPtr config_params);
diff --git a/src/lib/datasrc/tests/client_list_unittest.cc b/src/lib/datasrc/tests/client_list_unittest.cc
index eb69556..256e2ed 100644
--- a/src/lib/datasrc/tests/client_list_unittest.cc
+++ b/src/lib/datasrc/tests/client_list_unittest.cc
@@ -368,7 +368,8 @@ public:
const std::string& datasrc_name,
ZoneTableSegment::MemorySegmentOpenMode mode,
ConstElementPtr config_params) {
- list.resetMemorySegment(datasrc_name, mode, config_params);
+ EXPECT_TRUE(list.resetMemorySegment(datasrc_name, mode,
+ config_params));
}
virtual std::string getType() {
return ("mapped");
@@ -383,6 +384,13 @@ INSTANTIATE_TEST_CASE_P(ListTestMapped, ListTest,
#endif
+// Calling reset on empty list finds no data and returns false.
+TEST_P(ListTest, emptyReset) {
+ EXPECT_FALSE(list_->resetMemorySegment("Something",
+ memory::ZoneTableSegment::CREATE,
+ Element::create()));
+}
+
// Test the test itself
TEST_P(ListTest, selfTest) {
EXPECT_EQ(result::SUCCESS, ds_[0]->findZone(Name("example.org")).code);
More information about the bind10-changes
mailing list