[Tarantool-patches] [PATCH vshard 7/6] util: truncate too long fiber name

Oleg Babin olegrok at tarantool.org
Mon Jul 5 12:23:52 MSK 2021


Thanks for your patch! LGTM.

On 03.07.2021 00:36, Vladislav Shpilevoy wrote:
> Since tarantool's commit 008658b349264538f76327f8d60f2db5451854ea
> ("fiber: throw an error on too long fiber name") in version 1.7.6
> fiber:name() fails if the name is too long. But the error can be
> suppressed by using {truncate = true} option.
>
> The patch makes vshard truncate too long names instead of throwing
> an error.
> ---
>   test/unit/util.result   | 10 ++++++++++
>   test/unit/util.test.lua |  5 +++++
>   vshard/util.lua         |  2 +-
>   3 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/test/unit/util.result b/test/unit/util.result
> index c83e80c..ec61e8a 100644
> --- a/test/unit/util.result
> +++ b/test/unit/util.result
> @@ -71,6 +71,16 @@ test_run:grep_log('default', 'reloadable_function has been started', 1000)
>   fib:cancel()
>   ---
>   ...
> +-- Re-loadable fiber must truncate too long name.
> +name = string.rep('a', 512)
> +---
> +...
> +fib = util.reloadable_fiber_create(name, fake_M, 'reloadable_function')
> +---
> +...
> +fib:cancel()
> +---
> +...
>   -- Yielding table minus.
>   minus_yield = util.table_minus_yield
>   ---
> diff --git a/test/unit/util.test.lua b/test/unit/util.test.lua
> index 881feb4..5432c0d 100644
> --- a/test/unit/util.test.lua
> +++ b/test/unit/util.test.lua
> @@ -28,6 +28,11 @@ while not test_run:grep_log('default', 'module is reloaded, restarting') do fibe
>   test_run:grep_log('default', 'reloadable_function has been started', 1000)
>   fib:cancel()
>   
> +-- Re-loadable fiber must truncate too long name.
> +name = string.rep('a', 512)
> +fib = util.reloadable_fiber_create(name, fake_M, 'reloadable_function')
> +fib:cancel()
> +
>   -- Yielding table minus.
>   minus_yield = util.table_minus_yield
>   minus_yield({}, {}, 1)
> diff --git a/vshard/util.lua b/vshard/util.lua
> index 4d2c04e..afa658b 100644
> --- a/vshard/util.lua
> +++ b/vshard/util.lua
> @@ -90,7 +90,7 @@ local function reloadable_fiber_create(fiber_name, module, func_name, data)
>       assert(type(fiber_name) == 'string')
>       local xfiber = fiber.create(reloadable_fiber_main_loop, module, func_name,
>                                   data)
> -    xfiber:name(fiber_name)
> +    xfiber:name(fiber_name, {truncate = true})
>       return xfiber
>   end
>   


More information about the Tarantool-patches mailing list