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

32 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
Teemu Ollakka
3e5a28df32 codership/wsrep-lib#135 Fix wrong assertion in before_command().
An assertion

  `server_state_.rollback_mode() == wsrep::server_state::rm_async`

fired in `client_state::before_command()` if a BF abort happened
between calls to wait_rollback_complete_and_acquire_ownership()
and before_command().

This commit adds a test to reproduce the assertion and verify
the correct behavior, as well as removes the incorrect assertion
to fix the issue.
2020-07-24 10:46:48 +03:00
Teemu Ollakka
6291f1bf16 Squashed memory leaks to get clean test run with ASAN enabled. 2019-12-08 12:52:36 +02:00
Teemu Ollakka
85a03394cc NBO applying
- High priority interface method to apply NBO begin, separate from
  apply_toi() in order to avoid implementation to force interpreting
  ws_meta flags.
- Method to put client_state into NBO mode when applying NBO begin.
  The client_state will process in m_local mode.
- Unit tests for applying NBO
2019-12-08 12:52:36 +02:00
Teemu Ollakka
477a71dd46 Updated wsrep-API, added -Wconversion to compiler flags, fixed errors. 2019-10-11 09:56:07 +03:00
Teemu Ollakka
0c54cbd3f8 codership/wsrep-lib#106 Relaxed assumptions about threading model
Sanity checks to detect concurrency bugs were assuming a threading
model where each client state would always be processed within
single thread of execution. This however may be too strong assumption
if the application uses some kind of thread pooling.

This patch relaxes those assumptions by removing current_thread_id_
from client_state and relaxing assertions against owning_thread_id_.

This patch also adds a new method
wait_rollback_complete_and_acquire_ownership() into
client_state. This method is idempotent and can be used to gain
control to client_state before before_command() is called.
The method will wait until possible background rollback process is
over and marks the state to s_exec to protect the state against
new background rollbacks.

Other fixes/improvements:
- High priority globals state is restored after discarding streaming.
- Allowed server_state transition donor -> synced.
- Client state method store_globals() was renamed to acquire_ownership()
  to better describe the intent. Method store_globals() was left for
  backwards compatibility and marked deprecated.
2019-08-05 15:12:44 +03: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
c61811ed70 codership/wsrep-lib#90 Fixed assertion in before_commit()
Added unit test which makes assertion to fail if the fix is not
present.
2019-02-24 12:05:58 +02:00
Teemu Ollakka
ab0e5f5d77 Fixed streaming transaction BF abort
The streaming_rollback() was not called from transaction::bf_abort()
if a streaming transaction was BF aborted in executing state. This
was because the condition to enter streaming_rollback() checked
if the transaction state is executing. However, the transaction
state had already been changed to must_abort before.

As a fix, save the state to local variable when entering
bf_abort() and check against saved state in condition to enter
streaming_rollback().

Added unit test for the correct behavior in the case when streaming
transaction is BF aborted in executing state.

Silenced warning about failing to replicate rollback fragment.
This is pretty normal condition and may happen during shutdown/
configuration changes when SR transactions are rolled back.
2019-02-19 15:11:25 +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
sjaakola
cfcf34e70f codership/wsrep-lib#23 before_command() wait for ongoing rollbacks leaks
Storing information that background rollbacker in ongoing in client state has_rollback_
This can be used for detecting if there is ongoing background rollback,
and client should keep waiting in before_command() entry to avoid conflicts
in accessing client state during background rollbacking.

transaction::bf_abort() is modified to set has_rollback_ flag when
backgroung rollbacking has been assigned for the client

sync_rollback_complete() method has been modified to reset the backround
rollbacker flag
2018-11-27 12:26:14 +02: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
cb1ca4e66e Rollback and release streaming appliers in unit tests
Unit tests which cause streaming rollback leaked memory because
the streaming applier handle which was created for rollback
fragment handling was not released. Roll back a streaming transaction
and release applier handle appropriately in corresponding tests.
2018-10-17 12:51:01 +03:00
Teemu Ollakka
c0c977f9ab Added GPLv2 licence and copyright headers. 2018-10-15 15:14:22 +03:00
Teemu Ollakka
ca5c24655f Fixes to SR transaction processing
* Release server lock temporarily when BF aborting local SR
  transaction during view event processing
* Check transaction state for BF aborts in before_prepare() after
  the lock has acquired after fragment removal
* Send rollback fragment only from streaming_rollback()
2018-07-17 15:23:53 +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
ddc6c6495b Made client_id, transaction_id constructors explicit. 2018-07-11 15:00:31 +03:00
Teemu Ollakka
95dbab4c08 Made transaction streaming context private and provided accessor method. 2018-07-09 08:49:29 +03:00
Teemu Ollakka
7c424d8337 Fixes to local streaming replication processing. 2018-07-08 15:27:49 +03:00
Teemu Ollakka
af18a10a49 Removed is_autocommi() from client_service interface as it is not
quite useful as there might not be enough information for it
after the statement has been processed. Better to handle retrying
on DBMS side. Also removed after_statement_result enumeration and
return plain int from after_statement().
2018-07-06 19:48:48 +03:00
Teemu Ollakka
635eaf4c29 Refactored high priority service out of client service. 2018-07-02 18:22:24 +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