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

246 Commits

Author SHA1 Message Date
Daniele Sciascia
fc8e627815 Add method client_state::stream()
This method forces a streaming replication step.
2023-11-10 10:03:51 +01:00
Daniele Sciascia
096b5c5c7a Remove tracking of log_position
This patch removes log_position from streaming_context. The
log_position was meant for keeping track of the database specific
position corresponding to the changes that have been already
replicated by a streaming transaction. In reality, things may be more
complex in the DBMS side and a size_t may be unsufficient to keep
track of the progress of a streaming transaction. For example, in
MariaDB, it may be necessary to keep track of positions in both
transaction and statement caches. Suggesting that the responsibility
of tracking these position(s) should be delegated to client_service.
The log_position was also used to do sanity checks in
streaming_step(). Those sanity checks are preserved by simply keeping
track of the number of bytes that were certified by the streaming
transaction.
2023-11-10 10:00:26 +01:00
Denis Protivensky
ffe1ba7a5d Fix use-after-free in wsrep::log 2023-10-17 14:15:14 +03:00
Daniele Sciascia
62bd40800f Remove duplicate logic from after_statement
Remove bf abort handling `client_state::after_statement()`, since the
same logic already appears later in `transaction::after_statement()`.
Also, introduce `transaction::after_statement()` overload which takes
a lock.
2023-07-17 15:07:22 +02:00
Teemu Ollakka
b76e94f84a Transaction not immune after becoming ordered for commit
The transaction state is set to s_ordered_commit in
ordered_commit(). However, this is too late for making the
transaction immune for BF aborts after commit order has
been established, which happens in before_commit().

Moving the state change into before_commit() would be the
right thing to do, but that would require too many fixes
to existing applications which are using the lib.

In order to make the transaction immune for BF abort
after it has been ordered to commit, introduce additional
boolean flag which is set to true at the end of before_commit()
and is taken into account in bf_abort().
2023-04-26 11:46:34 +03:00
Teemu Ollakka
d2f27babd6 Add lock argument to server_service::background_rollback()
This is to allow implementation to temporarily release the
lock if needed.
2023-04-16 19:12:26 +03:00
Teemu Ollakka
f8a20ff00f Make is_rollbacker_active() public, don't unlock for background rollback
Make is_rollbacker_active() public so that the BF thread can
check if the rollbacker was started or not.

Also don't unlock the lock for launching the background
rollbacker to avoid race conditions in accessing the
victim state.
2023-04-05 09:30:55 +03:00
Teemu Ollakka
626c0b7b3b Fix -Winconsistent-missing-destructor-override warnings 2023-03-30 13:46:14 +03:00
Teemu Ollakka
69b9d7d464 Allow external locking for BF aborts
Added methods bf_abort() and total_order_bf_abort() which take
wsrep::unique_lock<wsrep::mutex> as argument to allow caller
to grab the mutex before attempting BF abort. The old calls
were kept for backwards compatibility and wrap the new calls
with internal locking.
2023-03-17 14:38:03 +02:00
Teemu Ollakka
9a35083730 Eliminated duplicate fragment removal code
Extracted duplicate fragment removal code in after_commit()
and after_rollback() into separate method.
2023-03-02 08:39:37 +02:00
Teemu Ollakka
7843345a19 Extracted duplicate logic into return_from_donor_state
The condition to skip changing to `s_joined` for all codepaths
which return from donor state. Extracted the logic into separate
method.

Commented start_sst_action in mock_server_service.
2023-02-28 16:20:18 +02:00
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
Teemu Ollakka
de3d7b63ea Add report_event() method into reporter object
Report event will write json formatted event into report
file.

Include Boost headers as system headers to avoid generating
excessive warnings. Enable extra tests for selected compilers
in actions.
2022-12-05 17:05:14 +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
Teemu Ollakka
6caf006214 Minor tweaks to boost library detection
- Change default WITH_BOOST path to reside inside source tree
  to avoid permission problems or accidentally overwriting
  directories outside source tree.
- If system Boost installation is not found, optionally use
  header only unit test framework from location specified by
  WITH_BOOST.
- Fix extra-semi warning in provider_options.hpp.
2022-09-19 15:51:22 +03:00
Teemu Ollakka
453b81c6a7 Provider options module
This commit introduces provider_options module which
acts as a proxy between application and wsrep provider
library.
When initialized, the provider options are read from the
provider through config service api extension. A lookup
table with current values and defaults is constructed.

Parameter names are mapped so that dots in provider parameter
names are transformed to underscores.
2022-09-02 10:29:19 +02:00
Daniele Sciascia
8bfce04189 Fix cleanup for non-prepared XA transactions
Cleanup XA transaction which is marked as prepared in DBMS, but not in
wsrep-lib side. This may happen if the DBMS runs with wsrep disabled.
2022-04-08 14:47:22 +02: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
4565f7232f Define event consumption interface for the application side event service
implementation.
Implement event pass-through to the applicaiton.

Refs codership/wsrep-lib#174
2021-12-10 20:54:57 +02:00
mkaruza
14b3612a30 Initial allowlist support 2021-12-06 14:23:40 +01: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
Daniele Sciascia
7d6641764b Replay prepared transactions found BFed after prepare
Handle the case were prepare is bf aborted after it has replicated a
fragment, and before the command finishes in
after_command_before_result() and after_command_after_result() hooks.
2021-09-06 15:29:38 +02:00
Alexey Yurchenko
4f1c201c9d Initial implementation of the status interface reporter object. 2021-09-05 15:42:54 +03:00
Daniele Sciascia
0151e98802 Assertion transaction.is_streaming() in wsrep::transaction::adopt()
Assertion is_streaming() fires in transaction::adopt() when a
transaction is BF aborted, while it is in s_executing state, and it
manages to complete rollback and cleanup while the BF aborter is
executing streaming_rollback() with client_state lock is unlocked.
In this case method transaction::adopt() finds a transaction that is
no longer marked as streaming, triggering the assertion.
A condition variable and flag streaming_rollback_in_progress_ now
prevents a client thread to finish rollback, even if the BF aborter
has temporarily unlocked the client_state lock.
2021-09-02 13:22:45 +02:00
Daniele Sciascia
c45b1eff94 Remove method transaction::clear_fragments()
Remove the method as it does nothing, except for calling
`streaming_context_.clear()`. This led to a situation where we have
two ways to do the same thing, and it is annoying, if one wants to search
for all places where streaming_context is cleaned up.
2021-07-06 11:23:38 +02:00
sjaakola
608ee82b26 allowing application to set transaction as PA unsafe
* Removed transaction::p_unsafe_ member
* Changed transaction::pa_unsafe(bool) to modify flags member directly
* Modified transaction.cpp to use transaction.pa_unsafe(bool) rather than
  directly changing transaction's flag
* added method mark_transaction_pa_unsafe() for client_state,
  application will use this
2021-05-14 14:56:02 +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
Otto Kekäläinen
a12b814270 Fix various spelling errors
e.g.
- succesfully -> successfully
- preceeding -> preceding
2021-02-04 17:08:08 +02:00
Teemu Ollakka
a93955ddee Introduce non-locking variant of client_state::cleanup()
The method takes already locked lock object as an argument.
The caller must ensure that the lock object owns the underlying mutex.

Replaced homegrown wsrep::unique_lock with type alias from
std::unique_lock.
2021-01-07 14:38:32 +02:00
Alexey Yurchenko
515ac816f9 Add prefix argument to logger callback.
Refs codership/wsrep-lib#148
2020-12-11 12:24:33 +02:00
Teemu Ollakka
ff94dfd8a7 Handle the possibility of client command that cannot return results
This patch adds the possibility to have client commands that do not
return results from DBMS. While processing such commands we must be
able to preserve errors until the next interaction with client.
Specifically if the transaction is bf aborted while processing such
a non-returning command, then we have to keep the deadlock error until
the client issues a command that may return the error.
To handle such cases, client_state::before_command() now takes
parameter keep_command_error. The DBMS is supposed set
keep_command_error true to instruct wsrep-lib to preserve errors (if
any) until the next command which sets keep_command_error false.

Dealing with a case where current client command does not return result.

Work in progress.

Fix typo and add assertions in keep_command_error()

Make keep_command_error a parameter to before_commit()

Fix comment about keep_command_error

Handle keep_command_error with s_must_abort in wsrep_before_command()

Fix unit test
2020-11-27 11:17:39 +01:00
Daniele Sciascia
41a6e9dad7 Address review comments
Removed unnecessary assertion in transaction::before_commit().
Assert client state and mode in client_state::xa_detach().
2020-10-28 14:37:46 +01: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
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
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
Teemu Ollakka
7245db4704 Enable -Wsuggest-override if supported by the compiler. 2020-10-22 17:31:21 +03:00
Teemu Ollakka
ec767cd3f0 Ostream operator for key type for better readability. 2020-10-19 05:31:20 +03:00
Daniele Sciascia
eac56f19e0 Remove dead code 2020-10-05 15:10:48 +02: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
mkaruza
d0255569b0 Variable desynced_on_pause getter 2020-04-03 10:10:29 +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
Teemu Ollakka
76f7249b8d Incorrect assertion and state handling in after_replay().
If the transaction fails during replay because of certification
failure, the provider will return control to applier without
terminating the transaction and transaction remains in
s_replaying.

Fixed transaction::after_statement() to handle the state changes
correctly if certification failure is returned from replay.
Replaying was extracted to separate private method from
after_statement(). Removed transaction::after_replay() as it
seems now unnecessary and it bypassed state change sanity checks.

Allowed replaying -> committed transaction transition to handle
the situation where DBMS allocates a new context and client_state
to do the replay.
2019-12-28 12:28:38 +02:00
Teemu Ollakka
8e37727a27 Removed extra line. 2019-12-08 12:52:36 +02:00
Teemu Ollakka
7d8583983f Fixes to review comments
- Increased loop sleep in poll_enter_toi()
- Fixed typos in comments
- Got rid of unnecessary ostringstreams
2019-12-08 12:52:36 +02:00
Leandro Pacheco
043ff7a7e9 remove has_error arg from begin_nbo_phase_two 2019-12-08 12:52:36 +02:00