Skip to content

[Fix][Connector-V2][JDBC] Make SQL Server type and URL parsing independent of the default locale - #13077

Merged
davidzollo merged 3 commits into
apache:devfrom
SEPURI-SAI-KRISHNA:fix-sqlserver-type-locale
Nov 7, 2026
Merged

davidzollo merged 3 commits into
apache:devfrom
SEPURI-SAI-KRISHNA:fix-sqlserver-type-locale

Conversation

@SEPURI-SAI-KRISHNA

@SEPURI-SAI-KRISHNA SEPURI-SAI-KRISHNA commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Yes, glad to contribute to Apache SeaTunnel.

Purpose of this pull request

Fixes #13075.

Two case conversions in the SQL Server JDBC code used the JVM default locale. Under tr-TR and az-AZ, i upper cases to İ, so both broke on a worker with such a default locale. Both now use Locale.ROOT.

SqlServerTypeConverter:114, column types. SQL Server type names are lower case (int, bigint, datetime2), and the converter upper cased them before its switch. int became İNT and failed with COMMON-17 unsupported convert type 'İNT'. This one method serves the catalog (table_path, from sys.types.name), the query path (ResultSetMetaData.getColumnTypeName, which the Microsoft driver reports in lower case) and SQL Server CDC (SqlServerTypeUtils). So the one change fixes all three.

SqlServerURLParser:53, URL property keys. The parser upper cases the keys to match them case insensitively, then looks up INSTANCENAME. Under tr-TR the key became İNSTANCENAME, the instance was lost, and the parser fell back to port 1433. For jdbc:sqlserver://localhost;instanceName=SQLEXPRESS, urlWithoutDatabase was jdbc:sqlserver://localhost:1433;instanceName=SQLEXPRESS;... instead of jdbc:sqlserver://localhost\SQLEXPRESS;.... The driver documentation says that when both a port and an instance name are given, the port wins and the instance name is ignored, so the catalog and SQL Server CDC connected to the default instance.

SqlServerDialect:202 (query.toLowerCase().contains("where")) is left as is: WHERE contains no I, so its result is the same in every locale.

Does this PR introduce any user facing change?

Yes, only on workers whose default locale is Turkish or Azerbaijani: SQL Server column types convert there, and a URL with an instanceName property keeps the instance. I compared dev's classes with these on 105 type names (every SQL Server type name in lower, upper and capitalised form) and 36 URLs (each address property key in three spellings, with and without a host in the URL):

  • tr-TR and az-AZ: 43 type names that failed now convert, and the 4 URLs whose key is spelled instanceName or instancename keep the instance. Nothing else changes, and every result now equals the ROOT one.
  • ROOT: identical results before and after.

So no working job changes, and no entry in incompatible-changes.md is needed. No option, default or API changed.

How was this patch tested?

Two tests in the existing test classes, each running under tr-TR and az-AZ and restoring the base locale and the FORMAT and DISPLAY defaults:

  • SqlServerTypeConverterTest.testConvertDoesNotDependOnTheDefaultLocale: int, bigint, datetime2.
  • SqlServerURLParserTest.testInstanceNamePropertyDoesNotDependOnTheDefaultLocale: the URL above keeps localhost\SQLEXPRESS and no port. The existing tests only use the host\instance form, which is why they pass in a Turkish JVM.

Reverting either change, its test fails.

I also ran the whole connector-jdbc suite in a JVM started with -Duser.language=tr -Duser.country=TR. With this change, 4 existing tests that failed there pass (decimal and the three identity types), and no test starts failing. 9 tests in SqlServerTypeConverterTest still fail there, but now on the test side: they compare column.getSourceType().toLowerCase() with the default locale and get, for example, ınt. The converter's result is correct. The default CI locale is unaffected, so I left those assertions alone. The two SqlServerDialectTest failures are the field_ide lookup that #13063 fixes.

The existing JdbcSqlServerIT covers it on a real server too. testCatalogReadsColumnTypesUnderTurkishLocale creates a table with int, bigint and datetime2 columns, and under tr-TR and az-AZ builds a catalog from the IT's URL and reads the table through it, so the URL parser and the converter both run under the locale. The catalog runs in the test JVM, so that is where the locale is set, and it is restored in finally. I ran the test method against SQL Server 2022 (the IT image). With this change it passes. With the two classes as they are on dev, it fails with COMMON-20 ... {"c_int":"İNT","c_bigint":"BİGİNT","c_datetime2":"DATETİME2"}, and the default locale is restored after the failure. The IT server is a default instance, so the instanceName case stays covered by the unit test.

Checks, JDK 17:

  • ./mvnw clean test -pl seatunnel-connectors-v2/connector-jdbc: 1198 tests, 0 failures, 4 errors. The 4 are the Oracle and Kingbase container tests, which need Docker.
  • ./mvnw spotless:check -pl seatunnel-connectors-v2/connector-jdbc: clean.
  • ./mvnw spotless:check -pl seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-part-3: clean.
  • ./mvnw -B -T 1 clean test -D"license.skipAddThirdParty"=true -pl seatunnel-ci-tools: 34 tests, 0 failures, 2 skipped by the module.

Check list

  • Code changed are covered with tests, or it does not need tests for reason
  • If any new Jar binary package adding in your PR, please add License Notice according to
    License Notice: none added.
  • If necessary, please update the documentation to describe the new feature: not needed, no documented behaviour changes.
  • If you are contributing the connector code, please check that the following files are updated:
    1. Update plugin-mapping.properties: not needed, no new connector.
    2. Update the pom file of seatunnel-dist: not needed, no new module.
    3. Add ci label in label-scope-conf: not needed, connector-jdbc is already labelled.
    4. Add e2e test for your connector: extended JdbcSqlServerIT, see above.
    5. Update connector-v2 doc: not needed, no option or mapping changes.
  • Update the release-note: not applicable, the file was removed from dev in [Improve] Remove release-note.md in dev branch #9304.

sharpca added a commit to sharpca/seatunnel that referenced this pull request Nov 1, 2026
The JDBC dialect type converters convert the source type name with
String#toUpperCase() / String#toLowerCase() without a locale before
matching it against the dialect type constants. Under a Turkish or
Azerbaijani default locale a lower-case "integer" upper-cases to
"INTEGER" with a dotted capital I and an upper-case "INT4" lower-cases to
"int4" with a dotless i, so the type no longer matches any constant and
the converter falls through to its unsupported-type branch.

Pass Locale.ROOT to every remaining case conversion in connector-jdbc so
that the same source type maps to the same SeaTunnel type on any worker.
The MySQL, OceanBase and SQL Server converters, JdbcDialect and
CatalogUtils are already covered by apache#13063, apache#13076 and apache#13077 and are not
touched here.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! I reviewed the complete four-file diff and the catalog/type-conversion callers at 2bb9addf3fab6c0ab58f8a03571b068637dfb416. The two production changes fix a real locale-dependent failure. I found no functional defect in those changes; the remaining source-side request is the existing integration-coverage requirement below.

What Problem Does This PR Solve?

User pain point: under Turkish or Azerbaijani JVM defaults, SQL Server metadata such as int becomes INT with a dotted capital I, missing the converter's ASCII switch. A named instance specified through instanceName can also be lost during URL reconstruction.

Fix approach: normalize machine-readable type names and property lookup keys with Locale.ROOT, while preserving original property values and suffix spelling.

One-sentence summary: the same SQL Server configuration and schema now have the same interpretation across JVM locales. For example, instanceName=SQLEXPRESS retains the named instance instead of taking the parser's default-port branch under tr-TR.

1. Code Change Review

1.1 Core Logic Analysis

The only production changes are SqlServerURLParser.parse:49-54 and SqlServerTypeConverter.convert:114 under seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/.

Before:

e -> e.getKey().toUpperCase()
String sqlServerType = typeDefine.getDataType().toUpperCase();

After:

e -> e.getKey().toUpperCase(Locale.ROOT)
String sqlServerType = typeDefine.getDataType().toUpperCase(Locale.ROOT);

Complete affected runtime chain:

JDBC source/sink catalog discovery
  -> SqlServerCatalogFactory.createCatalog / SqlServerUrlValidator.evaluate (:46,74)
     -> SqlServerURLParser.parse
        -> parse property map; normalize lookup keys (:49-54)
        -> choose explicit port / named instance / default port (:103-115)
        -> UrlInfo -> SqlServerCatalog connection metadata
  -> catalog column discovery
     -> SqlServerCatalog.buildColumn (:109-130)
        -> read database type/precision/scale/nullability/default
        -> SqlServerTypeConverter.convert (:106-114)
           -> existing ASCII type switch -> PhysicalColumn -> CatalogTable
     -> source row schema / sink schema and DDL decisions
Additional callers: SqlServerDataTypeConvertor, SqlserverTypeMapper,
SqlServerDialect.getTypeConverter. Reverse DDL reconvert logic is unchanged.

Key findings:

  • Normal catalog preparation reaches both changes; this is not only a recovery path.
  • The failure requires locale-sensitive letters; existing English-locale behavior is retained.
  • This is a precise normalization fix at the SQL Server protocol/metadata boundary.
  • URL property values, identifiers, precision/scale mapping and exception branches are unchanged. Existing parser limitations are not newly introduced by these two calls.

1.2 Compatibility Impact

Fully compatible with the intended URL/type contract. No API/SPI signature, option, default, network protocol, checkpoint or serialization format changes. Previously failing locale-dependent inputs now follow the existing mapping. No user migration is needed.

1.3 Performance / Side-Effect Analysis

Both sites already allocate normalized strings; ROOT adds no per-row work, collection, connection, thread or lock. CPU/memory/GC complexity is unchanged. Network, retries, idempotence and resource release are untouched. The tests mutate JVM locale temporarily and restore the base plus both category defaults in finally.

1.4 Error Handling and Logging

Unsupported types and URL errors retain the existing exception behavior. No additional logging or sensitive value exposure is introduced.

Issue 1: Pin the corrected metadata behavior through the existing SQL Server integration fixture

  • Location: seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/sqlserver/SqlServerTypeConverterTest.java:915-946; existing fixture seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-part-3/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/JdbcSqlServerIT.java.
  • Problem description: The new assertions call the parser/converter directly. No integration fixture changes, although this connector already has SQL Server IT coverage. The production boundary includes the driver's returned type text, catalog discovery and job schema construction.
  • Potential risk: The unit regression can pass while the real catalog/job path is not exercised with the non-English default. This is a coverage gap, not an observed data-conversion failure.
  • Best improvement: Extend the existing fixture with one minimal real metadata/schema assertion under a Turkish default. Set the locale in the JVM that actually performs discovery, restore it afterwards, and avoid introducing a separate large test matrix. Keep the focused unit cases.
  • Severity: Medium; blocking coverage requirement.
  • Raised by another reviewer: No; no prior reviews or inline findings were present in the retrieved history.

2. Code Quality Assessment

2.1 Coding Standards

The minimal ROOT changes match the existing style. The URL regression explains the dotted-I mechanism; locale restoration explains category ordering. No new production core method or state field is introduced; the tiny test conversion wrapper is straightforward.

2.2 Test Coverage and Test Stability

Stability: Stable for the current sequential JUnit configuration. SqlServerURLParserTest.java:161-184 and SqlServerTypeConverterTest.java:915-940 use fixed input/output assertions, no timing, network, random port or shared fixture. All locale categories are restored on failure. Enabling parallel locale-mutating tests would require a shared resource lock; I did not find that execution mode enabled here. The int/bigint/datetime2 and named-instance checks distinguish the old implementation. Issue 1 covers the missing IT extension.

Current-head CI is not green: edge-agent-it / JDK 17 fails during prerequisite engine-server unit tests, with NestedRowAccountingTest > AbstractSeaTunnelServerTest.before:73, IllegalStateException: Node failed to start!, after 300 seconds. That stage reports 695 tests, zero assertion failures, one error and five skips. The JDK11 edge lane and all four normal unit matrices pass. This identifies a node-startup error, not a SQL Server locale assertion; the available log does not expose a deeper startup cause.

I compared latest dev b3db27900bd4da855f0247e791e672f7fe301a4e with this head for that test, its AbstractSeaTunnelServerTest fixture, backend.yml and build_main.yml: no diff. There is no demonstrated upstream fix to prescribe as a sync cure. After checking for an active newer attempt, the run owner can retry that one failed lane; if startup fails again, preserve its node logs/XML for diagnosis. No unrelated engine/dependency patch is requested in this PR.

Local evidence: fetched the head, checked out independent branch seatunnel-review-13077, read all four changed files and the actual factory/catalog/dialect callers using git show/grep. git diff --check f3e1c2ee3b83efd4a1e7fb4cc4fe40b44060c7d0 2bb9addf3fab6c0ab58f8a03571b068637dfb416 passed. No local build, unit/IT/E2E execution or runtime validation was performed.

2.3 Documentation Updates

Option names, defaults and supported SQL Server types do not change. No new setup or migration instructions are required; the existing EN/ZH JDBC configuration contract remains valid. A brief locale-fix release note is useful but not a separate behavior migration.

3. Architectural Soundness

3.1 Elegance of the Solution

Precise fix. Machine-token normalization belongs in the parser/converter. Changing the global JVM locale would affect unrelated connectors and is a worse alternative.

3.2 Maintainability

The existing type switch and URL reconstruction remain easy to audit. Small IT coverage is the remaining deliverable, rather than a broader parser rewrite.

3.3 Extensibility

ROOT is reusable for machine-defined case-insensitive tokens; it should not be applied indiscriminately to user identifiers or payload values.

3.4 Historical-Version Compatibility

Existing jobs retain configuration and state formats. No mixed-version serialization or checkpoint change is introduced. Runtime acceptance is limited to the CI cases actually executed.

4. Issue Summary

Number Issue Location Severity
1 Missing existing SQL Server IT extension for locale-sensitive metadata discovery SqlServerTypeConverterTest.java:915; JdbcSqlServerIT.java Medium

5. Merge Recommendation

Conclusion: Ready to merge after fixes

  1. Blockers — must be fixed
    • Issue 1: add the minimal integration assertion through the existing SQL Server fixture.
    • Obtain green required checks on the resulting head; the diagnosed engine node-startup CI error is separate from the locale fix.
  2. Recommended fixes — non-blocking
    • No unrelated refactor or dependency change is requested.

Overall: the production fix is sound and narrowly placed. Keep this implementation, close the integration coverage requirement and retain the useful focused regressions. No independent maintainer APPROVED/CHANGES_REQUESTED review exists to reconcile. Daniel's READ-account COMMENT records the technical conclusion; a write-capable maintainer owns effective final approval/dismissal and merge gates.

Snapshot 2026-11-01T11:43:50.152407+00:00: head 2bb9addf3fab6c0ab58f8a03571b068637dfb416, base dev; compare diverged, ahead 1 / behind 4; merge blocked / BLOCKED, review decision REVIEW_REQUIRED. Drift is recorded separately; it does not itself request synchronization.

sharpca added a commit to sharpca/seatunnel that referenced this pull request Nov 1, 2026
Drop MySqlCatalog, OceanBaseMySqlCatalog and SqlServerURLParser: those files
are fixed by apache#13076 and apache#13077, and the OceanBase edit conflicts with the
removal of the second toUpperCase() there, so leave them to those PRs.

Add RedshiftCatalogLocaleTest, which drives RedshiftCatalog.buildColumn with a
mocked result set under tr-TR, so catalog schema discovery is covered and not
only the converters. Extend CharsetBasedSplitterTest with an I/i case that
asserts the case insensitive fold of upper case I is i and that the encoded
range decodes back to i.

Restore the base, DISPLAY and FORMAT locale defaults and mark the locale
mutating tests with @ResourceLock, so they cannot leak state into other tests.
@DanielLeens

Copy link
Copy Markdown
Contributor

A CI fact from my previous review has changed on the unchanged head: Apache Build is now SUCCESS, so the earlier engine node-startup failure is no longer the current gate. Thank you for getting that run through.

My source-side conclusion is unchanged: Issue 1, the focused SQL Server integration assertion, remains open. This is therefore not an approval based only on green CI. Please keep the production locale fix and extend the existing SQL Server fixture as requested; no unrelated dependency or workflow patch is needed. Effective maintainer review is still a separate repository gate. This comment updates CI context only, not another full source review.
Checked 2026-11-01T15:47:55.916782+00:00; unchanged head 2bb9addf3fab6c0ab58f8a03571b068637dfb416, base dev; compare diverged, ahead 1 / behind 4; merge blocked / BLOCKED; review decision REVIEW_REQUIRED. Behind/diverged is recorded independently and does not itself request a sync. Daniel has READ repository permission.

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Collaborator Author

@DanielLeens thanks for the review. Issue 1 is done in the latest commit. JdbcSqlServerIT.testCatalogReadsColumnTypesUnderTurkishLocale creates a table with int, bigint and datetime2 columns, and under tr-TR and then az-AZ in the test JVM builds a catalog from the IT's URL and reads the table through it. It builds its own catalog because testCatalog closes the shared one, and that way the URL parser runs under the locale too. The locale is restored in finally.

I checked that it detects the bug, against SQL Server 2022. With this PR it passes. With the two changed classes as they are on dev, it fails with COMMON-20 ... {"c_int":"İNT","c_bigint":"BİGİNT","c_datetime2":"DATETİME2"}, and the locale is still restored. The IT server is a default instance, so the instanceName case stays with the unit test. The PR description is updated.

@github-actions github-actions Bot added the e2e label Nov 2, 2026

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update and for the detailed IT write-up. I re-reviewed the current head 2ee8ffba36acc026dc69aaa41d9c9a1125ef7f06. The only change since my previous review (head 2bb9addf3f) is the new JdbcSqlServerIT.testCatalogReadsColumnTypesUnderTurkishLocale, which closes the integration-coverage request I raised as Issue 1. The two production changes are unchanged and I still find no functional defect in them.

What Problem Does This PR Solve?

User pain point: on a worker whose JVM default locale is Turkish or Azerbaijani, SQL Server metadata such as int is upper cased to a token with a dotted capital I, misses the converter's ASCII switch, and fails with COMMON-17 unsupported convert type. A named instance given through instanceName is also lost when the URL parser looks up its upper-cased property key.

Fix approach: use Locale.ROOT for the two machine-token normalizations (SqlServerTypeConverter.convert:114, SqlServerURLParser.parse:49-54).

One-sentence summary: the same SQL Server schema and URL are now interpreted identically under every JVM default locale.

1. Code Change Review

1.1 Core Logic Analysis

Before / after:

e -> e.getKey().toUpperCase()                          ->  e -> e.getKey().toUpperCase(Locale.ROOT)
typeDefine.getDataType().toUpperCase()                 ->  typeDefine.getDataType().toUpperCase(Locale.ROOT)

Runtime path (verified by reading the callers in this checkout, not by running anything):

JDBC source/sink with table_path
  -> SqlServerCatalogFactory / SqlServerUrlValidator -> SqlServerURLParser.parse   (key normalization, instance vs default port)
  -> SqlServerCatalog.buildColumn -> SqlServerTypeConverter.convert                (type name normalization -> existing switch)
  -> CatalogTable -> source schema / sink DDL decisions
Other callers of the converter: query path (ResultSetMetaData type name), SqlServerDialect, SQL Server CDC type utils.

Key findings:

  • The normal catalog-discovery path reaches both changes; this is not only a recovery or edge path.
  • I grepped the SQL Server catalog and dialect packages for remaining default-locale toUpperCase() / toLowerCase(). The only one left is SqlServerDialect:202 (toLowerCase().contains("where")), which contains no i, so it is locale-neutral, as the PR description says.
  • URL property values, identifiers and precision/scale mapping are untouched.
  • Solution type: Precise fix.

1.2 Compatibility Impact

Fully compatible. No option, default, API/SPI, protocol, serialization or checkpoint format changes. Inputs that already worked under ROOT-like locales behave identically; only previously failing Turkish/Azerbaijani inputs change. No incompatible-changes.md entry is needed.

1.3 Performance / Side-Effect Analysis

Both sites already allocated a normalized string once per column / per URL parse. Locale.ROOT adds no per-row work, thread, lock, connection or buffer. No impact at very large data volumes since this runs at metadata time, not per record.

1.4 Error Handling and Logging

Unsupported-type and URL-error branches keep their existing exceptions. No new logging and no credential exposure. No new issues found in this round.

2. Code Quality Assessment

2.1 Coding Standards

Minimal and consistent with surrounding style. No new production method or field, so no new Javadoc is required. The new IT has a Javadoc that explains the dotted-I mechanism.

2.2 Test Coverage and Test Stability

Stability rating: Stable.

  • Unit tests (SqlServerURLParserTest, SqlServerTypeConverterTest) use fixed inputs and restore the base locale plus both category defaults in finally.
  • New IT, JdbcSqlServerIT.java:394-459 (new testCatalogReadsColumnTypesUnderTurkishLocale): creates a table with int, bigint, datetime2, switches the JVM default to tr-TR then az-AZ, builds its own SqlServerCatalog from the IT URL (so the URL parser also runs under the locale), and asserts the exact SeaTunnel types. Locale is restored and the table dropped in finally. It is a plain @Test, no sleeps, no timing, no shared mutable catalog (it deliberately does not reuse the shared catalog that testCatalog closes). If the production toUpperCase(Locale.ROOT) calls were reverted, the type assertions would fail with the dotted-I type names, so the test has failure power. The contributor reports running it against SQL Server 2022 with and without the fix; I did not run it.
  • Only a default (unnamed) instance is available in the IT container, so the instanceName branch stays covered by the unit test only. That is an acceptable trade-off.

2.3 Documentation Updates

No user-visible option or behavior contract change; no EN/ZH doc update is needed.

3. Architectural Soundness

3.1 Elegance of the Solution

Precise fix at the metadata-token boundary. Changing the JVM locale globally would be a worse alternative.

3.2 Maintainability

Two one-line changes that are easy to audit.

3.3 Extensibility

Locale.ROOT is the right default for machine-defined, case-insensitive tokens; it should not be applied to user data.

3.4 Historical-Version Compatibility

Existing jobs keep configuration and state formats. No mixed-version, checkpoint or serialization effect.

4. Issue Summary

Number Issue Location Severity
- No open issues. Previous Issue 1 (IT coverage) is resolved by the new IT. - -

5. Merge Recommendation

Conclusion: Ready to merge

  1. Blockers
    • None on the source side.
  2. Recommended non-blocking fixes
    • None.

CI state (checked at head 2ee8ffba36): the apache Build check is in_progress, and the matching fork run is queued (run 41410090426). Please let it complete; the new IT only gets real CI evidence once the JDBC part-3 lane runs. The branch is diverged by 4 commits behind dev, with no conflict reported; I am not asking for a sync. Effective maintainer approval is a separate repository gate.

Overall assessment: the production fix is correct and complete for the SQL Server path, and the requested integration coverage is now in place. I did not run any build or test locally; the conclusions above come from reading the diff and callers.

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Collaborator Author

@DanielLeens thanks for the re-review. The JDBC part-3 lane did not pass on 2ee8ffba36: both updated-modules-integration-test-part-4 jobs were cancelled after 5 hours. The cause is the new test, so I fixed it.

AbstractJdbcIT turns auto commit off on the shared connection, so the CREATE TABLE was never committed. The catalog reads the table through its own connection, and SQL Server made it wait on that uncommitted DDL (LCK_M_S in sys.dm_exec_requests). The Java 11 log stops right after "Catalog sqlserver established connection" under tr-TR. My earlier local run opened the shared connection with auto commit on, so it missed this.

The new commit adds connection.commit() after CREATE TABLE and after DROP TABLE, as AbstractJdbcIT does after its own setup. Rerun against SQL Server 2022 with auto commit off, as in the IT:

  • the previous test hangs, as in CI
  • the new test passes with the fix
  • the new test fails with COMMON-20 without the fix

In all three runs the locale is restored and no table is left behind. MySQL and OceanBase commit DDL implicitly, so #13076 is not affected; both of its new tests passed in CI.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the quick and well-diagnosed follow-up, and for the clear explanation of the LCK_M_S wait. I re-reviewed the current head b0a9fdcd2a1bf6f5f0e3b08f65c42c2047dda2e1. The only change since my last review (head 2ee8ffba36) is two connection.commit() calls in JdbcSqlServerIT.testCatalogReadsColumnTypesUnderTurkishLocale. The two production changes are unchanged and I still find no functional defect in them.

My previous review at 2ee8ffba36 said "Ready to merge" on the basis that the new IT looked stable. It was not: the test blocked on its own uncommitted DDL, which I missed because I read the IT without checking how AbstractJdbcIT configures the shared connection. I am sorry about that; this commit is the fix for it, and I have re-checked the stability rating below against the new head.

