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

50 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
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
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
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
Daniele Sciascia
f8ff2cfdd4 Remove unnecessary include directives from the public interface 2022-11-10 10:31:36 +01: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
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
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
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
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
3a1b194741 Pass certification keys also for NBO end.
Certification keys are needed for NBO end to resolve dependencies
for the write sets which follow NBO end. Without keys the following
write sets do not detect dependency to NBO event and may start applying
too early.
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
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
a9987aa970 s_prepared state for XA transactions
After the XA PREPARE, the XA transactions stay s_prepared until
commit/rollback
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
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
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
Alexey Yurchenko
4285ff99ea codership/wsrep-lib#100 Support for assign_read_view() wsrep API call
Marshall the call from the `client_state` interface down to provider.
2019-05-08 15:07:45 +03:00
Teemu Ollakka
e9dafb7373 Provided methods to clone subset of transaction state for replay. 2019-04-03 18:51:27 +03: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
9c387ef82f Count fragments certified for a statement.
The counter counts fragments which were succesfully certified since
the object construction or last after_statement() call.
2019-02-15 09:50:37 +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
Alexey Yurchenko
fd07ff12e4 Refs codership/wsrep-API#21 added support for the IMPLICIT_DEPS WS flag 2018-11-28 18:07:08 +01:00
Teemu Ollakka
d4efa598bb Added is_empty() method to transaction class
Method is_empty() can be determined if there have no been changes
to the transaction.
2018-10-26 11:48:59 +03:00
Teemu Ollakka
7c6ee3f61f In order to avoid potential deadlocks, release client_state lock when
calling server state methods which may acquire server_state mutex.

Fixed compilation errors in release mode.
2018-10-15 16:35:19 +03:00
Teemu Ollakka
c0c977f9ab Added GPLv2 licence and copyright headers. 2018-10-15 15:14:22 +03:00
Teemu Ollakka
13487781d8 Total order BF abort client_state method to differentiate BF
aborts caused by conflicts between transactions and conflicts
between TOI operations and transactions.
2018-07-13 18:33:22 +03:00
Teemu Ollakka
3f4e5dea3b Revised logic to handle SR replaying
* Added server_id into transaction in order to be able to stop
  streaming applier during high priority BF abort
* Added missing commit fragment applying
* Don't clear fragments for replaying SR transaction
2018-07-12 13:36:45 +03:00
Teemu Ollakka
80ca03daaf Implemented SR transaction rollback. 2018-07-10 14:01:41 +03:00
Teemu Ollakka
8c4a786f79 Collect and append SR commit keys. 2018-07-09 20:16:31 +03:00
Teemu Ollakka
6f68c70d37 Interface changes required to store and remove fragments from high
priority context.
2018-07-09 18:12:48 +03:00
Teemu Ollakka
958a916b25 * Don't set ordering meta data for replaying transaction
* Renamed transaction prepare_for_fragment_ordering() to
  prepare_for_ordering()
2018-07-09 13:23:16 +03:00
Teemu Ollakka
95dbab4c08 Made transaction streaming context private and provided accessor method. 2018-07-09 08:49:29 +03:00
Teemu Ollakka
2ac13100f7 Refactored storage service out of client service interface. 2018-07-07 18:06:37 +03:00
Teemu Ollakka
a7f8728c12 After applying call, BF abort fixes
* Added after applying call for high priority threads in order to
  avoid client mode complexity in after_statement() call and
  make high prio transaction cleanup possible
* Mask connection failed error with deadlock error if provider
  returns connection failed and the transaction was BF aborted
2018-07-04 14:28:54 +03:00
Teemu Ollakka
8f0e112c47 Renamed invalid to undefined. More utility functions. 2018-06-21 16:50:44 +03:00
Teemu Ollakka
3a8861b26b * Moved causal reads/gtid wait into server state interface
* Changed undefined seqno to be defined as -1
2018-06-21 10:37:55 +03:00
Teemu Ollakka
ef0fb72b73 * Added size exceeded error code
* Return provider status from selected client_state calls
* Added more methods to provider interface
2018-06-20 19:44:20 +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
60fb119fa1 Cleaned up client_state interface. 2018-06-18 18:55:38 +03:00
Teemu Ollakka
cf231bdf2d Refactored server_service out of server_state. 2018-06-18 17:45:24 +03:00
Teemu Ollakka
af3119a58b Removed ostream include from public API headers. 2018-06-17 13:55:37 +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