Skip to content

Commit 71361e9

Browse files
committed
References lp:1163376 - merged annotate() call with append_data() to minimize code duplication.
Also converted long and siz_t variables to ints where applicable: with 2Gb writeset size limit int is sufficient to express releavant sizes and may help to reduce memory usge inside Galera.
1 parent 3ba8939 commit 71361e9

File tree

3 files changed

+56
-77
lines changed

3 files changed

+56
-77
lines changed

wsrep_api.h

+49-57
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ extern "C" {
5555
#define WSREP_CAP_ENCAPSULATE ( 1ULL << 14 )
5656

5757
/*!
58-
* Write set replication flags
58+
* Writeset flags
5959
*/
6060
#define WSREP_FLAG_PA_SAFE ( 1ULL << 0 )
6161
#define WSREP_FLAG_COMMUTATIVE ( 1ULL << 1 )
@@ -128,14 +128,14 @@ static const wsrep_uuid_t WSREP_UUID_UNDEFINED = {{0,}};
128128
* Scan UUID from string
129129
* @return length of UUID string representation or negative error code
130130
*/
131-
extern ssize_t
131+
extern int
132132
wsrep_uuid_scan (const char* str, size_t str_len, wsrep_uuid_t* uuid);
133133

134134
/*!
135135
* Print UUID to string
136136
* @return length of UUID string representation or negative error code
137137
*/
138-
extern ssize_t
138+
extern int
139139
wsrep_uuid_print (const wsrep_uuid_t* uuid, char* str, size_t str_len);
140140

141141
#define WSREP_MEMBER_NAME_LEN 32 //!< maximum logical member name length
@@ -163,14 +163,14 @@ static const wsrep_gtid_t WSREP_GTID_UNDEFINED = {{{0, }}, -1};
163163
* Scan GTID from string
164164
* @return length of GTID string representation or negative error code
165165
*/
166-
extern ssize_t
166+
extern int
167167
wsrep_gtid_scan(const char* str, size_t str_len, wsrep_gtid_t* gtid);
168168

169169
/*!
170170
* Print GTID to string
171171
* @return length of GTID string representation or negative error code
172172
*/
173-
extern ssize_t
173+
extern int
174174
wsrep_gtid_print(const wsrep_gtid_t* gtid, char* str, size_t str_len);
175175

176176
/*!
@@ -273,23 +273,23 @@ typedef void (*wsrep_view_cb_t) (void* app_ctx,
273273
const char* state,
274274
size_t state_len,
275275
void** sst_req,
276-
ssize_t* sst_req_len);
276+
int* sst_req_len);
277277

278278
/*!
279279
* @brief apply callback
280280
*
281-
* This handler is called from wsrep library to apply replicated write set
281+
* This handler is called from wsrep library to apply replicated writeset
282282
* Must support brute force applying for multi-master operation
283283
*
284284
* @param recv_ctx receiver context pointer provided by the application
285-
* @param data data buffer containing the write set
285+
* @param data data buffer containing the writeset
286286
* @param size data buffer size
287-
* @param meta transaction meta data of the write set to be applied
287+
* @param meta transaction meta data of the writeset to be applied
288288
*
289289
* @return success code:
290290
* @retval WSREP_OK
291-
* @retval WSREP_NOT_IMPLEMENTED appl. does not support the write set format
292-
* @retval WSREP_ERROR failed to apply the write set
291+
* @retval WSREP_NOT_IMPLEMENTED appl. does not support the writeset format
292+
* @retval WSREP_ERROR failed to apply the writeset
293293
*/
294294
typedef enum wsrep_status (*wsrep_apply_cb_t) (
295295
void* recv_ctx,
@@ -303,7 +303,7 @@ typedef enum wsrep_status (*wsrep_apply_cb_t) (
303303
* This handler is called to commit the changes made by apply callback.
304304
*
305305
* @param recv_ctx receiver context pointer provided by the application
306-
* @param meta transaction meta data of the write set to be committed
306+
* @param meta transaction meta data of the writeset to be committed
307307
* @param commit true - commit writeset, false - rollback writeset
308308
*
309309
* @return success code:
@@ -322,7 +322,7 @@ typedef enum wsrep_status (*wsrep_commit_cb_t) (
322322
* to be executed in any particular order) attached to writeset.
323323
*
324324
* @param recv_ctx receiver context pointer provided by the application
325-
* @param data data buffer containing the write set
325+
* @param data data buffer containing the writeset
326326
* @param size data buffer size
327327
*
328328
* @return success code:
@@ -436,20 +436,20 @@ struct wsrep_stats_var
436436
typedef struct wsrep_buf
437437
{
438438
const void* ptr; /*!< Pointer to data buffer */
439-
size_t len; /*!< Length of buffer */
439+
int len; /*!< Length of buffer (2G max)*/
440440
} wsrep_buf_t;
441441

442442
/*! Key struct used to pass certification keys for transaction handling calls.
443443
* A key consists of zero or more key parts. */
444444
typedef struct wsrep_key
445445
{
446446
const wsrep_buf_t* key_parts; /*!< Array of key parts */
447-
long key_parts_num; /*!< Number of key parts */
447+
int key_parts_num; /*!< Number of key parts */
448448
} wsrep_key_t;
449449

450450
/*! Key type:
451451
* EXCLUSIVE conflicts with any key type
452-
* SEMI reserved. If not supported, will be interpeted as EXCLUSIVE
452+
* SEMI reserved. If not supported, should be interpeted as EXCLUSIVE
453453
* SHARED conflicts only with EXCLUSIVE keys */
454454
typedef enum wsrep_key_type
455455
{
@@ -458,6 +458,19 @@ typedef enum wsrep_key_type
458458
WSREP_KEY_EXCLUSIVE
459459
} wsrep_key_type_t;
460460

461+
/*! Data type:
462+
* ORDERED state modification event that should be applied and committed
463+
* in order.
464+
* UNORDERED some action that does not modify state and execution of which is
465+
* optional and does not need to happen in order.
466+
* ANNOTATION (human readable) writeset annotation. */
467+
typedef enum wsrep_data_type
468+
{
469+
WSREP_DATA_ORDERED = 0,
470+
WSREP_DATA_UNORDERED,
471+
WSREP_DATA_ANNOTATION
472+
} wsrep_data_type_t;
473+
461474
/*! Transaction handle struct passed for wsrep transaction handling calls */
462475
typedef struct wsrep_ws_handle_
463476
{
@@ -596,7 +609,7 @@ struct wsrep_ {
596609
wsrep_conn_id_t conn_id,
597610
wsrep_ws_handle_t* ws_handle,
598611
// const struct wsrep_buf* data,
599-
// long count,
612+
// int count,
600613
uint64_t flags,
601614
wsrep_trx_meta_t* meta);
602615

@@ -623,11 +636,11 @@ struct wsrep_ {
623636
wsrep_ws_handle_t* ws_handle);
624637

625638
/*!
626-
* @brief Replay trx as a slave write set
639+
* @brief Replay trx as a slave writeset
627640
*
628641
* If local trx has been aborted by brute force, and it has already
629642
* replicated before this abort, we must try if we can apply it as
630-
* slave trx. Note that slave nodes see only trx write sets and certification
643+
* slave trx. Note that slave nodes see only trx writesets and certification
631644
* test based on write set content can be different to DBMS lock conflicts.
632645
*
633646
* @param wsrep provider handle
@@ -666,67 +679,46 @@ struct wsrep_ {
666679
wsrep_trx_id_t victim_trx);
667680

668681
/*!
669-
* @brief Appends a row reference to transaction write set
682+
* @brief Appends a row reference to transaction writeset
670683
*
671684
* Both copy flag and key_type can be ignored by provider (key type
672685
* interpreted as WSREP_KEY_EXCLUSIVE).
673686
*
674687
* @param wsrep provider handle
675688
* @param ws_handle writeset handle
676689
* @param keys array of keys
677-
* @param keys_num length of the array of keys
678-
* @param copy can be set to FALSE if keys persist until commit.
679-
* @param shared boolean denoting if key corresponds to shared resource
690+
* @param count length of the array of keys
691+
* @param type type ot the key
692+
* @param copy can be set to FALSE if keys persist through commit.
680693
*/
681694
wsrep_status_t (*append_key)(wsrep_t* wsrep,
682695
wsrep_ws_handle_t* ws_handle,
683696
const wsrep_key_t* keys,
684-
long keys_num,
685-
wsrep_key_type_t key_type,
697+
int count,
698+
enum wsrep_key_type type,
686699
wsrep_bool_t copy);
687700

688701
/*!
689-
* @brief Appends data to transaction write set
702+
* @brief Appends data to transaction writeset
690703
*
691704
* This method can be called any time before commit and it
692-
* appends a number of data buffers to transaction write set.
705+
* appends a number of data buffers to transaction writeset.
693706
*
694707
* Both copy and unordered flags can be ignored by provider.
695708
*
696709
* @param wsrep provider handle
697710
* @param ws_handle writeset handle
698711
* @param data array of data buffers
699712
* @param count buffer count
700-
* @param copy can be set to FALSE if data persists until commit.
701-
* @param unordered can be set to TRUE if this part of the write set
702-
* executed out of order.
713+
* @param type type of data
714+
* @param copy can be set to FALSE if data persists through commit.
703715
*/
704716
wsrep_status_t (*append_data)(wsrep_t* wsrep,
705717
wsrep_ws_handle_t* ws_handle,
706718
const struct wsrep_buf* data,
707-
long count,
708-
wsrep_bool_t copy,
709-
wsrep_bool_t unordered);
710-
711-
/*!
712-
* @brief Appends (human readable) annotation to transaction write set
713-
*
714-
* This method can be called any time before commit and it
715-
* appends array of strings to transaction write set.
716-
*
717-
* Copy flag can be ignored by provider.
718-
*
719-
* @param wsrep provider handle
720-
* @param ws_handle writeset handle
721-
* @param annotation array of annotation strings
722-
* @param count annotation string count
723-
* @param copy can be set to FALSE if data persists until commit.
724-
*/
725-
wsrep_status_t (*annotate)(wsrep_t* wsrep,
726-
wsrep_ws_handle_t* ws_handle,
727-
const char* annotation[],
728-
long count,
729-
wsrep_bool_t copy);
719+
int count,
720+
enum wsrep_data_type type,
721+
wsrep_bool_t copy);
730722

731723
/*!
732724
* @brief Get causal ordering for read operation
@@ -779,9 +771,9 @@ struct wsrep_ {
779771
wsrep_status_t (*to_execute_start)(wsrep_t* wsrep,
780772
wsrep_conn_id_t conn_id,
781773
const wsrep_key_t* keys,
782-
long keys_num,
774+
int keys_num,
783775
const struct wsrep_buf* action,
784-
long count,
776+
int count,
785777
wsrep_trx_meta_t* meta);
786778

787779
/*!
@@ -824,7 +816,7 @@ struct wsrep_ {
824816
const wsrep_uuid_t* source_id,
825817
int pa_range,
826818
const struct wsrep_buf* data,
827-
long count,
819+
int count,
828820
wsrep_bool_t copy);
829821

830822
/*!
@@ -872,7 +864,7 @@ struct wsrep_ {
872864
*/
873865
wsrep_status_t (*snapshot)(wsrep_t* wsrep,
874866
const void* msg,
875-
size_t msg_len,
867+
int msg_len,
876868
const char* donor_spec);
877869

878870
/*!

wsrep_dummy.c

+7-19
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static wsrep_status_t dummy_append_key(
148148
wsrep_t* w,
149149
wsrep_ws_handle_t* ws_handle __attribute__((unused)),
150150
const wsrep_key_t* key __attribute__((unused)),
151-
const long key_num __attribute__((unused)),
151+
const int key_num __attribute__((unused)),
152152
const wsrep_key_type_t key_type __attribute__((unused)),
153153
const bool copy __attribute__((unused)))
154154
{
@@ -160,19 +160,8 @@ static wsrep_status_t dummy_append_data(
160160
wsrep_t* w,
161161
wsrep_ws_handle_t* ws_handle __attribute__((unused)),
162162
const struct wsrep_buf* data __attribute__((unused)),
163-
const long count __attribute__((unused)),
164-
const bool copy __attribute__((unused)),
165-
const bool unordered __attribute__((unused)))
166-
{
167-
WSREP_DBUG_ENTER(w);
168-
return WSREP_OK;
169-
}
170-
171-
static wsrep_status_t dummy_annotate(
172-
wsrep_t* w,
173-
wsrep_ws_handle_t* ws_handle __attribute__((unused)),
174-
const char** annotation __attribute__((unused)),
175-
const long count __attribute__((unused)),
163+
const int count __attribute__((unused)),
164+
const wsrep_data_type_t type __attribute__((unused)),
176165
const bool copy __attribute__((unused)))
177166
{
178167
WSREP_DBUG_ENTER(w);
@@ -199,9 +188,9 @@ static wsrep_status_t dummy_to_execute_start(
199188
wsrep_t* w,
200189
const wsrep_conn_id_t conn_id __attribute__((unused)),
201190
const wsrep_key_t* key __attribute__((unused)),
202-
const long key_num __attribute__((unused)),
191+
const int key_num __attribute__((unused)),
203192
const struct wsrep_buf* data __attribute__((unused)),
204-
const long count __attribute__((unused)),
193+
const int count __attribute__((unused)),
205194
wsrep_trx_meta_t* meta __attribute__((unused)))
206195
{
207196
WSREP_DBUG_ENTER(w);
@@ -221,7 +210,7 @@ static wsrep_status_t dummy_preordered(
221210
const wsrep_uuid_t* source_id __attribute__((unused)),
222211
int pa_range __attribute__((unused)),
223212
const struct wsrep_buf* data __attribute__((unused)),
224-
long count __attribute__((unused)),
213+
int count __attribute__((unused)),
225214
wsrep_bool_t copy __attribute__((unused)))
226215
{
227216
WSREP_DBUG_ENTER(w);
@@ -251,7 +240,7 @@ static wsrep_status_t dummy_sst_received(
251240
static wsrep_status_t dummy_snapshot(
252241
wsrep_t* w,
253242
const void* msg __attribute__((unused)),
254-
const size_t msg_len __attribute__((unused)),
243+
const int msg_len __attribute__((unused)),
255244
const char* donor_spec __attribute__((unused)))
256245
{
257246
WSREP_DBUG_ENTER(w);
@@ -347,7 +336,6 @@ static wsrep_t dummy_iface = {
347336
&dummy_abort_pre_commit,
348337
&dummy_append_key,
349338
&dummy_append_data,
350-
&dummy_annotate,
351339
&dummy_causal_read,
352340
&dummy_free_connection,
353341
&dummy_to_execute_start,

wsrep_loader.c

-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ static int verify(const wsrep_t *wh, const char *iface_ver)
7272
VERIFY(wh->abort_pre_commit);
7373
VERIFY(wh->append_key);
7474
VERIFY(wh->append_data);
75-
VERIFY(wh->annotate);
7675
VERIFY(wh->free_connection);
7776
VERIFY(wh->to_execute_start);
7877
VERIFY(wh->to_execute_end);

0 commit comments

Comments
 (0)