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

[Pulsar SQL] Fix injection factory cast error (fix master broken) #9472

Merged

Conversation

gaoran10
Copy link
Contributor

@gaoran10 gaoran10 commented Feb 4, 2021

Fixes #9470

Motivation

Fix master CI problem.

error log

2021-02-04T10:14:12.161+0800 ERROR remote-task-callback-4 io.prestosql.execution.StageStateMachine Stage 20210204_021409_00001_siuzy.1 failed
java.lang.RuntimeException: java.util.concurrent.ExecutionException: org.apache.pulsar.client.admin.PulsarAdminException: java.util.concurrent.ExecutionException: org.apache.pulsar.client.admin.PulsarAdminException$GettingAuthenticationDataException: java.lang.ClassCastException: Cannot cast org.glassfish.jersey.inject.hk2.Hk2InjectionManagerFactory to org.glassfish.jersey.internal.inject.InjectionManagerFactory
 at org.apache.pulsar.sql.presto.PulsarRecordCursor.advanceNextPosition(PulsarRecordCursor.java:450)
 at io.prestosql.spi.connector.RecordPageSource.getNextPage(RecordPageSource.java:90)
 at io.prestosql.operator.TableScanOperator.getOutput(TableScanOperator.java:302)
 at io.prestosql.operator.Driver.processInternal(Driver.java:379)
 at io.prestosql.operator.Driver.lambda$processFor$8(Driver.java:283)
 at io.prestosql.operator.Driver.tryWithLock(Driver.java:675)
 at io.prestosql.operator.Driver.processFor(Driver.java:276)
 at io.prestosql.execution.SqlTaskExecution$DriverSplitRunner.processFor(SqlTaskExecution.java:1075)
 at io.prestosql.execution.executor.PrioritizedSplitRunner.process(PrioritizedSplitRunner.java:163)
 at io.prestosql.execution.executor.TaskExecutor$TaskRunner.run(TaskExecutor.java:484)
 at io.prestosql.$gen.Presto_332__testversion____20210204_021336_2.run(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.concurrent.ExecutionException: org.apache.pulsar.client.admin.PulsarAdminException: java.util.concurrent.ExecutionException: org.apache.pulsar.client.admin.PulsarAdminException$GettingAuthenticationDataException: java.lang.ClassCastException: Cannot cast org.glassfish.jersey.inject.hk2.Hk2InjectionManagerFactory to org.glassfish.jersey.internal.inject.InjectionManagerFactory
 at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
 at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1908)
 at org.apache.pulsar.sql.presto.PulsarRecordCursor.advanceNextPosition(PulsarRecordCursor.java:448)
 ... 13 more
Caused by: org.apache.pulsar.client.admin.PulsarAdminException: java.util.concurrent.ExecutionException: org.apache.pulsar.client.admin.PulsarAdminException$GettingAuthenticationDataException: java.lang.ClassCastException: Cannot cast org.glassfish.jersey.inject.hk2.Hk2InjectionManagerFactory to org.glassfish.jersey.internal.inject.InjectionManagerFactory
 at org.apache.pulsar.client.admin.internal.BaseResource.getApiException(BaseResource.java:229)
 at org.apache.pulsar.client.admin.internal.SchemasImpl$3.failed(SchemasImpl.java:150)
 at org.apache.pulsar.client.admin.internal.BaseResource.asyncGetRequest(BaseResource.java:166)
 at org.apache.pulsar.client.admin.internal.SchemasImpl.getSchemaInfoAsync(SchemasImpl.java:141)
 at org.apache.pulsar.client.admin.internal.SchemasImpl.getSchemaInfo(SchemasImpl.java:125)
 at org.apache.pulsar.sql.presto.PulsarSqlSchemaInfoProvider.loadSchema(PulsarSqlSchemaInfoProvider.java:123)
 at org.apache.pulsar.sql.presto.PulsarSqlSchemaInfoProvider.access$000(PulsarSqlSchemaInfoProvider.java:52)
 at org.apache.pulsar.sql.presto.PulsarSqlSchemaInfoProvider$1.load(PulsarSqlSchemaInfoProvider.java:64)
 at org.apache.pulsar.sql.presto.PulsarSqlSchemaInfoProvider$1.load(PulsarSqlSchemaInfoProvider.java:61)
 at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3529)
 at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2278)
 at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2155)
 at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2045)
 at com.google.common.cache.LocalCache.get(LocalCache.java:3951)
 at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3974)
 at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4935)
 at org.apache.pulsar.sql.presto.PulsarSqlSchemaInfoProvider.getSchemaByVersion(PulsarSqlSchemaInfoProvider.java:79)
 ... 14 more
