From: Alexander Turenko <alexander.turenko@tarantool.org> To: Maria Khaydich <maria.khaydich@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH] box: make box.execute() immutable Date: Tue, 12 May 2020 19:16:59 +0300 [thread overview] Message-ID: <20200512161659.lzelms6je2vni64d@tkn_work_nb> (raw) In-Reply-To: <1583942174.197473001@f388.i.mail.ru> > >I considered using of `type(box.cfg) == 'function'` check as in > >tarantoolctl, but in fact it is not realiable: if box was not configured > >after box.cfg() due to an error (say, after `box.cfg{listen = > >'invalid'}`) the type of box.cfg will be 'table' and reload_cfg() will > >work on the next box.cfg() call. So we should use box_is_configured C > >function: > > > > | local ffi = require('ffi') > > | > > | ffi.cdef([[ > > | bool > > | box_is_configured(void); > > | ]]) > > | > > | local function box_is_configured() > > | return ffi.C.box_is_configured() > > | end I was not right here: `type(box.cfg)` is changed only at successful box configuration, however it is performed before full box loading that is not suitable for box.execute(). We can set a module local `box_is_configured` variable at end of box configuration to eliminate the ffi call. I'll update and resend the patchset soon. > >BTW, it seems that it is possible that <box_load_and_execute> will be > >called when `box.cfg{}` is already in progress in another fiber: this is > >why all load_cfg() / reload_cfg() calls are decorated using `locked` > >wrapper. It seems we should do the same in <box_load_and_execute>: > > > > | function box.execute(...) > > | if not box_is_configured() then > > | locked(function() > > | -- Re-check, because after the lock release the box > > | -- state may be changed. We should call load_cfg() > > | -- only once. > > | if not box_is_configured() then > > | load_cfg() > > | end > > | end)() > > | end > > | return box.execute(...) > > | end > > > >I experimented with this like so: > > > > | $ ./src/tarantool > > | tarantool> box_execute = box.execute > > | tarantool> for i = 1, 10 do require('fiber').create(function() require('log').info(require('yaml').encode((box_execute('SELECT * FROM "_vindex"')))) end) end I'll add such test case.
next prev parent reply other threads:[~2020-05-12 16:17 UTC|newest] Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-11-14 11:50 [Tarantool-patches] [PATCH] box.execute should be immutable function Maria 2019-11-14 16:51 ` Nikita Pettik 2019-12-17 14:39 ` Igor Munkin 2019-12-24 15:32 ` [Tarantool-patches] [PATCH] box: make box.execute() immutable Maria Khaydich 2019-12-25 1:30 ` Igor Munkin 2019-12-26 14:08 ` Alexander Turenko 2020-01-13 12:13 ` Maria Khaydich 2020-01-13 15:48 ` Igor Munkin 2020-01-18 10:56 ` Maria Khaydich 2020-02-20 17:51 ` Alexander Turenko 2020-02-20 21:15 ` Igor Munkin 2020-03-11 15:56 ` Maria Khaydich 2020-03-18 22:25 ` Igor Munkin 2020-05-02 14:52 ` Alexander Turenko 2020-05-12 16:16 ` Alexander Turenko [this message] 2020-03-11 15:57 ` [Tarantool-patches] [PATCH 1/2] box: make box.cfg idempotent function Maria Khaydich 2020-03-12 13:29 ` Konstantin Osipov 2020-03-12 19:25 ` Maria Khaydich 2020-03-12 20:00 ` Konstantin Osipov 2020-03-18 22:26 ` Igor Munkin 2020-03-19 7:19 ` Konstantin Osipov 2020-03-19 9:08 ` Igor Munkin 2020-03-19 10:06 ` Konstantin Osipov 2020-03-19 10:26 ` Igor Munkin 2020-05-06 11:17 ` Alexander Turenko 2020-05-06 11:49 ` Konstantin Osipov 2020-05-06 12:53 ` Alexander Turenko 2020-05-06 13:02 ` Konstantin Osipov 2020-05-06 13:13 ` Alexander Turenko 2020-03-18 22:26 ` Igor Munkin 2020-05-12 16:17 ` Alexander Turenko
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200512161659.lzelms6je2vni64d@tkn_work_nb \ --to=alexander.turenko@tarantool.org \ --cc=maria.khaydich@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH] box: make box.execute() immutable' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox