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

Add PostgreSQL and Oracle migration files for DB backed resource group manager #9812

Merged

Conversation

posulliv
Copy link
Contributor

I was unable to add an automated test for Oracle migrations. I wanted to use the image used in other tests wnameless/oracle-xe-11g-r2 but Flyway community edition will not run migrations with versions of Oracle that old. If someone knows of a newer Oracle image that can be used, I will be happy to add a test.

Copy link
Member

@nineinchnick nineinchnick left a comment

Choose a reason for hiding this comment

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

I found this image: https://hub.docker.com/r/gvenzl/oracle-xe. Looks decent and it's used by the Testcontainers project.

@posulliv posulliv force-pushed the postgresql-oracle-resource-groups-migrations branch from 54aeec5 to 8574806 Compare November 23, 2021 21:14
@posulliv
Copy link
Contributor Author

@nineinchnick thanks! I added a test using that Oracle image.

@posulliv posulliv force-pushed the postgresql-oracle-resource-groups-migrations branch from 8574806 to 8e0b0ea Compare November 29, 2021 16:48
@posulliv posulliv force-pushed the postgresql-oracle-resource-groups-migrations branch 2 times, most recently from d41f5d4 to 2c646b3 Compare December 8, 2021 21:19
@posulliv
Copy link
Contributor Author

posulliv commented Dec 9, 2021

@aalbu this is ready for another review whenever you get a chance. thanks!

@posulliv posulliv requested review from aalbu and hashhar December 14, 2021 02:53
@posulliv posulliv force-pushed the postgresql-oracle-resource-groups-migrations branch from 2c646b3 to e0ee7f6 Compare January 10, 2022 20:37
@posulliv
Copy link
Contributor Author

@aalbu thanks for the review! All suggestions have been applied.

Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

Why does Postgres have a single migration? Is it because DDL is transactional in Postgres? (hint: should be a code comment or in the commit message - I'd prefer to have separate migrations just to make it easier to compare across databases but existing is fine as well).

Looks good % comments.

Thanks for working on this @posulliv.

@Override
protected final JdbcDatabaseContainer<?> startContainer()
{
JdbcDatabaseContainer<?> container = new MySQLContainer<>("mysql:8.0.12");
Copy link
Member

Choose a reason for hiding this comment

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

@ebyhr @wendigo What do you think about starting to read image versions from a single properties file (or public constants) to ensure consistency in the versions being tested (easier to bump min and max tested versions that way).

@posulliv No change requested.

Copy link
Member

Choose a reason for hiding this comment

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

An alternative is to make versions injectable either from environment or system properties. That has the benefit that it's easier to test arbitrary versions via a matrix.

plugin/trino-resource-group-managers/pom.xml Show resolved Hide resolved
@posulliv posulliv force-pushed the postgresql-oracle-resource-groups-migrations branch from e0ee7f6 to 13c7581 Compare January 18, 2022 22:01
@posulliv
Copy link
Contributor Author

Why does Postgres have a single migration? Is it because DDL is transactional in Postgres? (hint: should be a code comment or in the commit message - I'd prefer to have separate migrations just to make it easier to compare across databases but existing is fine as well).

Yes, that's correct. I agree though that it would be more consistent to have a separate migration per table. So I updated the PostgreSQL migrations to be 1 file per table.

hashhar
hashhar previously approved these changes Jan 19, 2022
Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

Thanks for adding this @posulliv .

@hashhar
Copy link
Member

hashhar commented Jan 19, 2022

Hmmm, seems like a test if failing now due to tests using H2.

Error:  io.trino.execution.resourcegroups.db.TestResourceGroupDbIntegration.testMemoryFraction  Time elapsed: 4.179 s  <<< FAILURE!
com.google.inject.CreationException: 
Unable to create injector, see the following errors:

1) Error notifying ProvisionListener LifeCycleModule$$Lambda$684/0x00000008004ee440 of DbResourceGroupConfig.
 Reason: LifeCycleStartException: Exception in PostConstruct method DbResourceGroupConfig::validate()
  at DbResourceGroupConfigurationManager.<init>(DbResourceGroupConfigurationManager.java:94)
      \_ for 2nd parameter config
  at H2ResourceGroupsModule.configure(H2ResourceGroupsModule.java:40)
  while locating DbResourceGroupConfigurationManager
  at H2ResourceGroupsModule.configure(H2ResourceGroupsModule.java:41)
  while locating ResourceGroupConfigurationManager
Caused by: LifeCycleStartException: Exception in PostConstruct method DbResourceGroupConfig::validate()
	at LifeCycleManager.startInstance(LifeCycleManager.java:246)
	at LifeCycleManager.addInstance(LifeCycleManager.java:212)
	at LifeCycleModule.provision(LifeCycleModule.java:62)
	at ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:117)
	at ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:66)
	at ProviderInternalFactory.circularGet(ProviderInternalFactory.java:62)
	at InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:47)
	at SingleParameterInjector.inject(SingleParameterInjector.java:40)
	at SingleParameterInjector.getAll(SingleParameterInjector.java:60)
	at ConstructorInjector.provision(ConstructorInjector.java:113)
	at ConstructorInjector.access$000(ConstructorInjector.java:33)
	at ConstructorInjector$1.call(ConstructorInjector.java:98)
	at ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:109)
	at LifeCycleModule.provision(LifeCycleModule.java:54)
	at ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:117)
	at ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:66)
	at ConstructorInjector.construct(ConstructorInjector.java:93)
	at ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:296)
	at ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
	at SingletonScope$1.get(SingletonScope.java:169)
	at InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:45)
	at FactoryProxy.get(FactoryProxy.java:60)
	at ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
	at SingletonScope$1.get(SingletonScope.java:169)
	at InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:45)
	at InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:213)
	at InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:186)
	at InternalInjectorCreator.build(InternalInjectorCreator.java:113)
	at Guice.createInjector(Guice.java:87)
	at Bootstrap.initialize(Bootstrap.java:269)
	at H2ResourceGroupConfigurationManagerFactory.create(H2ResourceGroupConfigurationManagerFactory.java:62)
	at InternalResourceGroupManager.setConfigurationManager(InternalResourceGroupManager.java:163)
	at H2TestUtil.createQueryRunner(H2TestUtil.java:137)
	at H2TestUtil.createQueryRunner(H2TestUtil.java:122)
	at H2TestUtil.getSimpleQueryRunner(H2TestUtil.java:154)
	at TestResourceGroupDbIntegration.testMemoryFraction(TestResourceGroupDbIntegration.java:28)
	at java.base/NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/Method.invoke(Method.java:566)
	at MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104)
	at Invoker.invokeMethod(Invoker.java:645)
	at Invoker.invokeTestMethod(Invoker.java:851)
	at Invoker.invokeTestMethods(Invoker.java:1177)
	at TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
	at TestMethodWorker.run(TestMethodWorker.java:112)
	at java.base/ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/Thread.run(Thread.java:829)
Caused by: IllegalArgumentException: Invalid JDBC URL: jdbc:h2:mem:test_1295574013934079806. Only PostgreSQL, MySQL, and Oracle are supported.
	at DbResourceGroupConfig.validate(DbResourceGroupConfig.java:104)
	at java.base/NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/Method.invoke(Method.java:566)
	at LifeCycleManager.startInstance(LifeCycleManager.java:241)
	... 48 more

cc: @posulliv can you fix this? I'm fine with reverting the change suggested in #9812 (comment) and adding a comment why the validation is not done in the config class itself.

@hashhar hashhar dismissed their stale review January 19, 2022 06:23

CI failed

@posulliv posulliv force-pushed the postgresql-oracle-resource-groups-migrations branch from 13c7581 to 4dc2c90 Compare January 19, 2022 21:28
@posulliv
Copy link
Contributor Author

thanks @hashhar. I updated and added a comment.

I forgot the unit tests use the h2 database. Perhaps some future work could be to update those unit tests to use one of the supported database engines instead of h2 and then we can add the validation back to the config class itself.

@hashhar
Copy link
Member

hashhar commented Jan 20, 2022

@aalbu / @nineinchnick Could you maybe take another look at the migrations being added since once added we won't get a chance to edit them - we can only add new migrations.

This looks good to me otherwise and ready to merge.

@nineinchnick
Copy link
Member

@hashhar LGTM

@hashhar hashhar merged commit 23ca99c into trinodb:master Jan 20, 2022
@github-actions github-actions bot added this to the 369 milestone Jan 20, 2022
@hashhar hashhar mentioned this pull request Jan 20, 2022
@hashhar
Copy link
Member

hashhar commented Jan 20, 2022

Thanks @posulliv for seeing this to the finish line.

Can you PTAL at suggested release note at #10552 (comment)? Feel free to suggest changes.

also we should add some docs to help users to use DB backed resource groups. I don't think there is anything existing already? cc: @mosabua do you know?

@posulliv posulliv deleted the postgresql-oracle-resource-groups-migrations branch January 20, 2022 14:37
@posulliv
Copy link
Contributor Author

@hashhar there is an open PR from a long time back to add docs for this - #4523

Needs to be updated now. I will work on updating that docs PR.

Release note comment looks good to me. Thanks!!

@mosabua
Copy link
Member

mosabua commented Jan 20, 2022

Awesome @posulliv .. ping me when you want some input for the docs PR and anything related.

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.

5 participants