1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-04-25 17:42:30 +03:00

105 Commits

Author SHA1 Message Date
Teemu Ollakka
3b3429d8df Work around GCC 12 warning of uninitialized use
Use pointers to pass state objects to service constructors
to work around GCC 12 warning

  error: member ‘wsrep::mock_storage_service::client_state_’
  is used uninitialized
2023-02-27 13:32:55 +02:00
Teemu Ollakka
53638a8384 Removing assert() calls from public headers
Removed calls to assert() from public headers to have
full control when assertions are enabled in wsrep-lib
code regardless of parent project build configuration.
Moved methods containing assertions and non-trivial
code from headers into compilation units.
2023-02-26 10:12:49 +02:00
Teemu Ollakka
275a0af8c5 Return error codes instead of throwing exception
Changed server_state public methods sst_received() and wait_until_state()
to report errors as return value instead of throwing exceptions.
This was done to gradually get rid of public methods which report
errors via exceptions.

This change was part of MDEV-30419.
2023-01-18 13:47:10 +02:00
Daniele Sciascia
f8ff2cfdd4 Remove unnecessary include directives from the public interface 2022-11-10 10:31:36 +01:00
Daniele Sciascia
b5bddfe4db Fix warnings when -Wextra-semi is enabled
Also, add argument -Wextra-semi if supported by the compiler.
2022-09-20 13:41:07 +03:00
Alexey Yurchenko
6fd1fdf690 Use dedicated call and progress event for progress reporting in status
reporter interface.

Refs codership/wsrep-lib#174
2021-12-10 20:54:57 +02:00
Alexey Yurchenko
efb4aab090 Fixup to previous commit. Since dbsim implies that logger function is
static and global, it cannot use the reporter object, which must be a
non-static member of server class.
2021-09-12 17:22:47 +03:00
Alexey Yurchenko
4f1c201c9d Initial implementation of the status interface reporter object. 2021-09-05 15:42:54 +03:00
Teemu Ollakka
9318a50d18 Wsrep TLS service
This commit defines a TLS service interface. If the implementation is
provided by the application when the provider is loaded, appropriate
hooks are probed from the provider and the provider side hooks are
initialized after the provider is loaded.

A sample implementation to demostrate the use of TLS interface
is provided in dbsim/db_tls.cpp.

Also contains a change to thread service interface: The
thread exit virtual method was changed to function pointer
to allow thread exit path which does not involve C++.
2021-02-24 11:14:21 +02:00
Daniele Sciascia
b12bbd059c Support for replaying prepared XA transactions
This patch implments replaying for prepared XA transactions.
Replay may happen in the following cases:

1) The transaction is BF aborted in prepared state and is idle. In
that case, the transaction is handed over to rollbacker for replay.

2) The transaction is BF aborted while executing the
commit (i.e. before or after successful certification). In
which case the transaction replays itself from fragment storage.

3) The transaction is BF aborted while certifying its commit
fragment. This case is handled like replay for streaming transactions,
where the provider is directly involved and re-delivers the last
fragment.
2020-10-26 14:22:22 +01:00
Teemu Ollakka
96cd92164e Added gcc 10 build into travis configuration, fixed compilation errors. 2020-09-03 15:22:28 +03:00
Teemu Ollakka
593f737605 Configurable data payload size for dbsim. 2020-07-02 17:39:21 +03:00
Teemu Ollakka
dcdd7435bd Added sync-wait option to dbsim. 2020-01-15 11:49:24 +02:00
Daniele Sciascia
a17b65a25f Set server position after local certification failure
After a local certification failure, commit order is released without
the setting the current position in DBMS. Which results in diverging
positions between provider and DBMS, if clean shutdown happens right
after local certification failure.
This patch add method set_position() to server_service class. So that
wsrep-lib can instruct DBMS to set the current position after local
certification failure releases commit order.
2020-01-07 11:20:21 +01:00
Leandro Pacheco
5298d2340e error parameter to nbo calls and m_undefined for toi_mode
toi_mode is set only when actually inside phase one and two.
In between it goes back to m_undefined.
2019-12-08 12:52:36 +02:00
Teemu Ollakka
85a03394cc NBO applying
- High priority interface method to apply NBO begin, separate from
  apply_toi() in order to avoid implementation to force interpreting
  ws_meta flags.
- Method to put client_state into NBO mode when applying NBO begin.
  The client_state will process in m_local mode.
- Unit tests for applying NBO
2019-12-08 12:52:36 +02:00
Daniele Sciascia
66ee7bed1b Add type wsrep::xid
Create type `wsrep::xid`, and change all signatures that take
`std::string xid` to take `wsrep::xid xid`.
2019-10-18 09:36:18 +02:00
Daniele Sciascia
725f148ddb Remove query() method from wsrep::client_service interface 2019-10-16 10:16:39 +02:00
Daniele Sciascia
5d18ce3e75 Minimize client_service interface for XA
Remove methods `is_xa()`, `is_xa_prepare()`, and `xid()` from
client_service interface. Instead, transactions are explicitly
assigned their xid, through at start of XA.
2019-10-16 10:16:39 +02:00
Daniele Sciascia
052247144f Support recovery of XA transactions
* Add method `restore_prepared_transaction` to `client_state` class
  which restores a transaction state from storage given its xid.
* Add method `commit_or_rollback_by_xid` to terminate prepared XA
  transactions by xid.
* Make sure that transactions in prepared state are not rolled back
  when their master fails/partitions away.
2019-10-16 10:16:39 +02:00
Daniele Sciascia
68adbe35f6 Fixup unused parameter position in prepare_fragment_for_replication() 2019-10-16 10:15:55 +02:00
Daniele Sciascia
b614822f08 Fixup to previous commit
Fix client_service in test mock and dbsim to update signature of
method prepare_fragment_for_replication().
2019-10-16 10:15:55 +02:00
Leandro Pacheco
3389074e24 comments and style fixes 2019-10-16 10:15:55 +02:00
Leandro Pacheco
36346beab4 Fixes for XA transactions with streaming enabled
Changes mostly related to handling of XA PREPARE fragments
2019-10-16 10:15:55 +02:00
Daniele Sciascia
54b0eeee45 Add is_query() and is_xa() to dbsim/test client service implementations 2019-10-16 10:15:55 +02:00
Teemu Ollakka
eb4cf86c1e Implemented thread service support.
Added a wsrep::thread_service interface to allow application to
inject instrumented thread, mutex and condition variable implementation
for provider.

The interface is defined in include/wsrep/thread_service.hpp.
Sample implementation is provided in dbsim/db_threads.[h|c]pp.

This patch will also clean up some remaining dependencies to
wsrep-API compilation units so that the dependency to wsrep-API
is header only. This will extending the provider support to
later wsrep-API versions.
2019-10-14 09:30:15 +03:00
Teemu Ollakka
477a71dd46 Updated wsrep-API, added -Wconversion to compiler flags, fixed errors. 2019-10-11 09:56:07 +03:00
Alexey Yurchenko
0f676bd893 codership/wsrep-lib#104 Error voting support
- populate and pass real error description buffer to provider in case
   of applying error
 - return 0 from server_state::on_apply() if error voting confirmed
   consistency
 - remove fragments and rollback after fragment applying failure
 - always release streaming applier on commit or rollback
2019-07-15 03:48:55 +03:00
Teemu Ollakka
badf53a28d Return error code from high_priority_service::adopt_transaction()
Adopt transaction may need to start a new transaction on DBMS side,
allow returning an error if the transaction start fails.
2019-02-25 12:37:58 +02:00
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
mkaruza
e7d72ae7f6 codership/mariadb-wsrep#27 Galera cache encryption
* Created interface class for encryption support
* Implemented function for setting enc key to provider, callback function for encryption/decryption
2019-02-01 16:57:34 +01:00
Teemu Ollakka
9a32c72b48 Fixed dbsim replaying to conform current implementation
Inherited db::replayer_service from db::high_priority_service
and overrode after_apply() and is_replaying() methods to match
current state of library implementation. Changed
db::client_service::replay() to use db::replayer_service instead
of db::high_priority_service().
2019-01-25 13:44:25 +02:00
Teemu Ollakka
fc5f59d27e Implemented dbsim high prio service log_dummy_write_set()
The empty implementation of log_dummy_write_set() in dbsim
high priority service implementation left unreleased commit
order critical section behind whenever remote write set failed
certification. Added calls to do empty commit to release the
critical section.

Other:

Implemented ostream operator<< for wsrep:🧵:id, and added
printout of owning thread into transaction debug output.
2019-01-25 12:18:46 +02:00
Teemu Ollakka
f30d9c06ce Enhanced dbsim to store view and position in storage engine
Mimic real DBMS implementation by storing view and position
into storage engine.
2019-01-25 12:18:46 +02:00
Teemu Ollakka
a6b38d2428 codership/wsrep-lib#54 Service call to recover streaming appliers
Introduced server_service recover_streaming_appliers() interface
call which will be called in total order whenever streaming appliers
must be recovered. The call comes with two overloads, one which
can be called from client context (e.g. after SST has been received)
and the other from high priority context (e.g. view event handling).

The client context overload should be eventually be deprecated once
there is a mechanism to make provider signal that it has joined to
the cluster and will start applying events.
2019-01-21 17:00:08 +02:00
Teemu Ollakka
47263df442 Revert "codership/mariadb-wsrep#27 Galera cache encryption"
This reverts commit 7e9419e8111c3ca37d5e484282fe11a690eb2c6a.
2019-01-21 14:12:28 +02:00
Teemu Ollakka
476bcdb41e Revert "codership/mariadb-wsrep#27 Galera cache encryption fixup"
This reverts commit 043e8bc2ea782b973a5982a8980473cd51e4c574.
2019-01-21 14:12:10 +02:00
Alexey Yurchenko
043e8bc2ea codership/mariadb-wsrep#27 Galera cache encryption fixup
Fixup to enable/disable encryption on provider loading
2019-01-20 15:20:52 +02:00
mkaruza
7e9419e811 codership/mariadb-wsrep#27 Galera cache encryption
* Implemented encryption callback and enc_set_key
* Added pure virtual functions for encryption functionality
* Set enc key if provider was not loaded on time
2019-01-19 23:58:20 +01:00
Teemu Ollakka
ae734a33f8 Fixed compilation errors picked up by travis clang builds 2019-01-19 18:08:49 +02:00
Teemu Ollakka
55f6c63328 codership/wsrep-lib#52 Removed client_service do_2pc() 2019-01-16 19:33:32 +02:00
Teemu Ollakka
89b3561ad8 Read recovered position from sst_received() after initialization
In general the position where the storage recovers after a SST
cannot be known untile the recovery process is over. This in turn
means that the position cannot be known when the server_state
sst_received() method is called. Worked around the problem by
introducing get_position() method into server service which
can be used to get the position from stable storage after SST
has completed and the state has been recovered.
2019-01-15 12:35:06 +02:00
Alexey Yurchenko
fb14883547 Recover current view from state after SST.
When member joins the group and needs to receive an SST it won't
receive the corresponding menbership view event because the SST
happens after the event and will already include the effects of
all events ordered before it. The view then must be recovered from
the received state.

Minor renames and cleanups.

References codership/wsrep-lib#18
2018-11-12 12:47:42 +02:00
Teemu Ollakka
c7e8bfbdb5 codership/wsrep-lib#13 Fix dbsim to deal with provider generated server id
Dbsim has internal map of server objects for SST simulation.
This was mapped using server_id, which is not available
anymore when server object is constructed. Changed the dbsim to
use server name instead for internal mapping.
2018-11-09 00:42:05 +02:00
Alexey Yurchenko
ea9971d54b - Initialize member cluster ID only on connection to cluster and forget
it on disconnect.
 - Don't rely on own index from the view because the view may come from
   another member (IST/SST), instead always determine own index from own ID.

Refs codership/wsrep-lib#13
2018-11-09 00:42:05 +02:00
Teemu Ollakka
c0c977f9ab Added GPLv2 licence and copyright headers. 2018-10-15 15:14:22 +03:00
Teemu Ollakka
5e5906d598 Prefixed cmake WITH_ definitions with WSREP_LIB_ to avoid collisions
with superproject definitions.

Avoid using client_service::do_2pc() in before_commit() to
determine if 2pc is actually happening, will use transaction
states to deduce that. client_service::do_2pc() should be deprecated.

Fixed a compiler warning in db_high_priority_service.cpp.
2018-10-12 16:04:52 +03:00
Teemu Ollakka
61e0e30687 Remove fragments in before rollback for streaming transactions
which got BF aborted in total order.
2018-07-19 13:52:12 +03:00
Teemu Ollakka
b02200b1ef Fixes to streaming rollback
* Check fragment removal error code in prepare phase. It is possible
  that the transaction gets BF aborted during fragment removal.
* Mark fragment certified in certify_fragment() even if the provider
  returns cert failed error. With current wsrep-API error codes
  it may not be possible to distinquish certification failure
  and BF abort during fragment replication. This may also be a
  provider bug. As a result rollback fragment may sometimes be
  replicated when it would not be necessary.
2018-07-17 14:34:24 +03:00
Teemu Ollakka
0efec1b8bd Added debug_crash() method to high priority service interface. 2018-07-16 12:45:53 +03:00