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

476 Commits

Author SHA1 Message Date
Teemu Ollakka
06b07fe940 Add a method to disable BF aborts for transaction 2024-03-21 13:49:22 +02:00
Teemu Ollakka
7d108eb870 Rename reported log_msg struct to log_msg_t
MySQL defines a macro log_msg in one of its headers, which
causes log_msg to be replaced with different symbol in
some compilation units.

Fix by renaming the struct to log_msg_t to avoid the conflict.
2024-03-19 10:20:29 +02:00
Daniele Sciascia
6a17207b7f Add method client_service::is_prepared_xa() 2024-01-24 13:05:03 +02:00
Teemu Ollakka
a5d95f0175 Fix dbsim thread instrumentation for main thread
The thread local ti_thread object was not initialized for main thread,
which caused ASAN to complain about wild pointer.

Fixed by assigning a thread local ti_thread object for main
thread too.
2023-10-30 12:29:10 +03:00
Denis Protivensky
ffe1ba7a5d Fix use-after-free in wsrep::log 2023-10-17 14:15:14 +03:00
Alexey Yurchenko
07af42c052 Fix file descriptor leak
Ref codership/wsrep-lib#219
2023-10-09 19:37:37 +03:00
Daniele Sciascia
151d4f8591 Unlock client mutex when calling client_service::remove_fragments()
To avoid mutex order violations
2023-09-05 10:19:23 +03:00
Daniele Sciascia
3b07ea039a Failed to insert streaming client warning after replay
Avoid streaming context cleanup in after_rollback() hook, if
transaction is going to replay. Otherwise, streaming client is not
stopped and is left in streaming client map, potentially causing
"Failed to insert streaming client" warning if the transaction
goes for retry.
2023-09-05 10:19:23 +03:00
Daniele Sciascia
173693f2ee Github actions: do sudo apt update before installing packages 2023-07-17 15:41:24 +02: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
7dafce8403 Remove wrong assertion from transaction::cleanup()
In case if SR transaction gets BF aborted before it is
certified, the replay will happen but if the replay fails
due to certification conflict, the transaction is not terminated
in provider replay and will keep its streaming status.

Removed the wrong assertion about streaming status from
transaction::cleanup().
2023-05-26 13:35:31 +03:00
Teemu Ollakka
9070f2a891 Change unit tests to mimic application behavior on replaying
Allocate separate client state in mock_client_service::replay()
for replaying step.

Added two new test cases for streaming replication replay after
BF abort.
2023-05-26 12:47:47 +03:00
Teemu Ollakka
e238c0d240 Review fixes
* Move resetting is_bf_immutable_ into trasaction::cleanup()
  to ensure that it is reset to false regardless how the
  transaction terminates.
* Removed redundant lock()/unlock() methods from
  mock_client_state.
2023-05-16 19:30:31 +03: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
4951c38357 Github Actions has removed ubuntu-18.04
Replace ubuntu-18.04 virtual environment with ubuntu-20.04.
Compilation tests for GCC < 7 cannot be done anymore
since ubuntu-20.04 environment does not provide such an
old compilers.
2023-04-04 13:53:25 +03:00
Teemu Ollakka
626c0b7b3b Fix -Winconsistent-missing-destructor-override warnings 2023-03-30 13:46:14 +03:00
Teemu Ollakka
66a8fa9b13 Add -Winconsistent-missing-destructor-override if compiler supports 2023-03-30 13:03:43 +03:00
Teemu Ollakka
94ea93a48d Add clang-13 into build matrix 2023-03-29 18:14:43 +03:00
Teemu Ollakka
5185ad3481 Grab lock after starting background rollback
This makes the bf_abort() to return with lock locked.
2023-03-17 16:24:56 +02: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
Daniele Sciascia
32d4275c60 Rollback storage service in case of errors while appending fragment
This is part of fix for MDEV-30838
2023-03-14 14:25:37 +01:00
Teemu Ollakka
7e0ccfc1d4 Updated wsrep-API/v26 for ASAN instrumentation fix 2023-03-02 08:44:56 +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
241898af7e Postpone streaming_context cleanup into after_rollback()
Streaming_context was cleaned up in streaming_rollback(),
which could cause clearing fragment seqno vector while
it was still accessed by the owning thread, causing
undefined behavior. Fixed by postponing streaming_context
cleanup for BF aborted SR transactions to always happen in
after_rollback().
2023-03-02 08:38:19 +02:00
Teemu Ollakka
19eaed587c Fix total order BF abort
Streaming rollback for total order BF abort used regular
BF abort codepath, which was not correct because the streaming
rollback must fully complete before total order operation executes.
Fixed this by adjusting bf_aborted_in_total_order_
before streaming_rollback() gets called.
2023-03-02 08:37:12 +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
5a943b66a7 Fix assertion unallowed state transition: connected -> joined
When the donor lost its donor state during SST due to cluster
partitioning, the state was erranously changed to `s_joined`
in `start_sst()` and `sst_sent()`, which caused assertion failures
in state checking.

Fixed by changing state to `s_joined` only if donor is still in
`s_donor` state.
2023-02-28 12:13:00 +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
9e8708af7e Add GCC 12 into GitHup actions build matrix 2023-02-26 10:12:56 +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
940ba9bd0e Fix escape_json() compilation error due to type limits check
Compilation failed on arm64 with

  error: comparison is always true due to limited range of data type
  [-Werror=type-limits]

for
  if (0x0 <= *c && *c <= 0x1f)

This was because char is unsigned on arm64 and thus always greater
than zero.

Fixed by using std::iscntrl() instead of explicit range check.
This adds also backspace into set of escaped characters.
2023-01-23 11:08:32 +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
sjaakola
2db35f8f6c MDEV-29512 deadlock between commit monitor and THD::LOCK_thd_data mutex
Grabbing back the lock later, after set_position has been called.
This is because set_position may have to wait for correct seqno position
and calls sync wait in galera side. Such wait would happen while holding
the lock, which would case hanging like reported in MDEV-29512

PR for MDEV-29512 contains a mtr test for reproducing one such deadlock
scenario.
2022-11-08 17:00:53 +02: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
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
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
Otto Kekäläinen
23fb862462 Fix spelling of 'initialize in error message 2022-03-14 08:59:29 +02: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
edd141127c Handle assert server_id_.is_undefined == false
Return an error if server_id_ is undefined before fragment
certification. This may happen if the server disconnects from the
cluster, right before a transactions attempts to replicate a
fragment.
2022-01-25 14:38:28 +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
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
Daniele Sciascia
13442a04d8 Assert transaction is active before appending keys and data
Attempt to append keys while transaction is not active results in
creating a transaction handle with id -1 (undefined).
Assert that the transaction is `active()` before appending keys.
Same for appending data.
2021-12-10 18:02:24 +00:00