From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: Mergen Imeev <imeevma@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH v1 1/1] sql: do not reset region on select Date: Thu, 17 Dec 2020 23:04:45 +0100 [thread overview] Message-ID: <60e8b082-4678-4e02-13e0-22ad74cc1c91@tarantool.org> (raw) In-Reply-To: <20201216053456.GA526090@tarantool.org> Hi! Thanks for the fixes! See 4 comments below. > diff --git a/src/box/txn.h b/src/box/txn.h > index dfa7c0ee4..1a5ec975e 100644 > --- a/src/box/txn.h > +++ b/src/box/txn.h > @@ -258,6 +258,13 @@ struct txn_savepoint { > char name[1]; > }; > > +struct txn_ro_savepoint { 1. Please, add a comment to this structure why does it exist. So far there was no a single comment anywhere why do we need RO statements/savepoints. Worth changing it while we are here. > + /** Region used during this transaction. */ > + struct region *region; > + /** Savepoint for region. */ > + size_t region_used; > +}; > + > extern double too_long_threshold; > > /** > @@ -557,24 +564,27 @@ txn_begin_in_engine(struct engine *engine, struct txn *txn); > * select. > */ > static inline int > -txn_begin_ro_stmt(struct space *space, struct txn **txn) > +txn_begin_ro_stmt(struct space *space, struct txn **txn, > + struct txn_ro_savepoint *svp) > { > *txn = in_txn(); > if (*txn != NULL) { > struct engine *engine = space->engine; > return txn_begin_in_engine(engine, *txn); > } > + svp->region = &fiber()->gc; > + svp->region_used = region_used(svp->region); > return 0; > } > > static inline void > -txn_commit_ro_stmt(struct txn *txn) > +txn_commit_ro_stmt(struct txn *txn, struct txn_ro_savepoint *svp) > { > assert(txn == in_txn()); > if (txn) { > /* nothing to do */ > } else { > - fiber_gc(); > + region_truncate(svp->region, svp->region_used); 2. What exactly do the ro requests allocate on the fiber region? I couldn't find any examples in memtx, but I didn't look too deep. > } > } > > diff --git a/test/sql/gh-5427-lua-func-changes-result.result b/test/sql/gh-5427-lua-func-changes-result.result > new file mode 100644 > index 000000000..f2e777a0e > --- /dev/null > +++ b/test/sql/gh-5427-lua-func-changes-result.result > @@ -0,0 +1,153 @@ > +-- test-run result file version 2 > +test_run = require('test_run').new() > + | --- > + | ... > +engine = test_run:get_cfg('engine') > + | --- > + | ... > +_ = box.space._session_settings:update('sql_default_engine', {{'=', 2, engine}}) > + | --- > + | ... > + > +box.execute([[CREATE TABLE t (b STRING PRIMARY KEY);]]) > + | --- > + | - row_count: 1 > + | ... > +box.execute([[INSERT INTO t VALUES ('aaaaaaaaaaaa');]]) > + | --- > + | - row_count: 1 > + | ... > +test_run:cmd("setopt delimiter ';'"); > + | --- > + | - true > + | ... > +box.schema.func.create('CORRUPT_SELECT', { > + language = 'LUA', > + returns = 'integer', > + body = [[ > + function(x) > + box.space.T:select() > + return 1 > + end]], > + is_sandboxed = false, > + param_list = { "string" }, > + exports = { 'LUA', 'SQL' }, > + is_deterministic = false, > + if_not_exists = true > +}); > + | --- > + | ... > +box.schema.func.create('CORRUPT_GET', { > + language = 'LUA', > + returns = 'integer', > + body = [[ > + function(x) > + box.space.T:get('aaaaaaaaaaaa') > + return 1 > + end]], > + is_sandboxed = false, > + param_list = { "string" }, > + exports = { 'LUA', 'SQL' }, > + is_deterministic = false, > + if_not_exists = true > +}); > + | --- > + | ... > +box.schema.func.create('CORRUPT_COUNT', { > + language = 'LUA', > + returns = 'integer', > + body = [[ > + function(x) > + box.space.T:count() > + return 1 > + end]], > + is_sandboxed = false, > + param_list = { "string" }, > + exports = { 'LUA', 'SQL' }, > + is_deterministic = false, > + if_not_exists = true > +}); > + | --- > + | ... > +box.schema.func.create('CORRUPT_MAX', { > + language = 'LUA', > + returns = 'integer', > + body = [[ > + function(x) > + box.space.T.index[0]:max() > + return 1 > + end]], > + is_sandboxed = false, > + param_list = { "string" }, > + exports = { 'LUA', 'SQL' }, > + is_deterministic = false, > + if_not_exists = true > +}); > + | --- > + | ... > +box.schema.func.create('CORRUPT_MIN', { > + language = 'LUA', > + returns = 'integer', > + body = [[ > + function(x) > + box.space.T.index[0]:min() > + return 1 > + end]], > + is_sandboxed = false, > + param_list = { "string" }, > + exports = { 'LUA', 'SQL' }, > + is_deterministic = false, > + if_not_exists = true > +}); > + | --- > + | ... > +test_run:cmd("setopt delimiter ''"); > + | --- > + | - true > + | ... > + > +box.execute([[select CORRUPT_SELECT(t.b) from t where t.b = ? and t.b <= ? order by t.b;]], {"aaaaaaaaaaaa", "aaaaaaaaaaaa"}) > + | --- > + | - metadata: > + | - name: COLUMN_1 > + | type: integer > + | rows: > + | - [1] > + | ... > +box.execute([[select CORRUPT_GET(t.b) from t where t.b = ? and t.b <= ? order by t.b;]], {"aaaaaaaaaaaa", "aaaaaaaaaaaa"}) > + | --- > + | - metadata: > + | - name: COLUMN_1 > + | type: integer > + | rows: > + | - [1] > + | ... > +box.execute([[select CORRUPT_COUNT(t.b) from t where t.b = ? and t.b <= ? order by t.b;]], {"aaaaaaaaaaaa", "aaaaaaaaaaaa"}) > + | --- > + | - metadata: > + | - name: COLUMN_1 > + | type: integer > + | rows: > + | - [1] > + | ... > +box.execute([[select CORRUPT_MAX(t.b) from t where t.b = ? and t.b <= ? order by t.b;]], {"aaaaaaaaaaaa", "aaaaaaaaaaaa"}) > + | --- > + | - metadata: > + | - name: COLUMN_1 > + | type: integer > + | rows: > + | - [1] > + | ... > +box.execute([[select CORRUPT_MIN(t.b) from t where t.b = ? and t.b <= ? order by t.b;]], {"aaaaaaaaaaaa", "aaaaaaaaaaaa"}) 3. Please, keep 80 symbols line width limit. > + | --- > + | - metadata: > + | - name: COLUMN_1 > + | type: integer > + | rows: > + | - [1] > + | ... > + > +box.execute([[DROP TABLE t;]]) 4. You also need to drop the functions. > + | --- > + | - row_count: 1 > + | ...
next prev parent reply other threads:[~2020-12-17 22:04 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-02 9:49 imeevma 2020-11-04 22:14 ` Vladislav Shpilevoy 2020-12-16 5:34 ` Mergen Imeev 2020-12-17 22:04 ` Vladislav Shpilevoy [this message] 2020-12-22 19:30 ` Mergen Imeev 2020-12-23 14:58 ` Vladislav Shpilevoy 2020-12-23 19:20 ` Mergen Imeev 2020-12-23 19:15 imeevma 2020-12-24 10:48 ` Nikita Pettik 2020-12-24 10:58 ` Nikita Pettik
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=60e8b082-4678-4e02-13e0-22ad74cc1c91@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=imeevma@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v1 1/1] sql: do not reset region on select' \ /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