Skip to content

Commit

Permalink
xrow: remove SYNCHRO_BODY_LEN_MAX constant
Browse files Browse the repository at this point in the history
Synchronous requests will receive a new field encoding a full vclock
soon. Theoretically a vclock may take up to ~ 300-400 bytes (3 bytes for
a map header + 32 components each taking up 1 byte for replica id and up
to 9 bytes for lsn). So it makes no sense to increase
SYNCHRO_BODY_LEN_MAX from 32 to 400-500. It would become almost the same
as plain BODY_LEN_MAX. Simply reuse the latter everywhere.

In-scope-of #9138

NO_DOC=refactoring
NO_TEST=refactoring
NO_CHANGELOG=refactoring

(cherry picked from commit 5360577)
  • Loading branch information
sergepetrenko committed Dec 2, 2023
1 parent 77853be commit 8d457af
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/box/memtx_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ static int
checkpoint_write_synchro(struct xlog *l, const struct synchro_request *req)
{
struct xrow_header row;
char body[XROW_SYNCHRO_BODY_LEN_MAX];
char body[XROW_BODY_LEN_MAX];
xrow_encode_synchro(&row, body, req);
return checkpoint_write_row(l, &row);
}
Expand Down
2 changes: 1 addition & 1 deletion src/box/relay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ relay_initial_join(struct iostream *io, uint64_t sync, struct vclock *vclock,
xrow_encode_raft(&row, &fiber()->gc, &raft_req);
xstream_write(&relay->stream, &row);

char body[XROW_SYNCHRO_BODY_LEN_MAX];
char body[XROW_BODY_LEN_MAX];
xrow_encode_synchro(&row, body, &req);
row.replica_id = req.replica_id;
xstream_write(&relay->stream, &row);
Expand Down
2 changes: 1 addition & 1 deletion src/box/txn_limbo.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ synchro_request_write(const struct synchro_request *req)
* This is a synchronous commit so we can
* allocate everything on a stack.
*/
char body[XROW_SYNCHRO_BODY_LEN_MAX];
char body[XROW_BODY_LEN_MAX];
struct xrow_header row;
char buf[sizeof(struct journal_entry) +
sizeof(struct xrow_header *)];
Expand Down
2 changes: 1 addition & 1 deletion src/box/xrow.c
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ xrow_encode_synchro(struct xrow_header *row, char *body,
pos = mp_encode_uint(pos, req->term);
}

assert(pos - body < XROW_SYNCHRO_BODY_LEN_MAX);
assert(pos - body < XROW_BODY_LEN_MAX);

memset(row, 0, sizeof(*row));
row->type = req->type;
Expand Down
3 changes: 1 addition & 2 deletions src/box/xrow.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ enum {
XROW_BODY_IOVMAX = 2,
XROW_IOVMAX = XROW_HEADER_IOVMAX + XROW_BODY_IOVMAX,
XROW_HEADER_LEN_MAX = 52,
XROW_BODY_LEN_MAX = 256,
XROW_SYNCHRO_BODY_LEN_MAX = 32,
XROW_BODY_LEN_MAX = 512,
IPROTO_HEADER_LEN = 32,
/** 7 = sizeof(iproto_body_bin). */
IPROTO_SELECT_HEADER_LEN = IPROTO_HEADER_LEN + 7,
Expand Down

0 comments on commit 8d457af

Please sign in to comment.