Skip to content

Function IDs overflow in box.space._func on frequent box.schema.func.drop/box.schema.func.create #11851

@msiomkin

Description

@msiomkin

Bug description

Typical code for updating functions on application initialization looks like this:

    box.schema.func.drop("cfn.pm_strftime", { if_exists = true })
    box.schema.func.create("cfn.pm_strftime", {
        language = "C",
        param_list = { "unsigned", "string" },
        returns = "string",
        exports = { "LUA", "SQL" },
        is_deterministic = true
    })
    box.schema.role.grant("public", "execute", "function", "cfn.pm_strftime")

    box.schema.func.drop("cfn.pm_strptime", { if_exists = true })
    box.schema.func.create("cfn.pm_strptime", {
        language = "C",
        param_list = { "string", "string" },
        returns = "unsigned",
        exports = { "LUA", "SQL" },
        is_deterministic = true
    })
    box.schema.role.grant("public", "execute", "function", "cfn.pm_strptime")

    box.schema.func.drop("cfn.pm_timepart", { if_exists = true })
    box.schema.func.create("cfn.pm_timepart", {
        language = "C",
        param_list = { "unsigned", "unsigned" },
        returns = "unsigned",
        exports = { "LUA", "SQL" },
        is_deterministic = true
    })
    box.schema.role.grant("public", "execute", "function", "cfn.pm_timepart")

This code increases functions IDs by three on every restart of the app. If there are a lot of functions we have a bigger delta. The maximum ID is hardcoded to 32000. If we restart the app regularly by schedule we'll have an overflow soon.

IDs must be the same after drop/create or at least mustn't grow monotonously.

A possible solution is to reuse gaps for ID values. Two other solutions are mentioned here: #11849

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions