Skip to content

Conversation

@homar
Copy link
Member

@homar homar commented Oct 16, 2025

Description

Previously catalogs were not loaded correctly when TestingTrinoServer /DistributedQueryRunner was used

Additional context and related issues

Release notes

(x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

## Section
* Fix some things. ({issue}`issuenumber`)

Summary by Sourcery

Ensure DistributedQueryRunner automatically loads initial catalogs on startup and update tests to configure and verify healthy and failing catalogs via a custom CatalogStore.

Bug Fixes:

  • Load initial catalogs correctly when using DistributedQueryRunner.

Enhancements:

  • Automatically invoke loadInitialCatalogs after DistributedQueryRunner startup.
  • Allow specifying a custom CatalogStore implementation via builder properties and introduce a prepopulated in-memory store module for tests.

Tests:

  • Introduce TestCatalogStoreModule and PrepopulatedInMemoryCatalogStore to simulate a broken catalog.
  • Update TestDynamicCatalogs to remove manual loading and validate healthy and broken catalog behaviors.
  • Update TestSystemMetadataCatalogTable to configure the test catalog store and include the failing catalog in system.metadata.catalogs.

@cla-bot cla-bot bot added the cla-signed label Oct 16, 2025
@sourcery-ai
Copy link

sourcery-ai bot commented Oct 16, 2025

Reviewer's Guide

DistributedQueryRunner now automatically loads initial catalogs from the configured CatalogStore at startup by invoking ConnectorServicesProvider.loadInitialCatalogs. Tests have been refactored to remove manual catalog loading calls, introduce a prepopulated in-memory catalog store with a simulated broken catalog via a TestCatalogStoreModule, and update assertions to reflect the new initialization behavior.

Sequence diagram for DistributedQueryRunner startup and initial catalog loading

sequenceDiagram
    participant DQR as DistributedQueryRunner
    participant Coord as Coordinator
    participant CSP as ConnectorServicesProvider
    participant CS as CatalogStore

    DQR->>Coord: getInstance(ConnectorServicesProvider)
    Coord->>CSP: return ConnectorServicesProvider
    DQR->>CSP: loadInitialCatalogs()
    CSP->>CS: Load initial catalogs
    CS-->>CSP: Return loaded catalogs
    CSP-->>DQR: Catalogs initialized
Loading

Class diagram for PrepopulatedInMemoryCatalogStore and TestCatalogStoreModule

classDiagram
    class PrepopulatedInMemoryCatalogStore {
        +Map<String, Catalog> catalogs
        +PrepopulatedInMemoryCatalogStore(Map<String, Catalog> catalogs)
        +getCatalog(String name)
        +listCatalogs()
    }
    class TestCatalogStoreModule {
        +configure()
        +Provides PrepopulatedInMemoryCatalogStore
    }
    PrepopulatedInMemoryCatalogStore <.. TestCatalogStoreModule: provides
Loading

Class diagram for ConnectorServicesProvider with loadInitialCatalogs method

classDiagram
    class ConnectorServicesProvider {
        +loadInitialCatalogs()
        +other methods...
    }
Loading

File-Level Changes

Change Details Files
Automatically invoke catalog loading in DistributedQueryRunner startup
  • Add call to ConnectorServicesProvider.loadInitialCatalogs() in queryCompleted callback
testing/trino-testing/src/main/java/io/trino/testing/DistributedQueryRunner.java
Remove manual loadInitialCatalogs calls and centralize initialization in tests
  • Eliminate explicit connectorServicesProvider.loadInitialCatalogs() invocations
  • Configure DistributedQueryRunner with TestCatalogStoreModule and catalog.store property
testing/trino-tests/src/test/java/io/trino/connector/TestDynamicCatalogs.java
testing/trino-tests/src/test/java/io/trino/connector/system/TestSystemMetadataCatalogTable.java
Introduce TestCatalogStoreModule and prepopulated in-memory catalog store
  • Add TestCatalogStoreModule for conditional module installation on coordinator
  • Implement PrepopulatedInMemoryCatalogStoreModule, Factory, and Store to inject a broken catalog
testing/trino-tests/src/test/java/io/trino/connector/TestDynamicCatalogs.java
Update test assertions to include simulated broken_catalog
  • Use BROKEN_CATALOG constant for queries and expected SHOW CATALOGS results
  • Assert system.metadata.catalogs reflects unhealthy (FAILING) broken_catalog entry
testing/trino-tests/src/test/java/io/trino/connector/TestDynamicCatalogs.java
testing/trino-tests/src/test/java/io/trino/connector/system/TestSystemMetadataCatalogTable.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@homar homar force-pushed the homar/make_distributed_query_runner_load_catalogs branch 2 times, most recently from 33ffca7 to 4a63696 Compare October 16, 2025 19:01
@homar homar marked this pull request as ready for review October 17, 2025 06:52
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

closeAllSuppress(e, queryRunner);
throw e;
}
queryRunner.getCoordinator().getInstance(Key.get(ConnectorServicesProvider.class)).loadInitialCatalogs();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we do it in io.trino.server.testing.TestingTrinoServer#TestingTrinoServer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point

@homar homar force-pushed the homar/make_distributed_query_runner_load_catalogs branch from 3a497f9 to 4258ddf Compare October 17, 2025 10:29
@homar homar changed the title Load initial catalogs in DistributedQueryRunner Load initial catalogs in TestingTrinoServer Oct 17, 2025
@homar homar requested a review from kokosing October 17, 2025 12:22
@kokosing kokosing merged commit 4da16d9 into trinodb:master Oct 17, 2025
98 checks passed
@github-actions github-actions bot added this to the 478 milestone Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants