Skip to content

Memory leak on replica disconnection from origin #10480

@nshy

Description

@nshy

Found by ASAN.

Reproducer.

Start a master:

local fiber = require('fiber')
box.cfg{
    memtx_max_tuple_size = 128 * 1024 * 1024,
    memtx_memory = 1024 * 1024 * 1024,
    replication_timeout = 10,
    work_dir = 'box-a',
    listen = 3301,
    read_only = false,
}
box.schema.user.grant('guest', 'super', nil, nil, {if_not_exists = true})
local space = box.schema.create_space('test')
space:create_index('pk')
while true do
    space:replace({1, string.rep(s, 128 * 1024 * 1024 - 100)})
    fiber.sleep(0.1)
    collectgarbage()
end

Start a replica:

local fiber = require('fiber')
box.cfg{
    memtx_max_tuple_size = 128 * 1024 * 1024, -- we need large tuples to make applier leak fast
    memtx_memory = 1024 * 1024 * 1024,
    replication_timeout = 10, -- default does not allow transmitting very large tuples
    work_dir = 'box-b',
    replication = 'localhost:3301',
    read_only = true,
}
while true do
    box.cfg{replication = {}}
    fiber.sleep(1) -- let master's relay finish disconnecting from this replica
    local lsn = box.info().replication[1].lsn
    box.cfg{replication = 'localhost:3301'}
    -- Make sure we read a tuple from master before disconnecting, so the leak is of tuple size
    while box.info().replication[1].lsn == lsn do
        fiber.sleep(0.01)
    end
end

The replica leak noticeably (I wait until it reached about 3 Gb).

Introduced in 2.10.0-beta2-53-gdacbf708f4.

Metadata

Metadata

Assignees

Labels

2.11Target is 2.11 and all newer release/master branches3.2Target is 3.2 and all newer release/master branchesbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions