1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-04-19 21:02:17 +03:00
wsrep-lib/dbsim/db_client_service.hpp
Teemu Ollakka 49deb7da98 Refactored checks for transaction state before certification
Moved the check for transaction state before certification step
into separate method abort_or_interrupted() which will check the state
and adjust state and client_state error status accordingly.

Moved the check for abort_or_interrupted() to happen before
the state is changed to certifying and write set data is appended.
This makes the check atomic and reduces the probability of race
conditions. After this check we rely on provider side transaction
state management and error reporting until the certification step
is over.

Change to public API: Pass client_state mutex wrappend in unique_lock
object to client_service::interrupted() call. This way the DBMS side
has a control to the lock object in case it needs to unlock it
temporarily. The underlying mutex will always be locked when the lock
object is passed via interrupted() call.

Other: Allow server_state change from donor to connected. This may
happen if the joiner crashes during SST and the provider reports
it before the DBMS side SST mechanism detects the error.
2019-02-19 22:26:45 +02:00

75 lines
2.2 KiB
C++

/*
* Copyright (C) 2018 Codership Oy <info@codership.com>
*
* This file is part of wsrep-lib.
*
* Wsrep-lib is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Wsrep-lib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with wsrep-lib. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef WSREP_DB_CLIENT_SERVICE_HPP
#define WSREP_DB_CLIENT_SERVICE_HPP
#include "wsrep/client_service.hpp"
#include "wsrep/transaction.hpp"
namespace db
{
class client;
class client_state;
class client_service : public wsrep::client_service
{
public:
client_service(db::client& client);
bool interrupted(wsrep::unique_lock<wsrep::mutex>&)
const override
{ return false; }
void reset_globals() override { }
void store_globals() override { }
int prepare_data_for_replication() override
{
return 0;
}
void cleanup_transaction() override { }
size_t bytes_generated() const override
{
return 0;
}
bool statement_allowed_for_streaming() const override
{
return true;
}
int prepare_fragment_for_replication(wsrep::mutable_buffer&) override
{
return 0;
}
int remove_fragments() override { return 0; }
int bf_rollback() override;
void will_replay() override { }
void wait_for_replayers(wsrep::unique_lock<wsrep::mutex>&) override { }
enum wsrep::provider::status replay()
override;
void emergency_shutdown() override { ::abort(); }
void debug_sync(const char*) override { }
void debug_crash(const char*) override { }
private:
db::client& client_;
wsrep::client_state& client_state_;
};
}
#endif // WSREP_DB_CLIENT_SERVICE_HPP