Skip to content

box: fix _func id overflow#12004

Merged
sergepetrenko merged 2 commits intotarantool:masterfrom
LevKats:box-func-id-overflow-fix
Dec 5, 2025
Merged

box: fix _func id overflow#12004
sergepetrenko merged 2 commits intotarantool:masterfrom
LevKats:box-func-id-overflow-fix

Conversation

@LevKats
Copy link
Contributor

@LevKats LevKats commented Oct 29, 2025

Each time one used the box.schema.func.create, the primary key of
the resulted function increased because of the
_func:auto_increment. Now the new key is chosen by the
generate_func_id in Lua and OP_GenFuncid SQL opcode, both implemented
using the new box_generate_func_id function that shares logic with
box_generate_space_id. Hence we are scanning the entire range of
possible ids [0, BOX_FUNCTION_MAX) before we are returning an
error.

Fixes #11849
Fixes #11851
NO_DOC=bugfix

@LevKats LevKats self-assigned this Oct 29, 2025
@LevKats LevKats requested a review from a team as a code owner October 29, 2025 17:17
@LevKats LevKats force-pushed the box-func-id-overflow-fix branch 3 times, most recently from f3d9e90 to 65f39fb Compare October 29, 2025 17:57
@coveralls
Copy link

coveralls commented Oct 29, 2025

Coverage Status

coverage: 87.616% (-0.01%) from 87.628%
when pulling 5d695f8 on LevKats:box-func-id-overflow-fix
into dd2a620
on tarantool:master
.

@LevKats LevKats added the asan-ci Enables asan build tests for a pull request label Oct 30, 2025
Copy link
Collaborator

@ImeevMA ImeevMA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Thanks for the patch. I have a few comments regarding the SQL part, please review them. As for the patch as a whole, I think it's a bit overcomplicated. Do we even need a universal function for generating space and function identifiers? Introducing a function to generate the function identifier seems like a simpler solution. Just a thought, though.

@LevKats LevKats force-pushed the box-func-id-overflow-fix branch 3 times, most recently from 2d52f6f to fe23e34 Compare October 31, 2025 12:22
@LevKats LevKats removed the asan-ci Enables asan build tests for a pull request label Oct 31, 2025
@LevKats LevKats requested a review from ImeevMA October 31, 2025 12:28
Copy link
Collaborator

@ImeevMA ImeevMA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fixes! I have just one comment for SQL part.

I have a few comments on the non-SQL part:

  1. I still think that there is no need to complicate the code due to function ID generation.
  2. Name of the test-file usually starts with gh-... for non-general tests. Also, you can just add the test to box-luatest/func_test.lua.

But I leave this part to @sergepetrenko

@ImeevMA ImeevMA removed their assignment Oct 31, 2025
@LevKats LevKats force-pushed the box-func-id-overflow-fix branch from fe23e34 to a32dd13 Compare October 31, 2025 19:32
Copy link
Collaborator

@sergepetrenko sergepetrenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch!

@sergepetrenko sergepetrenko removed their assignment Nov 7, 2025
@LevKats LevKats force-pushed the box-func-id-overflow-fix branch 3 times, most recently from 81bce09 to f554899 Compare November 18, 2025 03:47
@sergepetrenko sergepetrenko added backport/3.2 Automatically create a 3.2 backport PR backport/3.3 Automatically create a 3.3 backport PR labels Nov 19, 2025
@LevKats LevKats force-pushed the box-func-id-overflow-fix branch 2 times, most recently from 98ba970 to 302b904 Compare December 2, 2025 08:59
@drewdzzz drewdzzz removed their assignment Dec 2, 2025
@LevKats LevKats force-pushed the box-func-id-overflow-fix branch 2 times, most recently from 80edb44 to 0541e08 Compare December 3, 2025 08:07
@LevKats LevKats requested a review from drewdzzz December 3, 2025 08:13
@LevKats LevKats force-pushed the box-func-id-overflow-fix branch 2 times, most recently from 517b840 to 85aae89 Compare December 3, 2025 10:56
Copy link
Contributor

@drewdzzz drewdzzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for the patch and for your fixes!

@drewdzzz drewdzzz removed their assignment Dec 3, 2025
Introduce the `box_generate_unique_id` function, which is useful for spaces
with limited primary key range such as `_func`.

Part of tarantool#11849
Part of tarantool#11851

NO_DOC=refactoring
NO_TEST=refactoring
NO_CHANGELOG=refactoring
Each time one used the `box.schema.func.create`, the primary key of
the resulted function increased because of the
`_func:auto_increment`. Now the new key is chosen by the
`generate_func_id` in Lua and `OP_GenFuncid` SQL opcode, both implemented
using the new `box_generate_func_id` function that shares logic with
`box_generate_space_id`. Hence we are scanning the entire range of
possible ids `[0, BOX_FUNCTION_MAX)` before we are returning an
error.

Fixes tarantool#11849
Fixes tarantool#11851
NO_DOC=bugfix
@LevKats LevKats force-pushed the box-func-id-overflow-fix branch from 85aae89 to 5d695f8 Compare December 3, 2025 22:38
@LevKats LevKats added the full-ci Enables all tests for a pull request label Dec 3, 2025
@drewdzzz
Copy link
Contributor

drewdzzz commented Dec 4, 2025

I'm OK with the latest fixes, all the comments are resolved and full-ci has passed, so I beleive the PR is ready to be merged.

@drewdzzz drewdzzz assigned sergepetrenko and unassigned LevKats and drewdzzz Dec 4, 2025
Copy link
Collaborator

@sergepetrenko sergepetrenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lev, thanks for the patch!

@sergepetrenko sergepetrenko merged commit 95d3550 into tarantool:master Dec 5, 2025
59 of 60 checks passed
@TarantoolBot
Copy link
Collaborator

Backport failed for release/3.2, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release/3.2
git worktree add -d .worktree/backport/release/3.2/12004 origin/release/3.2
cd .worktree/backport/release/3.2/12004
git switch --create backport/release/3.2/12004
git cherry-pick -x 80e580e04494c96d98c925603582354c951889bd 95d35505f5784c0d45bc404ef6f0c85471b3ec02

@TarantoolBot
Copy link
Collaborator

Backport failed for release/3.3, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release/3.3
git worktree add -d .worktree/backport/release/3.3/12004 origin/release/3.3
cd .worktree/backport/release/3.3/12004
git switch --create backport/release/3.3/12004
git cherry-pick -x 80e580e04494c96d98c925603582354c951889bd 95d35505f5784c0d45bc404ef6f0c85471b3ec02

@TarantoolBot
Copy link
Collaborator

Backport failed for release/3.4: couldn't find remote ref release/3.4.
Please ensure that this Github repo has a branch named release/3.4.

@TarantoolBot
Copy link
Collaborator

Successfully created backport PR for release/3.5:

@TarantoolBot
Copy link
Collaborator

Backport summary

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

Labels

backport/3.2 Automatically create a 3.2 backport PR backport/3.3 Automatically create a 3.3 backport PR backport/3.4 Automatically create a 3.4 backport PR backport/3.5 Automatically create a 3.5 backport PR full-ci Enables all tests for a pull request

Projects

None yet

7 participants