fix(pooling): make active-connection assertions race-free#103
Merged
dkasimovskiy merged 3 commits intoJun 26, 2026
Conversation
17582df to
d30ba39
Compare
box.stat.net().CONNECTIONS.current is updated asynchronously by the IProto worker, so reading it once right after starting clients can return a stale value and flake ConnectionPoolReconnectsTest. Replace the single read in BasePoolTest#getActiveConnectionsCount with a bounded Lua poll that waits until the counter stops changing, and add waitForActiveConnections helper for tests that need to assert a specific count. Test-only change.
Documents the fix for flaky active-connection assertions under Unreleased > Bug fixes.
d30ba39 to
5f90d0f
Compare
| + " for i = 1, 50 do" | ||
| + " require('fiber').sleep(0.05);" | ||
| + " local cur = box.stat.net().CONNECTIONS.current;" | ||
| + " if cur == last then return cur - 1 end;" |
Contributor
There was a problem hiding this comment.
Надо сделать по другому немного: надо сделать так, чтобы этот счётчик не менял своё значение N раз. Например, если он 5 раз выдаёт одно и то же значение - значит, это количество соединений устаканилось и его можно использовать. И паузы побольше
Address PR #103 review: the 2-reads-at-50ms heuristic can still land on a transitional value while the IProto worker is mid-batch. Require 5 consecutive equal reads at 100ms intervals (5x100ms=500ms worst case before return; 100-iter safety net = 10s). Also collapse waitForActiveConnections to a single assert — the Lua poll already waits up to 10s, so the outer waitFor wrapper was redundant.
bitgorbovsky
approved these changes
Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что сделано
Проверка на количество активных соединений в интеграционных тестах tarantool-pooling теперь дожидаются стабилизации счётчика на стороне Tarantool, а не читают его один раз.
Зачем
box.stat.net().CONNECTIONS.current обновляется асинхронно. Старый getActiveConnectionsCount делал единственный executeCommandDecoded сразу после старта клиентов.
Под нагрузкой CI значение кол-ва активных соединений часто оказывалось на одно больше или меньше реального, как следствие ConnectionPoolReconnectsTest периодически падал с ошибкой expected: but was: <count1 - 1> (или ниже).
Изменения
I haven't forgotten about:
Related issues: