Skip to content
Snippets Groups Projects
Commit 831a35d4 authored by Georgy Kirichenko's avatar Georgy Kirichenko Committed by Vladimir Davydov
Browse files

txn: Fire a trigger after a transaction finalization

Fire transaction trigger after a transaction finalization. This allows
to not to view the transaction dismissed changes in case of rollback.

Fixes: #4276
parent 6ee11c84
No related branches found
No related tags found
No related merge requests found
......@@ -427,6 +427,12 @@ txn_commit(struct txn *txn)
if (txn->signature < 0)
goto fail;
}
/*
* Engine can be NULL if transaction contains IPROTO_NOP
* statements only.
*/
if (txn->engine != NULL)
engine_commit(txn->engine, txn);
/*
* The transaction is in the binary log. No action below
* may throw. In case an error has happened, there is
......@@ -438,12 +444,6 @@ txn_commit(struct txn *txn)
unreachable();
panic("commit trigger failed");
}
/*
* Engine can be NULL if transaction contains IPROTO_NOP
* statements only.
*/
if (txn->engine != NULL)
engine_commit(txn->engine, txn);
struct txn_stmt *stmt;
stailq_foreach_entry(stmt, &txn->stmts, next)
......@@ -475,6 +475,8 @@ txn_rollback()
struct txn *txn = in_txn();
if (txn == NULL)
return;
if (txn->engine)
engine_rollback(txn->engine, txn);
/* Rollback triggers must not throw. */
if (txn->has_triggers &&
trigger_run(&txn->on_rollback, txn) != 0) {
......@@ -482,8 +484,6 @@ txn_rollback()
unreachable();
panic("rollback trigger failed");
}
if (txn->engine)
engine_rollback(txn->engine, txn);
struct txn_stmt *stmt;
stailq_foreach_entry(stmt, &txn->stmts, next)
......
......@@ -1686,3 +1686,40 @@ fio = require('fio')
box.space.test:drop()
---
...
-- gh-4276 - check grant privilege rollback
_ = box.schema.user.create('testg')
---
...
_ = box.schema.space.create('testg'):create_index('pk')
---
...
box.error.injection.set('ERRINJ_WAL_IO', true)
---
- ok
...
-- the grant operation above fails and test hasn't any space test permissions
box.schema.user.grant('testg', 'read,write', 'space', 'testg')
---
- error: Failed to write to disk
...
-- switch user and check they couldn't select
box.session.su('testg')
---
...
box.space.testg:select()
---
- error: Read access to space 'testg' is denied for user 'testg'
...
box.session.su('admin')
---
...
box.error.injection.set('ERRINJ_WAL_IO', false)
---
- ok
...
box.schema.user.drop('testg')
---
...
box.space.testg:drop()
---
...
......@@ -587,3 +587,18 @@ fio = require('fio')
#fio.glob(fio.pathjoin(box.cfg.vinyl_dir, box.space.test.id, 0, '*.index.inprogress')) == 0
box.space.test:drop()
-- gh-4276 - check grant privilege rollback
_ = box.schema.user.create('testg')
_ = box.schema.space.create('testg'):create_index('pk')
box.error.injection.set('ERRINJ_WAL_IO', true)
-- the grant operation above fails and test hasn't any space test permissions
box.schema.user.grant('testg', 'read,write', 'space', 'testg')
-- switch user and check they couldn't select
box.session.su('testg')
box.space.testg:select()
box.session.su('admin')
box.error.injection.set('ERRINJ_WAL_IO', false)
box.schema.user.drop('testg')
box.space.testg:drop()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment