Skip to content

fix(config): add missing ORDER BY to Derby pagination queries#14748

Merged
KomachiSion merged 1 commit into
alibaba:developfrom
daguimu:fix/derby-pagination-order
Mar 31, 2026
Merged

fix(config): add missing ORDER BY to Derby pagination queries#14748
KomachiSion merged 1 commit into
alibaba:developfrom
daguimu:fix/derby-pagination-order

Conversation

@daguimu

@daguimu daguimu commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Problem

Several pagination methods in ConfigInfoMapperByDerby use OFFSET/FETCH NEXT without ORDER BY, causing non-deterministic results across paginated requests. This is the Derby dialect equivalent of the MySQL bug reported in #14046.

Root Cause

Derby does not guarantee consistent row ordering without an explicit ORDER BY clause. When OFFSET/FETCH NEXT is used for pagination, different pages may return overlapping or missing records.

Fix

Added ORDER BY before OFFSET in all affected methods:

ConfigInfoMapperByDerby (8 methods):

  • findConfigInfoByAppFetchRows — added ORDER BY id
  • getTenantIdList — added ORDER BY tenant_id
  • getGroupIdList — added ORDER BY group_id
  • findChangeConfigFetchRows — added ORDER BY id
  • findConfigInfoBaseLikeFetchRows — added ORDER BY id
  • findConfigInfo4PageFetchRows — added ORDER BY id
  • findConfigInfoBaseByGroupFetchRows — added ORDER BY id
  • findConfigInfoLike4PageFetchRows — added orderBy("id") via WhereBuilder

Also added orderBy() method to WhereBuilder for fluent ORDER BY support.

Tests Added

All 8 corresponding test methods updated to verify the ORDER BY clause is present in the generated SQL.

Impact

Ensures deterministic pagination ordering for all Derby config queries. Consistent with existing methods in the same class that already use ORDER BY id.

Several pagination methods in ConfigInfoMapperByDerby use OFFSET/FETCH
NEXT without ORDER BY, causing non-deterministic results across pages.
This adds ORDER BY before OFFSET to all affected methods. Also adds
orderBy() method to WhereBuilder.
@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 the kind/bug Category issues or prs related to bug. label Mar 31, 2026
@KomachiSion KomachiSion added this to the 3.2.1 milestone Mar 31, 2026
@KomachiSion
KomachiSion merged commit ebc72f2 into alibaba:develop Mar 31, 2026
2 checks passed
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