1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2026-10-23 09:48:57 +03:00
Commit Graph

505 Commits

Author SHA1 Message Date
Pekka Lampio
5b13b63c4f MDEV-35940 Unallowed state transition: donor -> synced in galera_wan
When the provider delivers the SYNCED event while the server is still
in donor state, on_sync() attempted a direct donor -> synced transition,
which is not allowed and aborts in a debug build. This happens when
SYNCED arrives before sst_sent() had a chance to return the server from
donor to joined.

Anticipate JOINED in on_sync() via return_from_donor_state() so the
transition goes donor -> joined -> synced, mirroring what the initial
sync branch already does.

Add a wsrep-lib unit test covering on_sync() in donor state.
2026-06-30 14:15:49 +03:00
Hemant Dangi
5eeef4009d MDEV-38843: BF applier failed on a node causing complete Cluster lockup
log_dummy_write_set() is what releases commit order through
commit_order_leave() - which hands the apply error to the provider to
drive the inconsistency vote - and advances the storage engine
checkpoint. Skipping it on a rollback error leaves the seqno stuck in
commit order so all following appliers block on commit_order_enter, and
the node silently locks the cluster while staying in the primary
component.
Always call log_dummy_write_set() on the apply-error path, regardless of
the rollback result. The rollback result is still folded into ret so it
is not lost.
2026-05-28 14:27:26 +05:30
Teemu Ollakka
93bf4e5b7c MGL-52 Handle BF abort during XA commit/rollback by XID
Although XA commit/rollback by XID does not have active transaction
with changes and does not become BF aborted by lock conflict, there
are other reasons why it can become BF aborted (e.g. session becoming
killed).

Add handling of `s_must_abort` in `commit_or_rollback_by_xid()` and
unit tests for testing correct behavior.
2026-02-16 14:46:59 +02:00
Teemu Ollakka
ece092ba53 MGL-52 Fix locking in commit_or_rollback_by_xid()
The provider::certify() call may be synchronous and blocking.
Unlock the mutex for the duration of provider::certify() call
to avoid deadlock if an applier tries to access the local transaction
which is executing provider::certify() call.
2026-02-13 12:08:56 +02:00
Teemu Ollakka
5db47fca15 MDEV-37026 Revert "Pass callback to get provider options to provider_v26 constructor"
This reverts commit 3965d83968 which
was merged in too early.
2026-02-13 12:00:19 +02:00
Jan Lindström
10689429a1 Fix compilation with GCC 15 2025-12-09 10:34:50 +02:00
Pekka Lampio
195cc5801e MDEV-31517 Wrong variable name in the configuration leads Galera to
think SST/IST failed, at next restart will request a full SST

This patch fixes an unwanted behavior of a Galera cluster node when
Server startup fails because of an error in configuration file: after
the failure full SST is requested at the next Server startup even
though full SST is not needed (MDEV-31517).

If Server startup fails because of a configuration error, this patch
ensures that Galera state of the failing node remains unchanged. This
avoids full SST at the next Server restart.

This fix consists of three patches for the following components:

1) Server,
2) WSREP library,
3) Galera.
2025-11-06 11:08:55 +02:00
Daniele Sciascia
3965d83968 Pass callback to get provider options to provider_v26 constructor
Passing a callback allows constructing the options string using
config service after loading the provider but before initializing
the provider. This way it is possible get options which are given
at DBMS startup, in command line or config file.
2025-07-09 14:55:16 +02:00
Denis Protivensky
2dc8339ff1 Expose provider::conflict_gtid() method for GRP 2025-06-19 16:44:58 +03:00
Jan Lindström
a2d7d89c1d MDEV-36551: Add interface to report wsrep state change in Galera 2025-05-07 17:32:41 +03:00
Alexey Yurchenko
14ce8cab76 Apparently github has removed support for Ubuntu 20.04 in workfolws.
Migrate builds done in 20.04 to 22.04 where possible, i.e. where compiler
is supported in 22.04.
2025-04-30 17:45:34 +02:00
Alexey Yurchenko
787aa86d1b It may happen so that disconnect() is called in s_joined state just an
instance before the SYNCED event is delivered. Thus wsrep-lib is already
in s_disconnecting state but still will transition to s_synced albeit
with a warning. This is pointless and possibly harmful.
If we are disconnecting ignore any remaining state events from the
replication queue.
Refs codership/wsrep-lib#251
2025-04-22 22:55:42 +02:00
Jan Lindström
7c7c3be62e Allow provider initialization even when connection monitor service
is not supported by Galera library.
2025-04-11 07:24:20 +03:00
Teemu Ollakka
e55f01ce1e Fix compilation for gcc 4.8 2025-04-08 11:59:48 +03:00
Teemu Ollakka
324b01e431 MDEV-36422 Build fails with cmake 4.0.0
Set policy_max version to 4.0 to avoid error

    Compatibility with CMake < 3.5 has been removed from CMake.

Add github workflow to check CMake compatibility for commonly used
versions and the newest ones.
2025-04-03 09:09:08 +03:00
Teemu Ollakka
cd07c34996 Fix wsrep-API/v26 to point to v26 branch head 2025-02-27 11:34:58 +02:00
Jan Lindström
b8e0540e7a MDEV-26851 : Add interface to monitor connections in Galera 2025-02-21 11:36:34 +02:00
Teemu Ollakka
2d7b357e60 Fix condition to treat an id as alphanumeric string
An id is considered an alphanumeric string if it contains a
non-empty sequence of alphanumeric characters followed by
one or more null characters.

Fixed unit tests accordingly.
2025-01-14 16:52:23 +02:00
Teemu Ollakka
5ea78de6c2 Add support for custom provider implementation
- Add a set_provider_factory() method to server_state to allow
  injecting provider factory which will be called when the
  provider is loaded.

Other related changes:
- Implement to_string() helper method for id class.
- Fix id ostream operator human readable id printing.
- Pass victim client_service as an argument to provider::bf_abort()
  to allow passing victim context to custom provider.
- Implement prev() helper method for seqno class.
- Make server_state recover_streaming_appliers_if_not_recovered()
  public. In some recovery scenarios the method must be called outside
  of server_state internal code paths.
- Add storage_service requires_globals() method. The storage service
  implementation may override this to return false if changing to
  storage service context does not require store/reset globals.
- Change view final() to also require that the view status is not
  primary for the view to be final. Also change the method name to
  is_final() to avoid confusion with C++ final identifier.
- Fixes to server state handling in disconnecting and disconnected
  states.
- Keep TOI meta data over whole TOI critical section.

Co-authored-by: Denis Protivensky <denis.protivensky@galeracluster.com>
2025-01-14 16:51:26 +02:00
Teemu Ollakka
51a0b0ab4f Fix boost download link 2025-01-14 12:35:12 +02:00
Teemu Ollakka
70cd967f5e Change github actions/cache to version 4
Cache service version 2 is going to get closed down,
replace with version 4.
2024-12-11 07:47:49 +02:00
Teemu Ollakka
7994288534 Check local sequential consistency in dbsim
- Release commit time critical section in callback
- Check the consistency inside commit order critical section

Other: Add 2pc switch to dbsim
2024-11-28 15:09:35 +02:00
Teemu Ollakka
3de594b662 Add application defined sequential consistency for certification
Client state methods before_prepare() and before_commit() accept
a callback which is called by the provider after it can guarantee
sequential consistency. This allows application threads which wish to
maintain sequential consistency to enter before_prepare() and
before_commit() calls concurrently without waiting the prior call
to finish.
2024-11-28 13:10:16 +02:00
Daniele Sciascia
1c61b809d1 MDEV-26266 Fix error handling around remove_fragments()
Handle the case where client_service::remove_fragments() fails,
for reasons other than bf abort. In this case, we want to make
sure that the transaction state is moved to s_must_abort, so
that we satisfy the sanity check at the end of before_prepare():

```
   assert(state() == s_preparing ||
          (is_xa() && state() == s_replaying) ||
          (ret && (state() == s_must_abort ||
                   state() == s_must_replay ||
                   state() == s_cert_failed ||
                   state() == s_aborted)));
```
2024-10-09 17:31:02 +02:00
Teemu Ollakka
31db847676 MDEV-32363 Add interface to set node isolation mode in provider 2024-05-21 12:38:34 +03:00
Teemu Ollakka
664d8cc01e Fix reporter test compilation
The compilation failed with

    error: ‘setprecision’ is not a member of ‘std’

Fix by including <iomanip>.
2024-05-17 16:09:54 +03:00
Teemu Ollakka
e399d53d04 Try actions gcc-11 on ubuntu 22.04, add gcc 13 and 14 on ubuntu 24.04
The gcc-11 disappeared from ubuntu-2004. Change gcc-11 os to ubuntu
22.04 where it is available.

Add gcc-13 and gcc-14 which are now available on ubuntu-2404.
2024-05-17 16:06:32 +03:00
Teemu Ollakka
4980861963 Use superproject BOOST_INCLUDE_DIR if set
Extract unittest specific cmake into separate unit to clean up
the main CMakeLists.txt.

fixes codership/wsrep-lib#231
2024-05-15 09:56:22 +03:00
Daniele Sciascia
6b879d46c8 Improve "Unallowed state transition" warning
In client_state, change warning "Unallowed state transition" to print
state names instead of numbers.
2024-04-25 15:37:47 +02:00
Daniele Sciascia
dfc4bdb8a5 Do not abort prepared transaction when statement is interrupted
In `transaction::abort_or_interrupt()` handle the case were a statement
is interrupted while transaction is in prepared state. In which case,
the transaction must remain in prepared state, until it is
committed (or rolled back).
Also in this patch: remove check for reduntant `s_must_abort` state.
2024-03-26 10:07:04 +01: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