[Tarantool-patches] [PATCH] replication: stop pushing TimedOut error to the replica

Serge Petrenko sergepetrenko at tarantool.org
Mon Jul 12 13:14:09 MSK 2021



09.07.2021 13:41, Cyrill Gorcunov пишет:
> On Fri, Jul 09, 2021 at 11:30:20AM +0300, Serge Petrenko wrote:
>> Thanks! No problem, will rework.
>> It might be better to not allocate any string at all.
>> I can simply allocate the needed buffer on the region (where the msgpack
>> will be encoded), and encode the string header, and leave the
>> buffer with whatever contents it has (it'll probably be filled
>> with 0x50 bytes, it's the slab poison symbol).
>>
>> Cool, good idea!

I've found an even better solution:

We don't care for the actual contents of the error, so
it's fine to fill the buffer with whatever junk we come up with.
(That's because the error is meant to fill the remaining buffer
space after a partially written row).
'E' is for error injection, since we have 'P' for slab poison.

I've force-pushed the following change:

====================

diff --git a/src/box/xrow.c b/src/box/xrow.c
index fae9861a5..c4647c6cb 100644
--- a/src/box/xrow.c
+++ b/src/box/xrow.c
@@ -552,10 +552,8 @@ iproto_write_error(int fd, const struct error *e, 
uint32_t schema_version,
         mpstream_iproto_encode_error(&stream, e);
         struct errinj *inj = errinj(ERRINJ_IPROTO_WRITE_ERROR_LARGE,
                                     ERRINJ_INT);
-       if (inj != NULL && inj->iparam > 0) {
-               char garbage[inj->iparam];
-               mpstream_encode_strn(&stream, garbage, inj->iparam);
-       }
+       if (inj != NULL && inj->iparam > 0)
+               mpstream_memset(&stream, 'E', inj->iparam);
         mpstream_flush(&stream);
         if (is_error)
                 goto cleanup;

=====================

-- 
Serge Petrenko



More information about the Tarantool-patches mailing list