What Problem Does This PR Solve?

User pain point: on a worker whose JVM default locale is Turkish or Azerbaijani, SQL Server type names such as int are upper cased to a token with a dotted capital I, miss the converter's ASCII switch, and fail with COMMON-17 unsupported convert type. A named instance given through instanceName is also lost when the URL parser looks up its upper-cased property key.

Fix approach: Locale.ROOT for the two machine-token normalizations (SqlServerTypeConverter.convert:114, SqlServerURLParser.parse:49-54).

One-sentence summary: the same SQL Server schema and URL are interpreted identically under every JVM default locale.

1. Code Change Review

1.1 Core Logic Analysis

Delta since my last review (test only):

statement.execute("CREATE TABLE [dbo].[" + tableName + "] (...)");
connection.commit();   // new: make the DDL visible to the catalog's own connection
...
finally {
    ...
    statement.execute("DROP TABLE IF EXISTS [dbo].[" + tableName + "]");
    connection.commit();   // new
}

Why this is the right fix (verified by reading the source): AbstractJdbcIT turns auto commit off on the shared connection, and SqlServerCatalog.getTable reads metadata through a separate connection. Under the default READ COMMITTED isolation a shared lock request on an object with an uncommitted CREATE TABLE waits, so the earlier version of the test never returned. Committing the DDL, as AbstractJdbcIT does after its own setup, removes the wait without changing what the test asserts.

Production runtime path (unchanged, normal path hits both changes):

JDBC source/sink with table_path
  -> SqlServerCatalogFactory / SqlServerUrlValidator -> SqlServerURLParser.parse   (key normalization: instance vs default port)
  -> SqlServerCatalog.buildColumn -> SqlServerTypeConverter.convert               (type name normalization -> existing switch)
  -> CatalogTable -> source schema / sink DDL decisions
Other callers: query path (ResultSetMetaData type name), SqlServerDialect, SQL Server CDC type utils.

1.2 Compatibility Impact

Fully compatible. No option, default, API/SPI, protocol, serialization or checkpoint format changes; only previously failing Turkish/Azerbaijani inputs change. No incompatible-changes.md entry needed.

1.3 Performance / Side-Effect Analysis

Metadata-time only, one normalized string per column or URL parse; no per-record cost. The IT adds one short-lived table and two short-lived catalogs.

1.4 Error Handling and Logging

Unsupported-type and URL-error branches keep their exceptions. No new logging or credential exposure.

No new blocking issues in this round. One optional nit, not a blocker:

Nit 1 (optional): the first connection.commit() sits outside the try

  • Location: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-part-3/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/JdbcSqlServerIT.java:413-415 (the CREATE TABLE at :409 and the commit are before the try that owns the cleanup).
  • Problem: if commit() itself threw, the finally that drops the table and restores the locale would not run.
  • Risk: negligible and only on a broken connection; the table name is fixed, so a leftover table would only affect a rerun on the same container.
  • Best improvement: optionally move the CREATE TABLE and commit() inside the try. Fine to leave as is.
  • Severity: Low (non-blocking).
  • Raised by another reviewer: No.

2. Code Quality Assessment

2.1 Coding Standards

Minimal and consistent with surrounding style. The added comment explains why the commit is needed (auto commit off plus a second connection), which is exactly the non-obvious part. No new production method or field.

2.2 Test Coverage and Test Stability

Stability rating: Stable (re-evaluated; it was Risk present for the previous head, in effect).

  • JdbcSqlServerIT.java:394-461: no sleeps, no random ports, own catalog per locale, locale and both category defaults restored in finally, DDL now committed and cleaned up. If the toUpperCase(Locale.ROOT) calls are reverted, the type assertions fail with the dotted-I names, so the test has failure power; the author reports exactly that against SQL Server 2022.
  • Unit tests (SqlServerURLParserTest, SqlServerTypeConverterTest) are unchanged and deterministic.
  • The IT container is a default instance, so the instanceName case remains covered by the unit test only; acceptable.

