[Tarantool-patches] [PATCH] box: sql prepare and execute statistics should be reflected in box.stat()

Nikita Pettik korablev at tarantool.org
Wed Feb 19 20:16:02 MSK 2020


On 19 Feb 19:37, Maria Khaydich wrote:
> 
> Thank you for the review!
> Proposed fixes are done.
>  
> ----------------------------------------------------------------------
> Calling prepare and execute did not update corresponding request statistics
> in the box.stat table. This happened because methods that collect stats were
> never called where they should have been.
>  
> Closes #4756

Please also add @ChangeLog according to our new sop guide. For instance,
see: https://lists.tarantool.org/pipermail/tarantool-patches/2020-February/014301.html
 
>  space = nil
>  ---
>  ...
> +--
> +-- gh-4756: PREPARE and EXECUTE statistics should be present in box.stat()
> +--
> +p = box.stat().PREPARE.total
> +---
> +...
> +e = box.stat().EXECUTE.total
> +---
> +...
> +s = box.prepare([[ SELECT ?; ]])
> +---
> +...
> +s:execute({42})
> +---
> +- metadata:
> +  - name: '?'
> +    type: integer
> +  rows:
> +  - [42]
> +...
> +box.stat().PREPARE.total == p + 1
> +---
> +- true
> +...
> +box.stat().EXECUTE.total == e + 1
> +---
> +- true
> +...
>  -- Cleanup xlog
>  box.snapshot()
>  ---
>  
> diff --git a/test/sql/iproto.test.lua b/test/sql/iproto.test.lua
> index 4019fb7a4..1417aa32b 100644
> --- a/test/sql/iproto.test.lua
> +++ b/test/sql/iproto.test.lua
> @@ -242,5 +242,17 @@ box.schema.user.revoke('guest', 'read,write,execute', 'universe')
>  box.schema.user.revoke('guest', 'create', 'space')
>  space = nil
>  
> +--
> +-- gh-4756: PREPARE and EXECUTE statistics should be present in box.stat()
> +--
> +p = box.stat().PREPARE.total
> +e = box.stat().EXECUTE.total
> +
> +s = box.prepare([[ SELECT ?; ]])
> +s:execute({42})

You also have to unprepare statement. Otherwise it gets stuck in
cache and sql/prepare.test.lua may fail since at the start of
execution it checks cahce size:
https://travis-ci.org/tarantool/tarantool/jobs/652552114?utm_medium=notification&utm_source=github_status

It is sort of basic clean-up which is provided for any schema object
(spaces, triggers etc).

> +box.stat().PREPARE.total == p + 1
> +box.stat().EXECUTE.total == e + 1
> +

Nit: I'd better wrap these statements into asssertions:

assert(box.stat().PREPARE.total == p + 1)



More information about the Tarantool-patches mailing list