Skip to content

Fixes 35939: Run Doris on PyMySQL and drop unused native libraries from operator images - #35940

Merged
ulixius9 merged 3 commits into
mainfrom
ulixius9/mariadb-docker-image-need
Oct 22, 2026
Merged

ulixius9 merged 3 commits into
mainfrom
ulixius9/mariadb-docker-image-need

Conversation

@ulixius9

@ulixius9 ulixius9 commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #35939

The operator (ingestion-base) images shipped mysqlclient only because pydoris hard-requires it. That C extension pulls in Debian's libmariadb3 and mariadb-common, which carry every MariaDB server CVE (26 High/Critical scanner findings, no fixed trixie build) even though no server is installed. This PR registers a pydoris dialect on PyMySQL for doris:// (every other MySQL-family connector already uses PyMySQL), uninstalls mysqlclient in the operator images, purges the MariaDB client packages and fails the build if any src:mariadb binary survives. The Airflow image (ingestion/Dockerfile) keeps mysqlclient on purpose, because Airflow's own metadata DB defaults to mysql+mysqldb.

The same scan has 10 more High findings against packages the operator images carry but never load, also with no trixie fix: libxml2 (7) and libsasl2-dev/libsasl2-modules/libsasl2-modules-gssapi-mit (3). The second commit purges them along with librdkafka. Together the two commits clear 36 of the scan's 45 High/Critical findings, including all 6 Criticals.

Behavior change: a Doris connectionArguments key that only mysqlclient understands (e.g. ssl_mode, read_default_file) now fails at connect time with TypeError, because PyMySQL rejects unknown kwargs. SSL via sslConfig is unaffected; it is passed the same way the MySQL connector already passes it to PyMySQL.

Type of change:

  • Improvement

High-level design:

  • doris/connection.py: DorisPyMySQLDialect(DorisDialect, MySQLDialect_pymysql) keeps all of pydoris's Doris reflection/type handling and swaps only the DBAPI. It is registered for doris when the module is imported; every Doris engine is built there. The dialect name stays pydoris, so Dialects.Doris and the profiler @compiles hooks are unchanged.
  • operators/docker/Dockerfile{,.ci}: pip uninstall -y mysqlclient (no-op for slim builds), purge libmariadb3/mariadb-common with the existing build-only packages, assert no src:mariadb package survives, drop MySQLdb from the import check.
  • operators/docker/Dockerfile{,.ci}, second commit: dpkg --purge removes libxml2, shared-mime-info, the SASL -dev/-modules/-modules-gssapi-mit packages and librdkafka*. Why nothing needs them:
    • lxml bundles its own libxml2.
    • Hive and Impala authenticate through pure-sasl plus kerberos, not Cyrus SASL.
    • The confluent_kafka wheel bundles its own librdkafka.
    • libsasl2-2 and libsasl2-modules-db stay because libpq5 needs them through libldap2. The DIGEST-MD5 plugin that the SASL CVE affects ships in libsasl2-modules, which is removed.
    • dpkg is used instead of apt-get because it refuses to remove a package something still depends on, where apt-get -y would silently remove the dependent too.
    • A new build step fails if any native library under site-packages, /opt or /instantclient links one of the purged libraries.
  • Alternatives rejected (diffed against 30 Doris column types): doris-alchemy 0.2.14 raises on array<…>, which fails the whole table, and overwrites the global MySQLDialect.colspecs on import. Both it and sqlalchemy-doris 0.2.2 lose variant/ipv4/ipv6, and sqlalchemy-doris has had no release since 2024. Vendoring pydoris was possible but means owning ~400 lines.
  • Rollout: the published Dockerfile installs openmetadata-ingestion from PyPI, so its changes are only safe with a release containing connection.py. Both ship in this PR. Collate's runner image re-installs only the base openmetadata-ingestion package (no extras), so pip never pulls mysqlclient back.
  • Decision record: ADR:2026-10-22-doris-connects-through-pymysql-and-images-ship-no-mariadb-client.

Tests:

Use cases covered

  • A Doris engine builds and connects with MySQLdb unavailable.
  • MySQL and Doris metadata, lineage, profiler and auto-classification workflows give identical results before and after the change.
  • The operator image contains no src:mariadb package, no libmariadb* file and no mysqlclient.
  • The operator image contains no libxml2, librdkafka or Cyrus SASL plugin package, and every native extension still loads.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated: ingestion/tests/unit/source/database/doris/test_connection.py: test_doris_engine_does_not_need_mysqlclient blocks MySQLdb and asserts the engine uses PyMySQL. It fails on main with ModuleNotFoundError: import of MySQLdb halted.
  • Ran every test touching the changed module: tests/unit/source/database/doris/test_connection.py, tests/unit/topology/database/test_doris.py, tests/unit/test_partition.py, tests/unit/observability/profiler/test_table_metric_computer.py → 138 passed.
  • Coverage %: 97% on doris/connection.py (the uncovered line is the existing test_connection body).

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable: there are no Doris integration tests, and the MySQL connector code is unchanged. Both connectors were exercised end to end against real databases instead (below).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  1. Built ingestion/operators/docker/Dockerfile.ci with INGESTION_DEPENDENCY="mysql,doris" twice, once from origin/main and once from this branch. In the main image the Doris dialect uses mysqldb and libmariadb3/mariadb-common are present. In the branch image the driver is pymysql, there is no mysqlclient and there are no MariaDB packages.

  2. Ran OM server 2.0.5 with a MySQL 8.0 source and an Apache Doris 4.1.3 (apache/doris:all-in-one-4.1.3) source. The seeded schemas cover:

    • MySQL: ENUM/SET/JSON/GEOMETRY/BIT, a foreign key, a range-partitioned table and a view.
    • Doris: ARRAY/MAP/STRUCT/VARIANT/JSON/LARGEINT/DECIMAL(38,10)/DATETIME(3)/IPV4/IPV6, a range-partitioned table, an AGGREGATE table with HLL/BITMAP, and a view.
  3. Ran metadata, lineage, profiler and auto-classification (sample data) workflows for both sources on both images, into separate *_before/*_after services. Metadata, lineage and auto-classification succeed on all four combinations. The Doris profiler succeeds on both images; the MySQL profiler ends at 99.64% on both.

  4. Diffed every table entity (columns, types, lengths, precision/scale, children, constraints, partitions, view definitions), latest table and column profiles, sample data and lineage edges through the API, ignoring ids, timestamps and service names. Result: identical for MySQL (4 tables, 33 columns, 33 column profiles) and Doris (4 tables, 35 columns, 35 column profiles).

  5. Built Dockerfile.ci at bde362fa948 with INGESTION_DEPENDENCY=all (arm64). The build succeeded and the new ldd guard passed. In the image:

    • Only libsasl2-2 and libsasl2-modules-db remain of the targeted source packages. There's no libxml2.so* and no libdigestmd5.so.
    • psycopg2, kerberos, confluent_kafka, lxml, pyodbc, pymssql, oracledb, pyhive, impala, pymysql, teradatasql and snowflake.connector all import.
    • The FreeTDS and MSSQL 18 ODBC drivers are registered.
    • doris:// resolves to pydoris/pymysql, and MySQLdb never loads.
    • The DB2 (ibm_db) driver is amd64-only, so this arm64 build didn't exercise it. The dpkg --purge dependency check and the ldd guard cover it on CI's amd64 build.
  6. End to end, second commit only. I built Dockerfile.ci with INGESTION_DEPENDENCY=all at 7373f4f1d9c (before the purge) and at bde362fa948 (after). Both images have the same 427 Python packages. I ran them against OM server 2.0.5 and live sources:

    • MySQL 8.0: metadata, lineage, profiler, auto-classification.
    • Doris 4.1.3: metadata, lineage, profiler, auto-classification.
    • Postgres 16: metadata, lineage, profiler, auto-classification. This covers psycopg2 → libpq5 → libldap2 → libsasl2-2.
    • Hive 4.0.1: metadata, profiler, auto-classification. auth=NONE runs over SASL PLAIN through thrift_sasl and pure-sasl, which I confirmed on the live connection.
    • Kafka 3.9.1: metadata through the wheel's bundled librdkafka.

    Results:

    • Every workflow has the same exit code and the same processed, warning and error counts on both images.
    • I diffed each table and topic entity, the latest table and column profiles, sample data and lineage edges through the API, ignoring ids, timestamps and service names. Every source is identical: MySQL 4 tables / 33 column profiles / 1 lineage edge; Doris 4 / 35; Postgres 4 / 20 / 2 lineage edges; Hive 3 / 14; Kafka 3 topics.
    • Two harness artefacts that aren't regressions: Postgres and Doris services were pre-created through the API, because this branch's client sends supportsAutoPartitionDetection, which the 2.0.5 server doesn't know. Kafka's internal __consumer_offsets topic was excluded, because the before run's sample-data consumer created it.
  7. Gaps that exist on main too, not regressions: the MySQL profiler fails on a TIME column ('int' object has no attribute 'microseconds'), Doris ipv4/ipv6 columns are skipped, and Doris lineage reports "not supported".

UI screen recording:

Not applicable: ingestion and Docker image change with no UI impact.

Checklist:

  • I have read the CONTRIBUTING document.

  • My PR title is Fixes <issue-number>: <short explanation>

  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.

  • I have commented on my code, particularly in hard-to-understand areas.

  • For JSON Schema changes: not applicable, no schema changes.

  • For a UI feature or feature task: not applicable, no UI changes.

  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

  • Self-review: I reviewed the final diff against REVIEW.md (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.

    • Reviewed 0804307b83d. The second commit (bde362fa948) has not been through the review pass yet. The first pass's 🔴 (missing decision record) is fixed. The final 7373f4f1d9c differs from it only by a Dockerfile comment the second pass flagged as a 🟡 nit. No 🔴 is open.
  • Decision check: adds docs/decisions/2026-10-22-doris-connects-through-pymysql-and-images-ship-no-mariadb-client.md.

  • I have added tests around the new logic.

  • For connector/ingestion changes: I updated the documentation. Not applicable: no user-facing connector option changed. The connectionArguments caveat above belongs in the release note.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with one non-blocking automated-test gap from the previous review.

Findings

  1. P2 Test never opens a connection ▶

Summary

Moves Doris connections to PyMySQL and removes unused native libraries from the operator images.

  • Doris connections keep pydoris behavior and use PyMySQL.
  • Operator images drop unused database and native-library packages.

Reviews (3) · Last reviewed commit: "Suppress pydoris's inherited reflection-..." · Reviewed by Greptile

… images

pydoris builds on SQLAlchemy's mysqldb dialect, so the operator (ingestion-base)
images shipped mysqlclient and, through it, Debian's libmariadb3 and
mariadb-common. Those two packages carry every MariaDB server CVE (26
High/Critical findings in the 2.0.6 runner scan) although no server is
installed. Doris was the only runtime consumer: every other MySQL-family
connector already uses PyMySQL.

Register a pydoris dialect on PyMySQL for the doris:// scheme, uninstall
mysqlclient in the operator images, purge the MariaDB client packages and fail
the build if any src:mariadb binary survives. The Airflow image keeps
mysqlclient for its own mysql+mysqldb metadata database.

ADR:2026-10-22-doris-connects-through-pymysql-and-images-ship-no-mariadb-client
@ulixius9
ulixius9 requested a review from a team as a code owner October 22, 2026 08:45
@ulixius9
ulixius9 requested review from mohittilala and a balanced review from Copilot October 22, 2026 08:45

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Oct 22, 2026
Comment on lines +95 to +97
with DorisConnection(doris_connection_config) as owned:
assert owned.client.dialect.driver == "pymysql"
assert isinstance(owned.client.dialect, DorisDialect)

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.

P2 Test never opens a connection

The new test stops at engine creation, which opens no database connection. It catches the old MySQLdb import, but cannot catch incompatible connection or cursor calls inherited by DorisPyMySQLDialect. Add an automated test that connects and runs a query with MySQLdb blocked, using a Doris fixture or a fake at the PyMySQL boundary.

…r images

Debian files 10 more High findings in the 2.0.6 runner scan against packages
nothing in the image loads, with no trixie fix: libxml2 (7; lxml bundles its
own), libsasl2-dev/-modules/-modules-gssapi-mit (3; Hive and Impala use
pure-sasl + kerberos, and the confluent_kafka wheel bundles its own
librdkafka). libsasl2-2 and its sasldb plugin stay for libpq5 -> libldap2;
the DIGEST-MD5 plugin the SASL CVE is in leaves with libsasl2-modules.

dpkg --purge refuses to remove a package something still depends on, where
apt-get -y would remove the dependent silently. A new build step fails if
any native library under site-packages, /opt or /instantclient links one
of the purged libraries.
Copilot AI balanced review requested due to automatic review settings October 22, 2026 08:57

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ulixius9 ulixius9 changed the title Fixes 35939: Run Doris on PyMySQL and drop MariaDB from operator images Fixes 35939: Run Doris on PyMySQL and drop unused native libraries from operator images Oct 22, 2026
…ySQL Doris dialect

basedpyright (py3.10 static checks) flags 10 reportIncompatibleMethodOverride
errors on DorisPyMySQLDialect: pydoris's DorisDialect declares untyped
reflection methods that clash with SQLAlchemy 2.0's typed MySQLDialect ones.
pydoris's methods are meant to win in the MRO, so the mismatch is inherited,
not ours to fix.
Copilot AI balanced review requested due to automatic review settings October 22, 2026 09:48

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gitar-bot

gitar-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Switching Doris from mysqlclient to PyMySQL and purging native libraries could break connections using mysqlclient-only arguments or dependencies.

Runs the Doris connector on PyMySQL via a DorisPyMySQLDialect registered for doris://, and removes mysqlclient plus the MariaDB, libxml2, Cyrus SASL and librdkafka packages from the operator images. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

Copy link
Copy Markdown

@ulixius9
ulixius9 added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit 2765a37 Oct 22, 2026
83 of 85 checks passed
@ulixius9
ulixius9 deleted the ulixius9/mariadb-docker-image-need branch October 22, 2026 12:58
ulixius9 added a commit that referenced this pull request Oct 23, 2026
…om operator images (#35940) (#36052)

* Run the Doris connector on PyMySQL and drop MariaDB from the operator images

pydoris builds on SQLAlchemy's mysqldb dialect, so the operator (ingestion-base)
images shipped mysqlclient and, through it, Debian's libmariadb3 and
mariadb-common. Those two packages carry every MariaDB server CVE (26
High/Critical findings in the 2.0.6 runner scan) although no server is
installed. Doris was the only runtime consumer: every other MySQL-family
connector already uses PyMySQL.

Register a pydoris dialect on PyMySQL for the doris:// scheme, uninstall
mysqlclient in the operator images, purge the MariaDB client packages and fail
the build if any src:mariadb binary survives. The Airflow image keeps
mysqlclient for its own mysql+mysqldb metadata database.

ADR:2026-10-22-doris-connects-through-pymysql-and-images-ship-no-mariadb-client

* Purge libxml2, the Cyrus SASL plugins and librdkafka from the operator images

Debian files 10 more High findings in the 2.0.6 runner scan against packages
nothing in the image loads, with no trixie fix: libxml2 (7; lxml bundles its
own), libsasl2-dev/-modules/-modules-gssapi-mit (3; Hive and Impala use
pure-sasl + kerberos, and the confluent_kafka wheel bundles its own
librdkafka). libsasl2-2 and its sasldb plugin stay for libpq5 -> libldap2;
the DIGEST-MD5 plugin the SASL CVE is in leaves with libsasl2-modules.

dpkg --purge refuses to remove a package something still depends on, where
apt-get -y would remove the dependent silently. A new build step fails if
any native library under site-packages, /opt or /instantclient links one
of the purged libraries.

* Suppress pydoris's inherited reflection-signature mismatch in the PyMySQL Doris dialect

basedpyright (py3.10 static checks) flags 10 reportIncompatibleMethodOverride
errors on DorisPyMySQLDialect: pydoris's DorisDialect declares untyped
reflection methods that clash with SQLAlchemy 2.0's typed MySQLDialect ones.
pydoris's methods are meant to win in the MRO, so the mismatch is inherited,
not ours to fix.

(cherry picked from commit 2765a37)

2.0 backport note: libxml2 and shared-mime-info are not purged here. 2.0's
operator images still install the postgresql server packages, which depend on
libxml2, so dpkg --purge would fail the build (that install was trimmed on main
by #35445). cx_Oracle stays in the import check because 2.0 still ships it.
mohittilala added a commit that referenced this pull request Nov 12, 2026
…37615)

- Ports the operator image part of #35445 to 2.0: only libpq-dev comes from pgdg, and postgresql and postgresql-contrib leave the Debian package list
- The server packages were all that kept libxml2 installed on 2.0, so libxml2 and shared-mime-info are purged again as on main (#35940), with libxml2 back in the ldd check
- libpq-dev stays for the psycopg2 source build and keeps libpq5 installed
- The Airflow images are left as they are, since they install libxml2 directly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Operator ingestion images ship MariaDB client packages that carry MariaDB server CVEs

3 participants