8000 [split 1/22] python: remove eval() from checksum fstr(), fix silent error swallowing, per-table LOCK TABLES READ lifecycle by minguyen9988 · Pull Request #1356 · Altinity/clickhouse-sink-connector · GitHub
[go: up one dir, main page]

Skip to content

[split 1/22] python: remove eval() from checksum fstr(), fix silent error swallowing, per-table LOCK TABLES READ lifecycle - #1356

Merged
subkanthi merged 1 commit into
2.10.0from
omniwatcher/split-01-py-checksum-safety
Aug 6, 2026
Merged

subkanthi merged 1 commit into
2.10.0from
omniwatcher/split-01-py-checksum-safety

Conversation

@minguyen9988
Copy link
Copy Markdown
Collaborator

Python tooling only - no Java changes.

  • fstr() in mysql_table_checksum.py, clickhouse_table_checksum.py, mysql_table_count.py was eval(f"f'{template}'"): any text reaching the template executed as Python. Replaced with literal {partition_expression} substitution; mysql_table_checksum_test.py (previously a placeholder that asserted True == False on every run) now pins that the eval cannot come back.
  • Thread-pool result loops read future.result() BEFORE checking future.exception(), so the first exception propagated un-logged and later ones were lost; now handled per-future with the table name logged.
  • top_level_table_checksum.py: per-table LOCK TABLES ... READ with try/finally unlock + connection close (lock released even when a checksum subprocess dies). New tests/test_table_locking.py covers the lock lifecycle.
  • db/clickhouse.py: cursor closed in finally; yaml.safe_load; credentials no longer logged in debug output.
  • db/mysql.py: user/password URL-quoted so special characters in credentials do not break the SQLAlchemy URL.
  • tests/main.py: parameterized INSERT instead of %-interpolated SQL.

Verified: python -m unittest db_compare.tests.mysql_table_checksum_test db_compare.tests.test_table_locking - all pass.

Part of the split of #1353 into independently mergeable sub-PRs (each <= 10 files), so the 2.10.0 branch can absorb the fixes incrementally.

Split out of #1353, which this series replaces. Each sub-PR is <= 10 files; the union of all 22 reproduces the #1353 tree exactly (verified by tree SHA).

…ng, per-table LOCK TABLES READ lifecycle

Python tooling only - no Java changes.

- fstr() in mysql_table_checksum.py, clickhouse_table_checksum.py, mysql_table_count.py was `eval(f"f'{template}'")`: any text reaching the template executed as Python. Replaced with literal `{partition_expression}` substitution; mysql_table_checksum_test.py (previously a placeholder that asserted True == False on every run) now pins that the eval cannot come back.
- Thread-pool result loops read future.result() BEFORE checking future.exception(), so the first exception propagated un-logged and later ones were lost; now handled per-future with the table name logged.
- top_level_table_checksum.py: per-table `LOCK TABLES ... READ` with try/finally unlock + connection close (lock released even when a checksum subprocess dies). New tests/test_table_locking.py covers the lock lifecycle.
- db/clickhouse.py: cursor closed in finally; yaml.safe_load; credentials no longer logged in debug output.
- db/mysql.py: user/password URL-quoted so special characters in credentials do not break the SQLAlchemy URL.
- tests/__main__.py: parameterized INSERT instead of %-interpolated SQL.

Verified: `python -m unittest db_compare.tests.mysql_table_checksum_test db_compare.tests.test_table_locking` - all pass.

Part of the split of #1353 into independently mergeable sub-PRs (each <= 10 files), so the 2.10.0 branch can absorb the fixes incrementally.
@subkanthi
subkanthi merged commit d58402d into 2.10.0 Aug 6, 2026
10 checks passed
@subkanthi
subkanthi deleted the omniwatcher/split-01-py-checksum-safety branch August 6, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0