Skip to content
Open
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
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "wsrep-API/v26"]
path = wsrep-API/v26
url = https://github.com/percona/wsrep-API.git
branch = percona-4.x-8.0
url = https://github.com/jaideepkarande/wsrep-API.git
branch = PXC-4799-4x-80
1 change: 1 addition & 0 deletions include/wsrep/provider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ namespace wsrep
virtual int resync() = 0;

virtual wsrep::seqno pause() = 0;
virtual wsrep::seqno try_pause() = 0;
virtual int resume() = 0;

// Applier interface
Expand Down
12 changes: 12 additions & 0 deletions include/wsrep/server_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,18 @@ namespace wsrep
*/
wsrep::seqno desync_and_pause();

/**
* Try to desync and pause the provider without blocking.
*
* This call relies on provider-level try_pause() which should return
* immediately with a negative value (e.g. -EAGAIN) if pausing would
* block. On such condition this method returns undefined seqno.
*
* @return Pause seqno on success, undefined seqno if pausing would
* block or fails.
*/
wsrep::seqno try_desync_and_pause();

/**
* Resume and resync the provider on one go. Prior this
* call the provider must have been both desynced and paused,
Expand Down
76 changes: 76 additions & 0 deletions src/server_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,82 @@ wsrep::seqno wsrep::server_state::desync_and_pause()
return ret;
}

/*
In try_desync_and_pause function instead of calling
server_state::pause/try_pause we have merged 2 functions into one and added
pause pre-check first followed by desynch and actual try_pause.
So desync_and_pause and try_desync_and_pause functions are same just that
in try_desync_and_pause we call try_pause instead of pause and
handle the case when try_pause returns state where the pausing would block.
In that case we roll back the desync(refer pause, resume and
resume_and_resync function) and return undefined seqno to indicate failure.
If try_pause is successful then we return the pause seqno as before.
*/
wsrep::seqno wsrep::server_state::try_desync_and_pause()
{
wsrep::log_info() << "Attempting to desync and pause the provider (non-blocking)";

wsrep::unique_lock<wsrep::mutex> lock(mutex_);

if (!pause_seqno_.is_undefined())
{
wsrep::log_info() << "Provider already paused at: " << pause_seqno_;
return pause_seqno_;
}

if (state(lock) != s_synced)
{
wsrep::log_info() << "Cannot pause: server not in synced state";
return wsrep::seqno::undefined();
}

while (pause_count_ > 0)
{
cond_.wait(lock);
if (!pause_seqno_.is_undefined())
{
wsrep::log_info() << "Provider already paused at: " << pause_seqno_;
return pause_seqno_;
}
}

++pause_count_;
assert(pause_seqno_.is_undefined());
lock.unlock();

// Desync may fail transiently; tolerate if we can pause.
bool const desync_successful(desync() == 0);
if (!desync_successful)
{
WSREP_LOG_DEBUG(wsrep::log::debug_log_level(),
wsrep::log::debug_level_server_state,
"Failed to desync server before try_pause");
}

wsrep::seqno ret(provider().try_pause());

lock.lock();
if (ret.get() < 0)
{
--pause_count_;
cond_.notify_all(); // Not sure this is needed since we never paused.
lock.unlock();

if (desync_successful)
{
resync();
}
return wsrep::seqno::undefined();
}

pause_seqno_ = ret;
desynced_on_pause_ = desync_successful;
lock.unlock();

wsrep::log_info() << "Provider paused at: " << ret;
return ret;
}

void wsrep::server_state::resume_and_resync()
{
wsrep::log_info() << "Resuming and resyncing the provider";
Expand Down
7 changes: 7 additions & 0 deletions src/wsrep_provider_v26.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,13 @@ wsrep::seqno wsrep::wsrep_provider_v26::pause()
return wsrep::seqno(wsrep_->pause(wsrep_));
}

wsrep::seqno wsrep::wsrep_provider_v26::try_pause()
{
return (wsrep_ && wsrep_->try_pause)
? wsrep::seqno(wsrep_->try_pause(wsrep_))
: wsrep::seqno::undefined();
}

int wsrep::wsrep_provider_v26::resume()
{
return (wsrep_->resume(wsrep_) != WSREP_OK);
Expand Down
1 change: 1 addition & 0 deletions src/wsrep_provider_v26.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace wsrep
int desync() WSREP_OVERRIDE;
int resync() WSREP_OVERRIDE;
wsrep::seqno pause() WSREP_OVERRIDE;
wsrep::seqno try_pause() WSREP_OVERRIDE;
int resume() WSREP_OVERRIDE;

enum wsrep::provider::status
Expand Down
2 changes: 1 addition & 1 deletion wsrep-API/v26
Submodule v26 updated 2 files
+9 −0 wsrep_api.h
+7 −0 wsrep_dummy.c