1
0
Fork 0

issue 493.2: trigger termination of long-running consolidation on shutdown request (#6955)

This commit is contained in:
Vasiliy 2018-10-18 23:21:23 +03:00 committed by Andrey Abramov
parent a50468f4b1
commit 6ae3bb056c
3 changed files with 24 additions and 3 deletions

View File

@ -556,7 +556,11 @@ if (CMAKE_COMPILER_IS_GNUCC)
endif ()
if (CMAKE_COMPILER_IS_GNUCC OR APPLE)
set(BASE_CXX_FLAGS "${BASE_CXX_FLAGS} -std=c++14")
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6)
set(BASE_CXX_FLAGS "${BASE_CXX_FLAGS} -std=c++11")
else()
set(BASE_CXX_FLAGS "${BASE_CXX_FLAGS} -std=c++14")
endif()
endif ()
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")

View File

@ -434,6 +434,7 @@ bool consolidateCleanupStore(
irs::directory& directory,
irs::index_writer& writer,
arangodb::iresearch::IResearchViewMeta::ConsolidationPolicy const& policy,
irs::merge_writer::flush_progress_t const& progress,
bool runCleanupAfterConsolidation,
arangodb::iresearch::IResearchView const& view,
const char* storeName
@ -450,7 +451,7 @@ bool consolidateCleanupStore(
<< "registering consolidation policy '" << policy.properties().toString() << "' for store '" << storeName << "' with arangosearch view '" << view.name() << "' run id '" << size_t(&runId) << "'";
try {
writer.consolidate(policy.policy());
writer.consolidate(policy.policy(), nullptr, progress);
} catch (arangodb::basics::Exception const& e) {
LOG_TOPIC(WARN, arangodb::iresearch::TOPIC)
<< "caught exception during registration of consolidation policy '" << policy.properties().toString() << "' for store '" << storeName << "' with arangosearch view '" << view.name() << "': " << e.code() << " " << e.what();
@ -751,8 +752,10 @@ IResearchView::IResearchView(
struct State : public IResearchViewMeta {
size_t _cleanupIntervalCount{ 0 };
std::chrono::system_clock::time_point _last{ std::chrono::system_clock::now() };
irs::merge_writer::flush_progress_t _progress;
} state;
state._progress = [this]()->bool { return !_asyncTerminate.load(); };
_asyncFeature->async(
self(),
[this, state](size_t& timeoutMsec, bool) mutable ->bool {
@ -797,6 +800,7 @@ IResearchView::IResearchView(
*_storePersisted._directory,
*_storePersisted._writer,
state._consolidationPolicy,
state._progress,
runCleanupAfterConsolidation,
*this,
"persistent store")
@ -2151,4 +2155,4 @@ void IResearchView::verifyKnownCollections() {
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

View File

@ -493,6 +493,19 @@ SECTION("test_cleanup") {
CHECK(view->memory() <= memory);
}
SECTION("test_consolidate") {
auto viewCreateJson = arangodb::velocypack::Parser::fromJson("{ \"name\": \"testView\", \"type\":\"arangosearch\", \"consolidationIntervalMsec\": 1000 }");
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1, "testVocbase");
auto logicalView = vocbase.createView(viewCreateJson->slice());
REQUIRE((false == !logicalView));
// FIXME TODO write test to check that long-running consolidation aborts on view drop
// 1. create view with policy that blocks
// 2. start policy
// 3. drop view
// 4. unblock policy
// 5. ensure view drops immediately
}
SECTION("test_drop") {
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1, "testVocbase");
std::string dataPath = ((((irs::utf8_path()/=s.testFilesystemPath)/=std::string("databases"))/=(std::string("database-") + std::to_string(vocbase.id())))/=std::string("arangosearch-123")).utf8();