Skip to content

fix(config): add ORDER BY to findConfigInfo4PageFetchRows for deterministic pagination#14742

Merged
KomachiSion merged 1 commit into
alibaba:developfrom
daguimu:fix/mysql-config-page-query-order
Mar 31, 2026
Merged

fix(config): add ORDER BY to findConfigInfo4PageFetchRows for deterministic pagination#14742
KomachiSion merged 1 commit into
alibaba:developfrom
daguimu:fix/mysql-config-page-query-order

Conversation

@daguimu

@daguimu daguimu commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Problem

The findConfigInfo4PageFetchRows method in ConfigInfoMapperByMySql uses LIMIT/OFFSET pagination in its inner subquery without an ORDER BY clause. Without explicit ordering, MySQL does not guarantee consistent row ordering across paginated queries, which can lead to duplicate or missing records when users paginate through config listing results.

Root Cause

The inner SQL query constructed in findConfigInfo4PageFetchRows() applies LIMIT directly without ORDER BY:

SELECT ... FROM config_info WHERE tenant_id=? ... LIMIT startRow,pageSize

This is the same class of bug as #14046 (which affected findConfigInfoLike4PageFetchRows), but in a different method that handles exact-match config queries rather than fuzzy queries.

Fix

  • Added ORDER BY id before LIMIT in the inner query of findConfigInfo4PageFetchRows(), consistent with other paginated methods in the same class (e.g., findAllConfigKey, findAllConfigInfoBaseFetchRows, findChangeConfigFetchRows, listGroupKeyMd5ByPageFetchRows, findAllConfigInfoFetchRows).

Tests Added

Change Point Test
Added ORDER BY id before LIMIT in inner query testFindConfigInfo4PageFetchRows() — verifies the exact generated SQL contains ORDER BY id LIMIT
Same change point testFindConfigInfo4PageFetchRowsWithDescAndTags() — verifies ORDER BY is present when all parameters (dataId, group, appName, content) are provided

Impact

This fix ensures deterministic pagination ordering for exact-match config queries on MySQL. Only the findConfigInfo4PageFetchRows method in the MySQL mapper is changed. No behavioral changes for other query methods or other database dialects.

…deterministic pagination

The inner SQL query applies LIMIT without ORDER BY, causing MySQL to
return non-deterministic results across paginated requests. This adds
ORDER BY id before LIMIT, consistent with other paginated methods in
the same class.
@github-actions

Copy link
Copy Markdown

Thanks for your this PR. 🙏
Please check again for your PR changes whether contains any usage/api/configuration change such as Add new API , Add new configuration, Change default value of configuration.
If so, please add or update documents(markdown type) in docs/next/ for repository nacos-group/nacos-group.github.io


感谢您提交的PR。 🙏
请再次查看您的PR内容,确认是否包含任何使用方式/API/配置参数的变更,如:新增API新增配置参数修改默认配置等操作。
如果是,请确保在提交之前,在仓库nacos-group/nacos-group.github.io中的docs/next/目录下添加或更新文档(markdown格式)。

@KomachiSion KomachiSion added this to the 3.2.1 milestone Mar 31, 2026
@KomachiSion KomachiSion added the kind/bug Category issues or prs related to bug. label Mar 31, 2026
@KomachiSion
KomachiSion merged commit f666062 into alibaba:develop Mar 31, 2026
2 checks passed
@daguimu
daguimu deleted the fix/mysql-config-page-query-order branch March 31, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/plugin kind/bug Category issues or prs related to bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants