1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-04-19 21:02:17 +03:00

123 Commits

Author SHA1 Message Date
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
Alexey Yurchenko
344544df3e Check for a valid provider instead of connection state in
`server_state::set_encryption_key()`

Refs codership/wsrep-lib#192
2022-08-15 14:48:03 +03:00
Daniele Sciascia
63346153ac Fixup error handling on fragment removal
If fragment removal fails when applying rollback fragment, then
rollback the fragment removal context.
2022-01-28 12:23:14 +01:00
Daniele Sciascia
88c3b2609d Revert "Fix fragment removal on rollback"
It turns out that avoiding apply error on fragment removal failure, is
not a safe thing to do. If the DBMS restarts, with a entry in the
streaming log storage, it may be recovered by creating a corresponding
streaming applier.

This reverts commit da5098b622bc6f92c9265bacf4c1168fd69b38b5.
2022-01-26 16:50:52 +01:00
Daniele Sciascia
da5098b622 Fix fragment removal on rollback
Do not cause apply error if fragment removal fails on
rollback. Instead, leave stale entries in storage, and move on.
2022-01-20 16:49:06 +01:00
Alexey Yurchenko
8f59e7b30b 1. Never transition from s_donor directly to s_synced, always wait
for SYNCED event as expected.
2. Fix transition to `s_joined` only after we have a complete state.
   Complete state is reached in the following 3 cases:
   - SST seqno exceeds connected seqno
   - view seqno equals connected seqno (view processed == view connected)
   - current state is `s_donor`

Refs codership/wsrep-lib#175
2021-11-30 21:49:50 +02:00
Alexey Yurchenko
31a35bf573 Remove obsolete wsrep::server_state::last_committed_gtid() method 2021-11-30 15:05:38 +02:00
Teemu Ollakka
d48122a1fa Introduced macro to silence implicit-fallthrough warning
The fallthrough comment is not enough to silence the warning
with -Wimplicit-fallthrough=5.

This commit also fixes submodule handling in github actions.
2021-11-28 12:20:48 +02:00
Daniele Sciascia
22921e7082 Cache rollback events that failed to replicate for later retry
This patch introduces a queue to store ids of transactions that failed
to send a rollback fragment in streaming_rollback(). This is to avoid
potentially  missed rollback fragments when a cluster splits and then
later reforms. Rollback fragments would be missing if a node rolled
back a transaction locally (either BFed or voluntary rollback) while
non-primary, and the attempt to send rollback fragment failed in
transaction::streaming_rollback().
Transaction that fail to send rollback fragment can proceed to
rollback locally.  However we must ensure that rollback fragments for
those transactions are eventually delivered by the cluster. This must
be done before a potentially conflicting writeset causes BF-BF
conflicts in the rest of the cluster.
2021-09-30 10:41:57 +02:00
sjaakola
85b8150321 fix for: allowing application to set transaction as PA unsafe
The new feature which allows application to set transaction as PA unsafe
caused problems for streaming replication use cases. In apply_write_set(),
it is assumed that write set flags must be 0 for existing streaming
replication transaction. However, if SR transaction modifies non PK table,
the replicated fragment may have pa_unsafe flag.
Fixed by changing the condition detecting SR transactions to accept pa_unsafe
flag. This avoids the apply_write_set() execution from falling down to assert(0)
in the "condition tree"
2021-05-21 09:15:45 +03:00
Otto Kekäläinen
a12b814270 Fix various spelling errors
e.g.
- succesfully -> successfully
- preceeding -> preceding
2021-02-04 17:08:08 +02:00
Daniele Sciascia
6752a4504f Address review comments
* Added unit tests for transaction::xa_detach() and
  transaction::xa_replay()
* Added unit tests for wsrep::xid
* Fixed minor issues pointed out by reviewer
2020-10-26 14:22:22 +01:00
Daniele Sciascia
965642eded Support for detaching prepared XA transactions
Add support for detaching XA transactions. This is useful for handling
the case where the DBMS client has a transaction in prepared state and
disconnects. Before disconnect, the DBMS calls the newly introduced
client_state::xa_detach(), to cleanup the local transaction and
convert it to a high priority transaction. The DBMS may later attempt
to terminate the transaction through client_state::commit_by_xid() or
client_state::rollback_by_xid().

Also in this patch:

- Fix client_state::close() so that it does not rollback transactions
  in prepared state
- Changed class wsrep::xid representation to hold enough information
  so that DBMS can convert to its native representation
- Fix potential infinite loop in
  server_state::find_streaming_applier(wsrep:xid&)
- Append SR keys on prepare fragment and make it pa_unsafe
- Handle one phase commit (simply fall back to two phase)
- Do not rollback prepared streaming clients in
  server_state::close_orphaned_transactions()
2020-10-26 14:20:21 +01:00
Daniele Sciascia
2da6e4894e Unnecessary adopt/start transaction in rollback_fragment()
This patch changes the handling of a rollback fragment so that
the high_priority_service adopts and starts a new transaction only
if fragment removal has to be performed.
When no fragment removal happens, starting a new transaction is
unnecessary: a dummy write set is logged instead and the transaction
is not cleaned up properly in DBMS side.
2020-10-26 10:21:59 +01:00
Alexey Yurchenko
daae4a9c35 Some methods in wsrep-lib still hide/ignore return codes from provider
which complicates diagnostics and debugging.

Don't ignore provider return codes and more verbose error logging for
sst_sent(), sst_received(), set_encryption_key() methods

Refs codership/wsrep-lib#127
2020-07-14 12:50:04 +03:00
Teemu Ollakka
90157ed1b0 Allow concurrent server_state disconnect operations.
Shutting down the provider may cause replication/appling failures, which
may further result to disconnect calls from failing operations.
Allow concurrent disconnect requests to deal with such a situations.
2019-12-08 13:42:11 +02:00
Leandro Pacheco
594e34052d handle nbo apply eror
also, remove outdated comment
2019-12-08 12:52:36 +02: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
e9bd950ee6 Fixed nbo_meta handling, release commit order for NBO begin. 2019-12-08 12:52:36 +02:00
Teemu Ollakka
c7a25b15db Ingnore NBO end event in applier, it will be handled via local TOI 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
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
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
9c9323e2a5 Initial support for XA
Force fragment replication when XA transaction is prepared, with
prepare fragment. Commit fragment happens in before_commit().
Adjusted fragment removal, which cannot happen in atomically with the
executing transaction.
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
Teemu Ollakka
20128556d6 Restore original thread local storage after releasing streaming applier.
In convert_streaming_client_to_applier() the new streaming applier
is created and deleted if the server has been disconnected. However,
releasing streaming applier may modify thread local storage. Call
store_globals() to restore thread local storage before returning.
2019-08-29 14:56:21 +03:00
Leandro Pacheco
55427188c1 avoid holding server_state lock when creating streaming applier
This fix avoids creating a lock cycle in MariaDB, between
LOCK_global_system_variables, LOCK_wsrep_cluster_config and
LOCK_wsrep_server_state.
2019-08-07 16:39:03 -03:00
Teemu Ollakka
0c54cbd3f8 codership/wsrep-lib#106 Relaxed assumptions about threading model
Sanity checks to detect concurrency bugs were assuming a threading
model where each client state would always be processed within
single thread of execution. This however may be too strong assumption
if the application uses some kind of thread pooling.

This patch relaxes those assumptions by removing current_thread_id_
from client_state and relaxing assertions against owning_thread_id_.

This patch also adds a new method
wait_rollback_complete_and_acquire_ownership() into
client_state. This method is idempotent and can be used to gain
control to client_state before before_command() is called.
The method will wait until possible background rollback process is
over and marks the state to s_exec to protect the state against
new background rollbacks.

Other fixes/improvements:
- High priority globals state is restored after discarding streaming.
- Allowed server_state transition donor -> synced.
- Client state method store_globals() was renamed to acquire_ownership()
  to better describe the intent. Method store_globals() was left for
  backwards compatibility and marked deprecated.
2019-08-05 15:12:44 +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
Leandro Pacheco
ae746fb289 fixing reviewer comments
- style fixes
- small improvement to avoid unnecessary search on close_orphaned_sr
2019-03-05 10:53:21 +01:00
Leandro Pacheco
5ef5becea6 removing previous_primary_view from public iface and style fixes 2019-03-05 10:34:30 +01:00
Leandro Pacheco
71f3fb2d01 close SR transacions on equal consecutive views
Fixes a bug where the fact that an SR master leaves the primary view
gets missed. When two consecutive primary views have the same
membership we now assume that every SR needs to be rolled back, as the
system may have been through a state of only non-primary components.
2019-03-05 09:41:48 +01: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
be98517cb3 Debug log level implementation
Debug log will now filter output based on debug level that is enabled.
2019-02-13 13:05:45 +02:00
Teemu Ollakka
510c7f767f Deal with backwards compatibility in sst_received()
Earlier versions of cluster software may not support storing
the view info into stable storage. In order to work around this
during rolling upgrade, skip sanity checks for recovered view
if the view state_id ID is undefined.
2019-02-13 08:54:10 +02:00
Shahriyar Rzayev
4eb6074e67 codership/wsrep-lib#71 to make output cleaner with additional space 2019-02-08 14:04:04 +04:00
Shahriyar Rzayev
ad5d8ea066 Fixed typo for issue #68 2019-02-07 12:29:39 +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
632f8c3b14 Fixed race condition in checking init_initialized on prim view
Flag init_initialized_ must be checked before changing the
state to s_initializing in on_primary_view() in order to avoid
race between main thread and applier thread. Otherwise it is
possible that main thread gains control after setting state
to initializing and changes the flag init_initialized_ to true
before the check is done in on_primary_view().
2019-01-25 12:18:46 +02:00
Teemu Ollakka
6e2c70c226 codership/wsrep-lib#54 Fixed race in server disconnect
Convert streaming client to applier only if the server is not
in disconnected state. In disconnected state the appliers map
is supposed to be empty and will be reconstructed from fragment
storage when the server is connected back to cluster.
2019-01-21 17:00:08 +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
144d8c13c1 Relaxed server_state state transition sanity checks
In release build log a warning but continue with state transition
anyway. In debug build log warning and crash in assert.
2019-01-21 14:13:25 +02:00
mkaruza
76875c3be1 Allowed transition s_joined to s_donor 2019-01-21 14:13:25 +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