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

40 Commits

Author SHA1 Message Date
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
Daniele Sciascia
6a17207b7f Add method client_service::is_prepared_xa() 2024-01-24 13:05:03 +02: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
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
626c0b7b3b Fix -Winconsistent-missing-destructor-override warnings 2023-03-30 13:46:14 +03: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
Daniele Sciascia
f8ff2cfdd4 Remove unnecessary include directives from the public interface 2022-11-10 10:31:36 +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
Teemu Ollakka
d1482feb32 Ensure that client_service::will_replay() is called.
Modified tests to verify that client_service::will_replay() is
called whenever it is determined that the transaction must replay.

Added a test to verify behavior when provider::commit_order_enter()
returns BF abort error.

Moved call to client_service::will_replay() into transaction::state()
to ensure that it is always called when shift to s_must_replay
happens.
2020-10-19 06:12:17 +03: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
Leandro Pacheco
b73df49cff basic XA unit tests 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
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
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
Teemu Ollakka
8c2daa7e3d Handle BF abort during fragment removal
Fragment removal for SR transaction is done in transaction context
to make it atomic. However, this means that if the BF abort arrives
during fragment removal, the transaction may be rolled back inside
client_service::remove_fragments(), and client_state::after_prepare()
is left in aborted state. This case was not handled in the
post condition checks of after_prepare().

Fixed assertion in after_prepare() and implemented unit test.
2019-02-15 12:09:49 +02: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
Daniele Sciascia
4ac15e4349 Fix attempt to replicate empty fragments
* Adds method wsrep::transaction::streaming_step() so that there is a
  single place where streaming context unit counter is udpated.
  The method also checks that some data has been generated before
  attempting fragment replication.
* Emit a warning if there is an attempt to replicate a fragment and
  there is no data to replicate.
2019-01-07 16:33:32 +01:00
Teemu Ollakka
c0c977f9ab Added GPLv2 licence and copyright headers. 2018-10-15 15:14:22 +03:00
Teemu Ollakka
272de0c6af Removed dead code 2018-10-03 13:13:06 +03:00
Alexey Yurchenko
31f244c3b3 Fixed compilation on Ubuntu 18.04 / GCC 7.3.0 2018-10-02 21:41:14 +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
2ac13100f7 Refactored storage service out of client service interface. 2018-07-07 18:06:37 +03:00
Teemu Ollakka
e876418ed3 * Renamed client service rollback() to bf_rollback() to better
describe its purpose.
* Raise deadlock error for BF aborted transaction in after_statement()
  call if the error is not set yet.
2018-07-06 15:42:03 +03:00
Teemu Ollakka
635eaf4c29 Refactored high priority service out of client service. 2018-07-02 18:22:24 +03:00
Teemu Ollakka
658a84a7d4 Fixed BF abort in sync rollback mode.
* Pass condition variable for client_state
* Notify all cond waiters when changing the transcation status to
  aborted
* Wait for aborting transaction state aborted in before_command
2018-07-02 10:09:48 +03:00
Teemu Ollakka
4e152ee79d * Added applier side TOI commit order enter and leave
* Added cleanup_transaction() method to client_service in order to
  provide a way to make DBMS side cleanup when transaction
  is cleaned up
2018-06-25 14:09:19 +03:00
Teemu Ollakka
cad9176474 TOI replicating and applying codepaths 2018-06-25 09:28:51 +03:00
Teemu Ollakka
779f84e5df Made client_service, transaction independent of provider.
Provider may not be loaded when client_service and
transaction are constructed.
2018-06-19 14:54:58 +03:00
Teemu Ollakka
0e4c7f16a9 Pass ws_handle as const reference to provider replay() 2018-06-19 09:36:15 +03:00
Teemu Ollakka
60fb119fa1 Cleaned up client_state interface. 2018-06-18 18:55:38 +03:00
Teemu Ollakka
ef5751943d Refactored most of the server_state interface into server_service
abstract interface.
2018-06-18 16:52:41 +03:00
Teemu Ollakka
03043d3f25 Removing client_state dependency from client_service. 2018-06-18 10:21:02 +03:00
Teemu Ollakka
ef4baa9f9d Renamed server_context to server_state. 2018-06-17 10:07:48 +03:00
Teemu Ollakka
790c2bec4e Renamed transcation_context to transaction 2018-06-17 10:04:00 +03:00
Teemu Ollakka
dd28b173ab Renamed client_context to client_state. 2018-06-17 10:00:13 +03:00