Evidence this round: the previously hanging lanes now complete. In the fork run for this head (run 41487880643), all updated-modules-integration-test-part-1 to part-8 jobs on JDK 11 and 17 succeeded, including part-3 and part-4. I did not run anything locally.

CI state at this head: the apache Build check is red, and the cause in the fork run is a single job, unit-test (17, ubuntu-latest): Redis7Test.failedInitializationClosesConnections:153->assertConnectionCountUnchanged:169->awaitCondition:268 expected: <true> but was: <false> in connector-redis. This PR does not touch Redis or any code that module uses, and the other three unit-test matrices (JDK 11 ubuntu/windows, JDK 17 windows) passed, so this looks like an environmental flake in a Docker-based connection-count assertion rather than something caused by this change. That is an inference from the diff and the job log. Please re-run only that failed job (job-level rerun, not the whole workflow) once no newer run is active.

2.3 Documentation Updates

No option, default or documented behavior changes, so no EN/ZH doc update is needed.

3. Architectural Soundness

Precise fix at the metadata-token boundary; changing the JVM locale globally would be worse. Two one-line production edits, easy to audit. Locale.ROOT is right for machine-defined case-insensitive tokens and should not be applied to user data. No mixed-version, checkpoint or serialization effect.

4. Issue Summary

Number Issue Location Severity
- No blocking issues. Previous Issue 1 (IT coverage) is resolved and the IT hang is fixed. - -
Nit 1 Optional: first commit() outside the cleanup try JdbcSqlServerIT.java:413 Low

5. Merge Recommendation

Conclusion: Ready to merge

  1. Blockers
    • None on the source side.
    • CI only: re-run the single failed job unit-test (17, ubuntu-latest) (unrelated Redis7Test flake) until the Build check is green.
  2. Recommended non-blocking fixes
    • Nit 1 above, optional.

The branch is diverged (ahead 3 / behind 5 versus dev) with no conflict reported (merge state BLOCKED is the pending review and check gate); I am not asking for a sync. Effective maintainer approval is a separate repository gate. Thanks again for the careful root-cause work on the lock wait.

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Collaborator Author

@DanielLeens thanks for the re-review. I re-ran the failed job as you suggested: unit-test (17, ubuntu-latest) passed on attempt 2 of https://github.com/SEPURI-SAI-KRISHNA/seatunnel/actions/runs/41487880643 (https://github.com/SEPURI-SAI-KRISHNA/seatunnel/actions/runs/41487880643/job/125716003597), on the unchanged head b0a9fdcd2a. The Build check on this PR is now green.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @SEPURI-SAI-KRISHNA, for rerunning only the failed job. On the unchanged head b0a9fdcd2a, unit-test (17, ubuntu-latest) passed on attempt 2 of the fork run, so the earlier Redis7Test failure was the unrelated flake, and the apache Build check is now green.

My source-side conclusion is unchanged: the two Locale.ROOT normalizations in SqlServerTypeConverter and SqlServerURLParser are correct, and JdbcSqlServerIT.testCatalogReadsColumnTypesUnderTurkishLocale is now stable with the committed DDL. CI was the only remaining gate, so I am approving this head. The optional nit about moving the first connection.commit() inside the try is still fine to leave as is. Effective maintainer approval is a separate repository gate. Thanks again!

@davidzollo davidzollo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1
LGTM, appreciate your solid contribution, keep up the excellent work

Thanks for your contribution! This is a solid addition to the project, and your attention to detail really shows. Contributors like you are what keep this community moving forward. Feel free to keep the PRs coming — we're always glad to have you here!

Please ignore the following message if you have joined in the Slack~

To facilitate focused communication among contributors, we’ve created a brand-new dedicated #contributors channel in official Slack workspace.
Slack workspace link: https://s.apache.org/seatunnel-slack

This channel is designed for technical discussions, feature design brainstorming, roadmap sync and direct communication with project core Contributors. Everyone who contributes code, docs, test cases or community ideas is warmly invited to join, share thoughts and collaborate together under The Apache Way. Welcome to join 😄

@davidzollo
davidzollo added this pull request to the merge queue Nov 7, 2026
Merged via the queue into apache:dev with commit ac3316d Nov 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Connector-V2][JDBC] SQL Server column types and instanceName break under a Turkish or Azerbaijani locale

3 participants