Skip to content

core: disable rw triggers on replicas#248

Open
ShelbyKS wants to merge 1 commit into
tarantool:masterfrom
ShelbyKS:NOTASK-disable-rw-triggers-on-replicas
Open

core: disable rw triggers on replicas#248
ShelbyKS wants to merge 1 commit into
tarantool:masterfrom
ShelbyKS:NOTASK-disable-rw-triggers-on-replicas

Conversation

@ShelbyKS
Copy link
Copy Markdown

No description provided.

@Col-Waltz
Copy link
Copy Markdown

Thank you for the patch!

Please provide proper commit message for your changes:

core: disable rw triggers on replicas

<Some information about changes and implementation reason>

after leader change in cluster there are ERR_READONLY errors on previous leader while processing on_disconnect triggers. I guess we can add early exit on replicas
@ShelbyKS ShelbyKS force-pushed the NOTASK-disable-rw-triggers-on-replicas branch from 0d8b2b2 to 7c56265 Compare May 28, 2026 15:23
@ShelbyKS
Copy link
Copy Markdown
Author

provided propper commit message

@ShelbyKS ShelbyKS changed the title NOTASK: disable rw triggers on replicas core: disable rw triggers on replicas May 28, 2026
@Col-Waltz
Copy link
Copy Markdown

Col-Waltz commented Jun 2, 2026

Thanks for providing a proper commit message, now I see some problems in this solution:

  1. ERR_READONLY error signals that we try to modify data on RO instance. It is more safe to rely on box.info.ro to protect RO instanse from modifying.

  2. _on_consumer_disconnect wakes all waiters so they can close their connections. Waiters operate with local fields and do not modify data itself, but it is useful if this instance will become master again. So it is safe to wake them up and it is better to do this so that they don't wait ttl.

I suggest to fix _on_consumer_disconnect like this:

local consumers = box.space._queue_consumers
local waiters = consumers.index.pk:select{conn_id}

for _, waiter in ipairs(waiters) do
        local fid = waiter[2]
        local cond = conds[fid]
        if cond then
            releasing_connections[fid] = true
            cond:signal(fid)
        end

        if not box.info.ro then
            consumers:delete{waiter[1], waiter[2]}
        end
    end

So we will wake up waiters, but delete them only if it is safe.

And session_disconnect also should be protected:

if not box.info.ro then
    session.disconnect(conn_id)
end

I will implement this changes myself in other PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants