Skip to content

Log accessible tables on Electric connection startup#3805

Open
KyleAMathews wants to merge 4 commits intomainfrom
claude/list-accessible-tables-Vo8uZ
Open

Log accessible tables on Electric connection startup#3805
KyleAMathews wants to merge 4 commits intomainfrom
claude/list-accessible-tables-Vo8uZ

Conversation

@KyleAMathews
Copy link
Contributor

Summary

Add logging of all tables accessible to Electric when the connection manager initializes. This helps operators understand which tables the connected database user has SELECT permission on.

Changes

  • Configuration module: Added list_accessible_tables!/1 function that queries PostgreSQL for all ordinary and partitioned tables (excluding system schemas) that the connected user has SELECT permission on
  • Connection manager: Added log_accessible_tables/1 function that retrieves and logs the list of accessible tables during connection setup, with error handling for database connection issues
  • Logs are emitted at INFO level on success and WARNING level if the query fails

Implementation Details

  • The SQL query uses has_table_privilege() to check SELECT permissions, ensuring only truly accessible tables are reported
  • System schemas (pg_catalog, information_schema) are excluded from results
  • Results are sorted by schema and table name for consistent output
  • Database connection errors are handled gracefully without blocking connection initialization
  • The logging occurs after connection setup but before replication supervisor initialization

https://claude.ai/code/session_012BtysQooC3gKQrgpj4KbGk

Add an info log message during Electric startup that lists all tables
accessible to the database user (tables with SELECT permission). This
helps users verify their database connection is working correctly and
see what tables are available for syncing.

The log appears right after the "Connected to Postgres" message and
before the shapes supervisor starts, showing output like:
"5 tables are accessible to Electric: [\"public.items\", ...]"

https://claude.ai/code/session_012BtysQooC3gKQrgpj4KbGk
@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.36%. Comparing base (8da1c1f) to head (2e275f7).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3805       +/-   ##
===========================================
+ Coverage   75.75%   87.36%   +11.60%     
===========================================
  Files          11       23       +12     
  Lines         693     2050     +1357     
  Branches      174      547      +373     
===========================================
+ Hits          525     1791     +1266     
- Misses        167      257       +90     
- Partials        1        2        +1     
Flag Coverage Δ
packages/experimental 87.73% <ø> (ø)
packages/react-hooks 86.48% <ø> (ø)
packages/start 82.83% <ø> (ø)
packages/typescript-client 93.29% <ø> (?)
packages/y-electric 56.05% <ø> (ø)
typescript 87.36% <ø> (+11.60%) ⬆️
unit-tests 87.36% <ø> (+11.60%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blacksmith-sh

This comment has been minimized.

KyleAMathews and others added 3 commits January 30, 2026 07:15
- Add logged_accessible_tables? flag to State struct to track if logging
  has already occurred
- Only log accessible tables on first startup, not during reconnections
- Add stack_id to error log message for better debugging context
- Remove redundant inline comment

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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