Skip to content

Commit 12c02f5

Browse files
committed
Add extension certify_v1 for application defined sequential consistency
The new call certify_v1 has the signature and behavior of the original certify() call defined in wsrep struct, with additional callback to allow application defined sequential consistency.
1 parent b03acea commit 12c02f5

File tree

1 file changed

+63
-1
lines changed

1 file changed

+63
-1
lines changed

wsrep_api.h

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2009-2013 Codership Oy <[email protected]>
1+
/* Copyright (C) 2009-2024 Codership Oy <[email protected]>
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -1373,6 +1373,68 @@ int wsrep_load(const char* spec, wsrep_t** hptr, wsrep_log_cb_t log_cb);
13731373
*/
13741374
void wsrep_unload(wsrep_t* hptr);
13751375

1376+
/*!
1377+
* A callback struct to pass on calls which may be required to
1378+
* maintain sequential consistency enforced by the caller. The
1379+
* provider will call the callback once the sequential consistency
1380+
* is guaranteed.
1381+
*/
1382+
typedef struct wsrep_seq_cb {
1383+
/*! Pointer to caller defined context. */
1384+
void *ctx;
1385+
/*! Function which will be called by the provider once the sequential
1386+
* consistency is guaranteed.
1387+
*
1388+
* @param ctx Caller defined context.
1389+
*/
1390+
void (*fn)(void *ctx);
1391+
} wsrep_seq_cb_t;
1392+
1393+
/*!
1394+
* @brief Certifies transaction with provider.
1395+
*
1396+
* Must be called before transaction commit. Returns success code, which
1397+
* caller must check.
1398+
*
1399+
* In case of WSREP_OK, transaction can proceed to commit.
1400+
* Otherwise transaction must rollback.
1401+
*
1402+
* In case of a failure there are two conceptually different situations:
1403+
* - the writeset was not ordered. In that case meta struct shall contain
1404+
* undefined GTID: WSREP_UUID_UNDEFINED:WSREP_SEQNO_UNDEFINED.
1405+
* - the writeset was successfully ordered, but failed certification.
1406+
* In this case meta struct shall contain a valid GTID.
1407+
*
1408+
* Regardless of the return code, if meta struct contains a valid GTID
1409+
* the commit order critical section must be entered with that GTID.
1410+
*
1411+
* This is an extension to the original certify() call with additional seq_cb
1412+
* parameter. The purpose of the seq_cb is to provide a callback to be
1413+
* called by the provider after the sequential consistency for the write set
1414+
* is guaranteed.
1415+
*
1416+
* @param wsrep provider handle
1417+
* @param conn_id connection ID
1418+
* @param ws_handle writeset of committing transaction
1419+
* @param flags fine tuning the replication WSREP_FLAG_*
1420+
* @param meta transaction meta data
1421+
* @param seq_cb callback for provider to call after ensuring sequential
1422+
consistency
1423+
*
1424+
* @retval WSREP_OK writeset successfully certified, can commit
1425+
* @retval WSREP_TRX_FAIL must rollback transaction
1426+
* @retval WSREP_CONN_FAIL must close client connection
1427+
* @retval WSREP_NODE_FAIL must close all connections and reinit
1428+
*/
1429+
1430+
typedef wsrep_status_t (*wsrep_certify_fn_v1)(wsrep_t* wsrep,
1431+
wsrep_conn_id_t conn_id,
1432+
wsrep_ws_handle_t* ws_handle,
1433+
uint32_t flags,
1434+
wsrep_trx_meta_t* meta,
1435+
const wsrep_seq_cb_t* seq_cb);
1436+
#define WSREP_CERTIFY_V1 "wsrep_certify_v1"
1437+
13761438
#ifdef __cplusplus
13771439
}
13781440
#endif

0 commit comments

Comments
 (0)