Repository navigation
Fixes 35939: Run Doris on PyMySQL and drop unused native libraries from operator images - #35940
Conversation
… 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
❌ PR checklist incompleteThis 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 |
| with DorisConnection(doris_connection_config) as owned: | ||
| assert owned.client.dialect.driver == "pymysql" | ||
| assert isinstance(owned.client.dialect, DorisDialect) |
There was a problem hiding this comment.
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.
…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.
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 VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
…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.
…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



Describe your changes:
Fixes #35939
The operator (
ingestion-base) images shippedmysqlclientonly becausepydorishard-requires it. That C extension pulls in Debian'slibmariadb3andmariadb-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 apydorisdialect on PyMySQL fordoris://(every other MySQL-family connector already uses PyMySQL), uninstallsmysqlclientin the operator images, purges the MariaDB client packages and fails the build if anysrc:mariadbbinary survives. The Airflow image (ingestion/Dockerfile) keepsmysqlclienton purpose, because Airflow's own metadata DB defaults tomysql+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) andlibsasl2-dev/libsasl2-modules/libsasl2-modules-gssapi-mit(3). The second commit purges them along withlibrdkafka. Together the two commits clear 36 of the scan's 45 High/Critical findings, including all 6 Criticals.Behavior change: a Doris
connectionArgumentskey that onlymysqlclientunderstands (e.g.ssl_mode,read_default_file) now fails at connect time withTypeError, because PyMySQL rejects unknown kwargs. SSL viasslConfigis unaffected; it is passed the same way the MySQL connector already passes it to PyMySQL.Type of change:
High-level design:
doris/connection.py:DorisPyMySQLDialect(DorisDialect, MySQLDialect_pymysql)keeps all ofpydoris's Doris reflection/type handling and swaps only the DBAPI. It is registered fordoriswhen the module is imported; every Doris engine is built there. The dialect name stayspydoris, soDialects.Dorisand the profiler@compileshooks are unchanged.operators/docker/Dockerfile{,.ci}:pip uninstall -y mysqlclient(no-op for slim builds), purgelibmariadb3/mariadb-commonwith the existing build-only packages, assert nosrc:mariadbpackage survives, dropMySQLdbfrom the import check.operators/docker/Dockerfile{,.ci}, second commit:dpkg --purgeremoveslibxml2,shared-mime-info, the SASL-dev/-modules/-modules-gssapi-mitpackages andlibrdkafka*. Why nothing needs them:lxmlbundles its own libxml2.pure-saslpluskerberos, not Cyrus SASL.confluent_kafkawheel bundles its own librdkafka.libsasl2-2andlibsasl2-modules-dbstay becauselibpq5needs them throughlibldap2. The DIGEST-MD5 plugin that the SASL CVE affects ships inlibsasl2-modules, which is removed.dpkgis used instead ofapt-getbecause it refuses to remove a package something still depends on, whereapt-get -ywould silently remove the dependent too./optor/instantclientlinks one of the purged libraries.doris-alchemy0.2.14 raises onarray<…>, which fails the whole table, and overwrites the globalMySQLDialect.colspecson import. Both it andsqlalchemy-doris0.2.2 losevariant/ipv4/ipv6, andsqlalchemy-dorishas had no release since 2024. Vendoringpydoriswas possible but means owning ~400 lines.Dockerfileinstallsopenmetadata-ingestionfrom PyPI, so its changes are only safe with a release containingconnection.py. Both ship in this PR. Collate's runner image re-installs only the baseopenmetadata-ingestionpackage (no extras), so pip never pullsmysqlclientback.ADR:2026-10-22-doris-connects-through-pymysql-and-images-ship-no-mariadb-client.Tests:
Use cases covered
MySQLdbunavailable.src:mariadbpackage, nolibmariadb*file and nomysqlclient.libxml2,librdkafkaor Cyrus SASL plugin package, and every native extension still loads.Unit tests
ingestion/tests/unit/source/database/doris/test_connection.py:test_doris_engine_does_not_need_mysqlclientblocksMySQLdband asserts the engine uses PyMySQL. It fails onmainwithModuleNotFoundError: import of MySQLdb halted.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.doris/connection.py(the uncovered line is the existingtest_connectionbody).Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
Built
ingestion/operators/docker/Dockerfile.ciwithINGESTION_DEPENDENCY="mysql,doris"twice, once fromorigin/mainand once from this branch. In themainimage the Doris dialect usesmysqldbandlibmariadb3/mariadb-commonare present. In the branch image the driver ispymysql, there is nomysqlclientand there are no MariaDB packages.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:Ran metadata, lineage, profiler and auto-classification (sample data) workflows for both sources on both images, into separate
*_before/*_afterservices. 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.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).
Built
Dockerfile.ciatbde362fa948withINGESTION_DEPENDENCY=all(arm64). The build succeeded and the newlddguard passed. In the image:libsasl2-2andlibsasl2-modules-dbremain of the targeted source packages. There's nolibxml2.so*and nolibdigestmd5.so.psycopg2,kerberos,confluent_kafka,lxml,pyodbc,pymssql,oracledb,pyhive,impala,pymysql,teradatasqlandsnowflake.connectorall import.doris://resolves topydoris/pymysql, andMySQLdbnever loads.ibm_db) driver is amd64-only, so this arm64 build didn't exercise it. Thedpkg --purgedependency check and thelddguard cover it on CI's amd64 build.End to end, second commit only. I built
Dockerfile.ciwithINGESTION_DEPENDENCY=allat7373f4f1d9c(before the purge) and atbde362fa948(after). Both images have the same 427 Python packages. I ran them against OM server 2.0.5 and live sources:psycopg2→libpq5→libldap2→libsasl2-2.auth=NONEruns over SASL PLAIN throughthrift_saslandpure-sasl, which I confirmed on the live connection.Results:
supportsAutoPartitionDetection, which the 2.0.5 server doesn't know. Kafka's internal__consumer_offsetstopic was excluded, because the before run's sample-data consumer created it.Gaps that exist on
maintoo, not regressions: the MySQL profiler fails on aTIMEcolumn ('int' object has no attribute 'microseconds'), Dorisipv4/ipv6columns 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(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.0804307b83d. The second commit (bde362fa948) has not been through the review pass yet. The first pass's 🔴 (missing decision record) is fixed. The final7373f4f1d9cdiffers 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
connectionArgumentscaveat above belongs in the release note.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge, with one non-blocking automated-test gap from the previous review.Findings
Summary
Moves Doris connections to PyMySQL and removes unused native libraries from the operator images.
Reviews (3) · Last reviewed commit: "Suppress pydoris's inherited reflection-..." · Reviewed by Greptile