[tarantool-patches] Re: [PATCH v2 3/4] wal: xrow buffer cursor

Konstantin Osipov kostja.osipov at gmail.com
Fri Sep 20 10:47:40 MSK 2019


* Georgy Kirichenko <georgy at tarantool.org> [19/09/18 12:39]:
> This structure enables to find a xrow buffer row less than given vclock
> and then fetch row by row from the xrow forwards to the last appended ones.
> A xrow buffer cursor is essential to allow from memory replication because
> of relay which required to be able to fetch all log rows, stored in a wal
> memory (implemented as xrow buffer), from given position and then follow
> all new changes.
> 
> Prerequisites: #3794
> ---
>  src/box/xrow_buf.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++
>  src/box/xrow_buf.h | 22 +++++++++++++++++
>  2 files changed, 81 insertions(+)
> 
> diff --git a/src/box/xrow_buf.c b/src/box/xrow_buf.c
> index d690ac4b7..c73e3acb2 100644
> --- a/src/box/xrow_buf.c
> +++ b/src/box/xrow_buf.c
> @@ -218,3 +218,62 @@ error:
>  	return -1;
>  }
>  
> +int
> +xrow_buf_cursor_create(struct xrow_buf *xrow_buf,
> +		      struct xrow_buf_cursor *xrow_buf_cursor,
> +		      struct vclock *vclock)
> +{
> +	uint64_t chunk_gen;
> +	for (chunk_gen = xrow_buf->first_chunk_gen;
> +	     chunk_gen <= xrow_buf->last_chunk_gen;
> +	     ++chunk_gen) {
> +		struct xrow_buf_chunk *chunk =
> +			xrow_buf->chunk + chunk_gen % XROW_BUF_CHUNK_COUNT;
> +		int rc = vclock_compare(&chunk->vclock, vclock);
> +		if (rc != 0 && rc != -1)
> +			break;
> +	}
> +	if (chunk_gen == xrow_buf->first_chunk_gen)
> +		return -1;
> +	xrow_buf_cursor->chunk_gen = chunk_gen - 1;
> +	xrow_buf_cursor->row_index = 0;
> +	return 0;

How does chunk_gen variable works? Obviously it is used to track 
replicas which have fallen behind. But how does it coordinate with
the total xrow_buf size? How do you make a decision whether to
obsolete a cursor or increase the amount of memory consumed?

This should be in the comments to this function implementation or
in the function body.


-- 
Konstantin Osipov, Moscow, Russia




More information about the Tarantool-patches mailing list