fix(config): add ORDER BY to findConfigInfo4PageFetchRows for deterministic pagination#14742
Merged
KomachiSion merged 1 commit intoMar 31, 2026
Conversation
…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.
|
Thanks for your this PR. 🙏 感谢您提交的PR。 🙏 |
KomachiSion
approved these changes
Mar 31, 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.
Problem
The
findConfigInfo4PageFetchRowsmethod inConfigInfoMapperByMySqlusesLIMIT/OFFSETpagination in its inner subquery without anORDER BYclause. 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()appliesLIMITdirectly withoutORDER BY: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
ORDER BY idbeforeLIMITin the inner query offindConfigInfo4PageFetchRows(), consistent with other paginated methods in the same class (e.g.,findAllConfigKey,findAllConfigInfoBaseFetchRows,findChangeConfigFetchRows,listGroupKeyMd5ByPageFetchRows,findAllConfigInfoFetchRows).Tests Added
ORDER BY idbeforeLIMITin inner querytestFindConfigInfo4PageFetchRows()— verifies the exact generated SQL containsORDER BY id LIMITtestFindConfigInfo4PageFetchRowsWithDescAndTags()— verifies ORDER BY is present when all parameters (dataId, group, appName, content) are providedImpact
This fix ensures deterministic pagination ordering for exact-match config queries on MySQL. Only the
findConfigInfo4PageFetchRowsmethod in the MySQL mapper is changed. No behavioral changes for other query methods or other database dialects.