Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure module instances are not shared by multiple JDBC catalogs #24058

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

piotrrzysko
Copy link
Member

Description

When a JdbcPlugin is instantiated, creating an instance of a module at that time causes the instance to be shared by all connectors provided by the plugin. This is problematic when the module extends AbstractConfigurationAwareModule, as it holds a reference to the ConfigurationFactory, which is set dynamically during bootstrap. If catalogs are loaded concurrently, this can lead to situations where a connector accesses the configuration of another connector.

Additional context and related issues

Release notes

( ) 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.
(x) Release notes are required, with the following suggested text:

## Section
* Fix potential configuration leakage between JDBC catalogs. ({issue}`issuenumber`)

@cla-bot cla-bot bot added the cla-signed label Nov 7, 2024
@@ -26,6 +26,7 @@
import io.trino.spi.type.TypeManager;

import java.util.Map;
Copy link
Contributor

Choose a reason for hiding this comment

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

If catalogs are loaded concurrently, this can lead to situations where a connector accesses the configuration of another connector.

Can you add a test to this PR showcasing this behavior?

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that this is a non-deterministic bug. A test I came up with takes around 20 seconds because it requires many iterations to hit this scenario. I'll try to come up with a better approach.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a test. Without the changes from this PR, it consistently fails on my laptop when the number of iterations is set to 2000. However, this sometimes takes more than 20 seconds. I reduced the iterations to 100 to speed it up, so it may not always fail if the changes are not applied.

@wendigo
Copy link
Contributor

wendigo commented Nov 8, 2024

Just couple of nitpicks

When a JdbcPlugin is instantiated, creating an instance of a module at
that time causes the instance to be shared by all connectors provided by
the plugin. This is problematic when the module extends
AbstractConfigurationAwareModule, as it holds a reference to the
ConfigurationFactory, which is set dynamically during bootstrap. If
catalogs are loaded concurrently, this can lead to situations where a
connector accesses the configuration of another connector.
@piotrrzysko piotrrzysko marked this pull request as ready for review November 8, 2024 13:06
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