Skip to content

fix(sql): don't classify objects with permissive __getattr__ as connections#10296

Closed
Jayashanker-Padishala wants to merge 2 commits into
marimo-team:mainfrom
Jayashanker-Padishala:fix-10213-permissive-getattr-sql-sniffing
Closed

fix(sql): don't classify objects with permissive __getattr__ as connections#10296
Jayashanker-Padishala wants to merge 2 commits into
marimo-team:mainfrom
Jayashanker-Padishala:fix-10213-permissive-getattr-sql-sniffing

Conversation

@Jayashanker-Padishala

Copy link
Copy Markdown

This pull request was authored by a coding agent. (Per AGENTS.md: authored by Claude Code under the direction of @Jayashanker-Padishala, who takes responsibility for it. Marked as draft per policy.)

Fixes #10213

📝 Summary

Instantiating any ignite.metrics.Metric hung the executing cell forever. Root cause (found via faulthandler stack dump of the hung kernel):

  1. ignite metrics implement __getattr__ to return a lazy MetricsLambda factory for any attribute name — and each access runs traceback.format_stack() (ignite metric.py:797), so every attribute probe is also slow.
  2. That makes every callable(getattr(var, method, None)) duck-typing check succeed, so the post-execution _broadcast_data_source_connection hook classified the metric as an ADBC connection.
  3. AdbcConnectionCatalog.get_databasesadbc_get_objects(...).read_all().to_pylist() then walked into the lazy object graph and never produced real data — the cell appears hung and is not interruptible.

🔧 Fix

Add fabricates_attributes() (in _sql/engines/types.py): probe one attribute that no real connection defines; if the object returns something for it, its duck-typing answers are meaningless and is_compatible rejects it. Applied to both AdbcDBAPIEngine and DBAPIEngine (the two engines relying on pure getattr duck-typing — the others use isinstance checks).

Deliberately not inspect.getattr_static: genuine connection-pool proxies legitimately forward __getattr__ to an underlying connection and would regress; they pass the probe (the probe attribute doesn't exist on the real connection either).

This generalizes the existing ibis Deferred special-case (#7791) — any permissive-__getattr__ object (lazy proxies, mocks) is now handled, not just known names.

🧪 Verification

  • Reproduced the hang in the interactive kernel (executing_kernel fixture + from ignite.metrics import Loss; metric = Loss(nn.MSELoss())): watchdog fired at 30s pre-fix; post-fix the same cell completes in ~4s with metric defined.
  • New tests: test_is_compatible_rejects_fabricated_attributes (dbapi), test_adbc_is_compatible_rejects_fabricated_attributes (adbc), test_fabricated_attributes_not_treated_as_engine (get_engines).
  • pytest tests/_sql/: 246 passed. ruff check + ruff format --check clean on all changed files.

@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jul 23, 2026 2:23pm

Request Review

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

…ctions

Instantiating any pytorch-ignite Metric hung the executing cell forever:
ignite metrics implement __getattr__ to return a lazy MetricsLambda for
any attribute name (with a traceback.format_stack call on each access),
so they pass every getattr-based duck-typing check. The post-execution
data-source hook then classified the metric as an ADBC connection and
adbc_get_objects()/read_all() walked into the lazy object graph and never
returned real data.

Probe one attribute that no real connection defines; if the object
fabricates a callable for it, reject it in AdbcDBAPIEngine.is_compatible
and DBAPIEngine.is_compatible. Genuine connection proxies that forward
__getattr__ to an underlying connection are unaffected, since the probe
does not exist there either.

Fixes marimo-team#10213
@Jayashanker-Padishala

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@mscolnick
mscolnick requested a review from Light2Dark July 23, 2026 13:05
@Light2Dark

Copy link
Copy Markdown
Member

Thanks @Jayashanker-Padishala! I made a similar fix here with some additions #10301. But thank you for checking, appreciate it.

@Light2Dark Light2Dark closed this Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

marimo notebook hangs when using pytorch-ignite metraics

2 participants