Caused by: java.util.concurrent.ExecutionException: org.apache.pulsar.client.admin.PulsarAdminException$GettingAuthenticationDataException: java.lang.ClassCastException: Cannot cast org.glassfish.jersey.inject.hk2.Hk2InjectionManagerFactory to org.glassfish.jersey.internal.inject.InjectionManagerFactory
 at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
 at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1908)
 at org.apache.pulsar.client.admin.internal.BaseResource.request(BaseResource.java:67)
 at org.apache.pulsar.client.admin.internal.BaseResource.asyncGetRequest(BaseResource.java:164)
 ... 28 more
Caused by: org.apache.pulsar.client.admin.PulsarAdminException.GettingAuthenticationDataException: java.lang.ClassCastException: Cannot cast org.glassfish.jersey.inject.hk2.Hk2InjectionManagerFactory to org.glassfish.jersey.internal.inject.InjectionManagerFactory
 at org.apache.pulsar.client.admin.internal.BaseResource.lambda$requestAsync$1(BaseResource.java:106)
 at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774)
 at java.util.concurrent.CompletableFuture.uniWhenCompleteStage(CompletableFuture.java:792)
 at java.util.concurrent.CompletableFuture.whenComplete(CompletableFuture.java:2153)
 at org.apache.pulsar.client.admin.internal.BaseResource.requestAsync(BaseResource.java:87)
 ... 30 more
Caused by: java.lang.ClassCastException: Cannot cast org.glassfish.jersey.inject.hk2.Hk2InjectionManagerFactory to org.glassfish.jersey.internal.inject.InjectionManagerFactory
 at java.lang.Class.cast(Class.java:3369)
 at org.glassfish.jersey.internal.ServiceFinder$LazyObjectIterator.hasNext(ServiceFinder.java:690)
 at org.glassfish.jersey.internal.inject.Injections.lookupService(Injections.java:88)
 at org.glassfish.jersey.internal.inject.Injections.lookupInjectionManagerFactory(Injections.java:73)
 at org.glassfish.jersey.internal.inject.Injections.createInjectionManager(Injections.java:44)
 at org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:412)
 at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:317)
 at org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:807)
 at org.glassfish.jersey.client.ClientRequest.getClientRuntime(ClientRequest.java:219)
 at org.glassfish.jersey.client.ClientRequest.getInjectionManager(ClientRequest.java:610)
 at org.glassfish.jersey.client.JerseyWebTarget.onBuilder(JerseyWebTarget.java:364)
 at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:199)
 at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:36)
 at org.apache.pulsar.client.admin.internal.BaseResource.lambda$requestAsync$1(BaseResource.java:96)
 ... 34 more

Modifications

  1. set thread context classLoader.
  2. remove useless dependencies.

Verifying this change

This change is already covered by existing tests.

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

@@ -107,12 +107,6 @@
<version>${presto.version}</version>
</dependency>

<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

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

why is the pulsar client removed here? The pulsar presto connector need the admin client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

<dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>pulsar-client-admin-original</artifactId>
    <version>${project.version}</version>
</dependency>

This dependency already exists, it contains pulsar-client-original.

@codelipenghui codelipenghui changed the title [Pulsar SQL] Fix injection factory cast error [Pulsar SQL] Fix injection factory cast error (fix master broken) Feb 4, 2021
@codelipenghui codelipenghui added this to the 2.8.0 milestone Feb 4, 2021
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

awesome work

@@ -98,6 +99,7 @@ public String getTopicName() {
}

private SchemaInfo loadSchema(BytesSchemaVersion bytesSchemaVersion) throws PulsarAdminException {
Thread.currentThread().setContextClassLoader(InjectionManagerFactory.class.getClassLoader());
Copy link
Contributor

Choose a reason for hiding this comment

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

if you set the Thread Context Classloader you have to restore it in a finally block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for reminding me, I'll fix it.

@sijie sijie added the area/sql Pulsar SQL related features label Feb 4, 2021
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

LGTM

@eolivelli
Copy link
Contributor

eolivelli commented Feb 4, 2021

SQL integration tests passed !
and also the License check (it may have failed due to the changes to the pom.xml)

@eolivelli
Copy link
Contributor

/pulsar-bot run-failure-tests

@codelipenghui codelipenghui merged commit fa89a03 into apache:master Feb 4, 2021
@gaoran10 gaoran10 deleted the fix-injector-factory-cast-error-in-sql branch February 4, 2021 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sql Pulsar SQL related features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI is broken on master failing on SQL integration test
8 participants