Skip to content

Commit

Permalink
Added debug_crash() method to high priority service interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
temeo committed Jul 16, 2018
1 parent 4418627 commit 0efec1b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
5 changes: 3 additions & 2 deletions dbsim/db_high_priority_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ namespace db
void switch_execution_context(wsrep::high_priority_service&) override
{ }
int log_dummy_write_set(const wsrep::ws_handle&,
const wsrep::ws_meta&)
const wsrep::ws_meta&) override
{ return 0; }
bool is_replaying() const;
bool is_replaying() const override;
void debug_crash(const char*) override { }
private:
high_priority_service(const high_priority_service&);
high_priority_service& operator=(const high_priority_service&);
Expand Down
5 changes: 5 additions & 0 deletions include/wsrep/high_priority_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ namespace wsrep
virtual bool is_replaying() const = 0;

bool must_exit() const { return must_exit_; }

/**
* Debug facility to crash the server at given point.
*/
virtual void debug_crash(const char* crash_point) = 0;
protected:
wsrep::server_state& server_state_;
bool must_exit_;
Expand Down
17 changes: 14 additions & 3 deletions src/server_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ static int apply_fragment(wsrep::server_state& server_state,
{
wsrep::high_priority_switch sw(high_priority_service,
streaming_applier);

ret = streaming_applier.apply_write_set(ws_meta, data);
streaming_applier.after_apply();
}
high_priority_service.debug_crash("crash_apply_cb_before_append_frag");
ret = ret || high_priority_service.append_fragment_and_commit(
ws_handle, ws_meta, data);
high_priority_service.debug_crash("crash_apply_cb_after_append_frag");
high_priority_service.after_apply();
return ret;
}
Expand All @@ -67,9 +70,17 @@ static int commit_fragment(wsrep::server_state& server_state,
{
wsrep::high_priority_switch sw(
high_priority_service, *streaming_applier);
ret = streaming_applier->apply_write_set(ws_meta, data) ||
streaming_applier->remove_fragments(ws_meta) ||
streaming_applier->commit(ws_handle, ws_meta);
ret = streaming_applier->apply_write_set(ws_meta, data);
streaming_applier->debug_crash(
"crash_apply_cb_before_fragment_removal");
ret = ret || streaming_applier->remove_fragments(ws_meta);
streaming_applier->debug_crash(
"crash_apply_cb_after_fragment_removal");
streaming_applier->debug_crash(
"crash_commit_cb_before_last_fragment_commit");
ret = ret || streaming_applier->commit(ws_handle, ws_meta);
streaming_applier->debug_crash(
"crash_commit_cb_last_fragment_commit_success");
streaming_applier->after_apply();
}
if (ret == 0)
Expand Down
2 changes: 2 additions & 0 deletions test/mock_high_priority_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ namespace wsrep
const wsrep::ws_meta&)
WSREP_OVERRIDE { return 0; }
bool is_replaying() const WSREP_OVERRIDE { return replaying_; }
void debug_crash(const char*) WSREP_OVERRIDE { /* Not in unit tests*/}

wsrep::mock_client_state* client_state()
{
return client_state_;
Expand Down

0 comments on commit 0efec1b

Please sign in to comment.