mirror of https://gitee.com/bigwinds/arangodb
issue 493.2: trigger termination of long-running consolidation on shutdown request (#6955)
This commit is contained in:
parent
a50468f4b1
commit
6ae3bb056c
|
@ -556,7 +556,11 @@ if (CMAKE_COMPILER_IS_GNUCC)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (CMAKE_COMPILER_IS_GNUCC OR APPLE)
|
if (CMAKE_COMPILER_IS_GNUCC OR APPLE)
|
||||||
|
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")
|
set(BASE_CXX_FLAGS "${BASE_CXX_FLAGS} -std=c++14")
|
||||||
|
endif()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
|
|
|
@ -434,6 +434,7 @@ bool consolidateCleanupStore(
|
||||||
irs::directory& directory,
|
irs::directory& directory,
|
||||||
irs::index_writer& writer,
|
irs::index_writer& writer,
|
||||||
arangodb::iresearch::IResearchViewMeta::ConsolidationPolicy const& policy,
|
arangodb::iresearch::IResearchViewMeta::ConsolidationPolicy const& policy,
|
||||||
|
irs::merge_writer::flush_progress_t const& progress,
|
||||||
bool runCleanupAfterConsolidation,
|
bool runCleanupAfterConsolidation,
|
||||||
arangodb::iresearch::IResearchView const& view,
|
arangodb::iresearch::IResearchView const& view,
|
||||||
const char* storeName
|
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) << "'";
|
<< "registering consolidation policy '" << policy.properties().toString() << "' for store '" << storeName << "' with arangosearch view '" << view.name() << "' run id '" << size_t(&runId) << "'";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
writer.consolidate(policy.policy());
|
writer.consolidate(policy.policy(), nullptr, progress);
|
||||||
} catch (arangodb::basics::Exception const& e) {
|
} catch (arangodb::basics::Exception const& e) {
|
||||||
LOG_TOPIC(WARN, arangodb::iresearch::TOPIC)
|
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();
|
<< "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 {
|
struct State : public IResearchViewMeta {
|
||||||
size_t _cleanupIntervalCount{ 0 };
|
size_t _cleanupIntervalCount{ 0 };
|
||||||
std::chrono::system_clock::time_point _last{ std::chrono::system_clock::now() };
|
std::chrono::system_clock::time_point _last{ std::chrono::system_clock::now() };
|
||||||
|
irs::merge_writer::flush_progress_t _progress;
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
|
state._progress = [this]()->bool { return !_asyncTerminate.load(); };
|
||||||
_asyncFeature->async(
|
_asyncFeature->async(
|
||||||
self(),
|
self(),
|
||||||
[this, state](size_t& timeoutMsec, bool) mutable ->bool {
|
[this, state](size_t& timeoutMsec, bool) mutable ->bool {
|
||||||
|
@ -797,6 +800,7 @@ IResearchView::IResearchView(
|
||||||
*_storePersisted._directory,
|
*_storePersisted._directory,
|
||||||
*_storePersisted._writer,
|
*_storePersisted._writer,
|
||||||
state._consolidationPolicy,
|
state._consolidationPolicy,
|
||||||
|
state._progress,
|
||||||
runCleanupAfterConsolidation,
|
runCleanupAfterConsolidation,
|
||||||
*this,
|
*this,
|
||||||
"persistent store")
|
"persistent store")
|
||||||
|
|
|
@ -493,6 +493,19 @@ SECTION("test_cleanup") {
|
||||||
CHECK(view->memory() <= memory);
|
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") {
|
SECTION("test_drop") {
|
||||||
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, 1, "testVocbase");
|
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();
|
std::string dataPath = ((((irs::utf8_path()/=s.testFilesystemPath)/=std::string("databases"))/=(std::string("database-") + std::to_string(vocbase.id())))/=std::string("arangosearch-123")).utf8();
|
||||||
|
|
Loading…
Reference in New Issue