Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pegasus_server: update rdsn to fix replica close problem; add cancel_… #49

Merged
merged 1 commit into from
May 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/server/pegasus_server_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <algorithm>
#include <boost/lexical_cast.hpp>
#include <rocksdb/convenience.h>
#include <rocksdb/table.h>
#include <rocksdb/utilities/checkpoint.h>
#include <dsn/utility/utils.h>
Expand Down Expand Up @@ -1810,7 +1811,7 @@ ::dsn::error_code pegasus_server_impl::start(int argc, char **argv)
_is_open = true;

dinfo("%s: start the updating sstsize timer task", replica_name());
::dsn::tasking::enqueue_timer(
_updating_rocksdb_sstsize_timer_task = ::dsn::tasking::enqueue_timer(
LPC_UPDATING_ROCKSDB_SSTSIZE,
&_tracker,
[this]() { this->updating_rocksdb_sstsize(); },
Expand All @@ -1825,6 +1826,12 @@ ::dsn::error_code pegasus_server_impl::start(int argc, char **argv)
}
}

void pegasus_server_impl::cancel_background_work(bool wait)
{
dassert(_db != nullptr, "");
rocksdb::CancelAllBackgroundWork(_db, wait);
}

::dsn::error_code pegasus_server_impl::stop(bool clear_state)
{
if (!_is_open) {
Expand All @@ -1842,10 +1849,15 @@ ::dsn::error_code pegasus_server_impl::stop(bool clear_state)
}
}

_context_cache.clear();
// stop all tracked tasks when pegasus server is stopped.
if (_updating_rocksdb_sstsize_timer_task != nullptr) {
_updating_rocksdb_sstsize_timer_task->cancel(true);
_updating_rocksdb_sstsize_timer_task = nullptr;
}
_tracker.cancel_outstanding_tasks();

_context_cache.clear();

_is_open = false;
delete _db;
_db = nullptr;
Expand Down
3 changes: 3 additions & 0 deletions src/server/pegasus_server_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class pegasus_server_impl : public ::dsn::apps::rrdb_service
// - ERR_LOCAL_APP_FAILURE
virtual ::dsn::error_code start(int argc, char **argv) override;

virtual void cancel_background_work(bool wait) override;

// returns:
// - ERR_OK
// - ERR_FILE_OPERATION_FAILED
Expand Down Expand Up @@ -247,6 +249,7 @@ class pegasus_server_impl : public ::dsn::apps::rrdb_service

pegasus_context_cache _context_cache;

::dsn::task_ptr _updating_rocksdb_sstsize_timer_task;
uint32_t _updating_rocksdb_sstsize_interval_seconds;

pagasus_manual_compact_service _manual_compact_svc;
Expand Down