Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It's possible to commit a write transaction after becoming read-only with mvcc #9937

Open
sergepetrenko opened this issue Apr 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@sergepetrenko
Copy link
Collaborator

Bug description

Tarantool version: 3.1.0-entrypoint-234-g4466deafee

Our read-only checks only work when corresponding write statements are executed, and not on transaction commit.
So if code executing a transaction writes something and then yields before commit (which's possible with MVCC), and the node becomes read-only during this yield, the commit will happen anyway, writing data on a read-only node.

Since the WAL write is initiated only on transaction commit, this means a node may continue writing data after becoming read-only, breaking all the expectations about being read-only.

Steps to reproduce

Run a single tarantool instance in interactive mode and issue:

-- Step 1.
box.cfg{memtx_use_mvcc_engine = true}
s = box.schema.space.create('test')
_ = s:create_index('pk')

-- Step 2.
fiber = require('fiber')
log = require('log')
fiber.new(function()
    box.begin()
    log.info("read-only status before yield is %s", box.info.ro)
    s:insert{1}
    fiber.sleep(5)
    log.info("read-only status after yield is %s", box.info.ro)
    box.commit()
end)
box.cfg{read_only = true}

-- Step 3. Wait a bit (until the transaction above is committed), then do:
s:fselect{}

Actual behavior

During step 2 the logs will show:

2024-04-11 13:47:18.040 [30674] main/117/lua/tarantool I> read-only status before yield is false
tarantool> box.cfg{read_only = true}
2024-04-11 13:47:18.345 [30674] main/104/interactive/box.load_cfg I> set 'read_only' configuration option to true
2024-04-11 13:47:23.038 [30674] main/117/lua/tarantool I> read-only status after yield is true

And step 3 output:


tarantool> s:fselect{}
---
- |-
  +-----+
  |col1 |
  +-----+
  |  1  |
  +-----+
...

Expected behavior

box.commit() from the example above should fail and throw an error.
Something like: The node became read-only while the transaction was processed.

@sergepetrenko sergepetrenko added the bug Something isn't working label Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant