[Tarantool-patches] [PATCH 1/2] vinyl: init all vars before cleanup in vy_lsm_split_range()

Nikita Pettik korablev at tarantool.org
Thu Apr 9 14:26:00 MSK 2020


On 09 Apr 14:07, Konstantin Osipov wrote:
> * Nikita Pettik <korablev at tarantool.org> [20/04/09 14:00]:
> > On 09 Apr 11:18, Konstantin Osipov wrote:
> > > * Nikita Pettik <korablev at tarantool.org> [20/04/09 00:39]:
> > > 
> > > > +	struct errinj *inj = errinj(ERRINJ_VY_MAX_TUPLE_SIZE, ERRINJ_INT);
> > > > +	if (inj != NULL && inj->iparam >= 0) {
> > > > +		if (inj->iparam-- == 0)
> > > > +			total_size = vy_max_tuple_size + 1;
> > > > +	}
> > > 
> > > shouldn't this be under #ifdef
> > 
> > Looks like not: most of other errinj() calls are not wrapped in
> > #ifdef NDEBUG macro (in case of debug build errinj() always
> > returns NULL).
> 
> In most cases the compiler can optimize these away, but the rules
> are complicated.
> Regarding other uses of errinj() one should take into
> consideration whether it's a hot path or not, whether the code
> in which injection is used is small/simple or not, etc.
> 
> I'd say as a rule of thumb anything using errinj and is multiline
> is better off using #ifdef.

Ok, as you wish, I don't mind this change. Diff:

diff --git a/src/box/vy_stmt.c b/src/box/vy_stmt.c
index d2469961f..e822137ec 100644
--- a/src/box/vy_stmt.c
+++ b/src/box/vy_stmt.c
@@ -134,11 +134,13 @@ vy_stmt_alloc(struct tuple_format *format, uint32_t bsize)
 {
        uint32_t total_size = sizeof(struct vy_stmt) + format->field_map_size +
                bsize;
+#ifndef NDEBUG
        struct errinj *inj = errinj(ERRINJ_VY_MAX_TUPLE_SIZE, ERRINJ_INT);
        if (inj != NULL && inj->iparam >= 0) {
                if (inj->iparam-- == 0)
                        total_size = vy_max_tuple_size + 1;
        }
+#endif
        if (unlikely(total_size > vy_max_tuple_size)) {
                diag_set(ClientError, ER_VINYL_MAX_TUPLE_SIZE,
                         (unsigned) total_size);

 
> > > The patch is LGTM, please solicit another review.
> 
> -- 
> Konstantin Osipov, Moscow, Russia
> https://scylladb.com


More information about the Tarantool-patches mailing list