Repository navigation
fix(admin): use ROWNUM for the Oracle instance identity lookup (#7724) - #7754
Merged
Merged
Conversation
Aias00
approved these changes
Oct 17, 2026
Aias00
left a comment
Contributor
There was a problem hiding this comment.
LGTM. The variant is a faithful copy of the generic statement plus a valid Oracle row limit.
Evidence
- The five predicates (
instance_ip,namespace_id,instance_port,instance_type,id) match the generic statement one for one — I diffed them, nothing was dropped and no bind name changed. AND ROWNUM = 1after the filters preservesLIMIT 1semantics: ROWNUM is assigned to rows that already satisfy the WHERE clause, so the first matching row is returned.WHERE 1=1keeps the dynamic predicates uniform.- The same pattern already exists in this mapper (
existed,databaseId="oracle"), so theDatabaseIdProviderresolution is established, and the test pins which statement MyBatis picks. - The red-green is real: on master the resolved statement ends with
LIMIT 1, soassertFalse(sql.contains("limit"))fails. createOrUpdatebuilds its query from ip/port/type/namespace only, so theidfilter is a bonus and its absence in the test does not weaken the regression.
Non-blocking
- Two statements now have to be kept in sync by hand. If you touch this again, a shared
<sql>fragment for the predicate block with only the tail (LIMIT 1vsAND ROWNUM = 1) differing would remove the drift risk. SElECTcasing is inherited from the five existing statements in the file, so the new one is internally consistent — just noting that a case-sensitive SQL lint would flag all six.- The test asserts four of the five filters; adding
instanceIdwould cover the one predicate the caller never sets.
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.
Fixes #7724.
Summary
InstanceInfoMapper.selectOneByQueryhas no Oracle-specific mapping: the shared statement ends withLIMIT 1, which Oracle rejects.InstanceInfoServiceImpl#createOrUpdatecalls this lookup before every insert/update, so instance identity persistence cannot work on an Oracle deployment.The same mapper already demonstrates the supported pattern in its
existedstatement (databaseId="oracle"+ROWNUM = 1).Modifications
databaseId="oracle"variant ofselectOneByQuerythat keeps every identity/namespace predicate and ends withAND ROWNUM = 1.databaseId="oracle"and checks the resolved SQL.Verifying this change
New
InstanceInfoMapperOracleSqlTest: withdatabaseId="oracle",selectOneByQueryresolves to SQL containingROWNUMand noLIMIT, with all four filters (instance_ip,namespace_id,instance_port,instance_type) intact.Red-green: without the Oracle variant the test fails and reports the generic
... limit 1statement; with it the test passes.Targeted tests pass:
./mvnw -B -ntp -pl shenyu-admin test -Dtest=InstanceInfoMapperOracleSqlTest1/1 green.
Checkstyle passes:
clean.
Notes
AND ROWNUM = 1applies after the filters and preserves the single-row semantics ofLIMIT 1. The test pins MyBatis dialect selection locally; execution against a real Oracle instance is exercised by the repository's SQL matrix.