Skip to content

Retry TestingTrinoServer setup when port is already used#13077

Merged
kokosing merged 1 commit intotrinodb:masterfrom
kokosing:origin/master/305_retry
Jul 4, 2022
Merged

Retry TestingTrinoServer setup when port is already used#13077
kokosing merged 1 commit intotrinodb:masterfrom
kokosing:origin/master/305_retry

Conversation

@kokosing
Copy link
Copy Markdown
Member

@kokosing kokosing commented Jul 4, 2022

Retry TestingTrinoServer setup when port is already used

Even we typically use random port to setup TestingTrinoServer there is a
low likelihood of a race condition where same port is used by two
concurrent tests.

In such case let's retry.

Even we typically use random port to setup TestingTrinoServer there is a
low likelihood of a race condition where same port is used by two
concurrent tests.

In such case let's retry.
@cla-bot cla-bot bot added the cla-signed label Jul 4, 2022
@kokosing kokosing requested review from findepi, sopel39 and wendigo July 4, 2022 11:57
@kokosing
Copy link
Copy Markdown
Member Author

kokosing commented Jul 4, 2022

An example of flaky failure looks like the below:

2) [Guice/ErrorInjectingConstructor]: UncheckedIOException: Failed to bind to localhost/127.0.0.1:45437
  at HttpServerInfo.<init>(HttpServerInfo.java:55)
  at GeneratedMethodAccessor36.invoke(Unknown Source)
  at LocalAnnouncementHttpServerInfo.<init>(LocalAnnouncementHttpServerInfo.java:31)
      \_ for 1st parameter httpServerInfo
  while locating LocalAnnouncementHttpServerInfo
  at DiscoveryBinder$HttpAnnouncementProvider.setAnnouncementHttpServerInfo(DiscoveryBinder.java:122)
      \_ for 1st parameter httpServerInfo
  at DiscoveryBinder.bindServiceAnnouncement(DiscoveryBinder.java:79)
      \_ installed by: ServerMainModule -> CoordinatorModule

Learn more:
  https://github.com/google/guice/wiki/ERROR_INJECTING_CONSTRUCTOR
Caused by: UncheckedIOException: Failed to bind to localhost/127.0.0.1:45437
	at HttpServerInfo.createChannel(HttpServerInfo.java:172)
	at HttpServerInfo.<init>(HttpServerInfo.java:57)
	at HttpServerInfo$$FastClassByGuice$$6630143.GUICE$TRAMPOLINE(<generated>)
	at HttpServerInfo$$FastClassByGuice$$6630143.apply(<generated>)
	at DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:82)
	at ConstructorInjector.provision(ConstructorInjector.java:114)
	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:300)
	at ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
	at SingletonScope$1.get(SingletonScope.java:169)
	at InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:45)
	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:300)
	at FactoryProxy.get(FactoryProxy.java:60)
	at SingleParameterInjector.inject(SingleParameterInjector.java:40)
	at SingleParameterInjector.getAll(SingleParameterInjector.java:60)
	at SingleMethodInjector.inject(SingleMethodInjector.java:84)
	at MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:146)
	at MembersInjectorImpl.injectAndNotify(MembersInjectorImpl.java:101)
	at Initializer$InjectableReference.get(Initializer.java:245)
	at Initializer.injectAll(Initializer.java:140)
	at InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
	at InternalInjectorCreator.build(InternalInjectorCreator.java:113)
	at Guice.createInjector(Guice.java:87)
	at Bootstrap.initialize(Bootstrap.java:270)
	at TestingTrinoServer.<init>(TestingTrinoServer.java:299)
	at TestingTrinoServer$Builder.build(TestingTrinoServer.java:736)
	at DistributedQueryRunner.createTestingTrinoServer(DistributedQueryRunner.java:263)
	at DistributedQueryRunner.<init>(DistributedQueryRunner.java:159)
	at DistributedQueryRunner$Builder.build(DistributedQueryRunner.java:780)
	at InsightsQueryRunner.createInsightsQueryRunner(InsightsQueryRunner.java:183)
	at DataProductTestFixtureRunner.createQueryRunner(DataProductTestFixtureRunner.java:189)
	at DataProductTestFixtureRunner.<init>(DataProductTestFixtureRunner.java:72)
	at DataProductTestFixtureRunner.<init>(DataProductTestFixtureRunner.java:91)
	at TestDataProductSupportedCatalogs.setUp(TestDataProductSupportedCatalogs.java:42)
	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.invokeConfigurationMethod(Invoker.java:515)
	at Invoker.invokeConfigurations(Invoker.java:217)
	at Invoker.invokeConfigurations(Invoker.java:144)
	at TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:169)
	at TestMethodWorker.run(TestMethodWorker.java:108)
	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: BindException: Address already in use
	at java.base/Net.bind0(Native Method)
	at java.base/Net.bind(Net.java:459)
	at java.base/Net.bind(Net.java:448)
	at java.base/ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
	at java.base/ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80)
	at HttpServerInfo.createChannel(HttpServerInfo.java:168)
	... 62 more
	```

@kokosing kokosing merged commit 5a72170 into trinodb:master Jul 4, 2022
@kokosing kokosing deleted the origin/master/305_retry branch July 4, 2022 19:27
@github-actions github-actions bot added this to the 389 milestone Jul 4, 2022
@findepi
Copy link
Copy Markdown
Member

findepi commented Jul 19, 2022

Even we typically use random port to setup TestingTrinoServer

Where is the random port coming from?

we should bind to 0 and this should guarantee a succesful bind
i think this is what we're doing.

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.

4 participants