EventStore / replicator

Real-time replication tool
https://replicator.eventstore.org
Apache License 2.0
20 stars 11 forks source link

"Cannot modify ServiceCollection after application is built" with TCP reader #47

Closed AdrianM closed 2 years ago

AdrianM commented 2 years ago

When i start the replicator (HELM 0.4.4), i get the following stack trace:

System.InvalidOperationException: Cannot modify ServiceCollection after application is built. at Microsoft.AspNetCore.WebApplicationServiceCollection.CheckServicesAccess() at Microsoft.AspNetCore.WebApplicationServiceCollection.Add(ServiceDescriptor item) at Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(IServiceCollection services, Type serviceType, Object implementationInstance) at Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton[TService](IServiceCollection services, TService implementationInstance) at EventStore.Replicator.Esdb.Tcp.TcpConfigurator.ConfigureEventStoreTcp(String connectionString, Boolean follower) in /app/src/EventStore.Replicator.Esdb.Tcp/Configurator.cs:line 39 at EventStore.Replicator.Esdb.Tcp.TcpConfigurator.ConfigureReader(String connectionString) in /app/src/EventStore.Replicator.Esdb.Tcp/Configurator.cs:line 18 at EventStore.Replicator.Factory.GetReader(String protocol, String connectionString) in /app/src/EventStore.Replicator/Factories.cs:line 11 at es_replicator.Startup.<>c__DisplayClass0_0.<ConfigureServices>b__2(IServiceProvider sp) in /app/src/es-replicator/Startup.cs:line 38

Looks like the problem is triggered in TcpConfigurator.cs in line 39 (but i have no solution for this, looks like a C# error). Another small bug is in line 10, it should say 'tcp' instead of 'tpc'

As a workaround, i tried to switch to gRPC and then run into another bug related with my previous issue about the empty Metadata object (https://github.com/EventStore/replicator/issues/39). It tries to read the "Metadata" object in line 15, 19 and 20 without null check in the class EventStore.Replicator.Esdb.Grpc/ConnectionExtensions.cs (https://github.com/EventStore/replicator/blob/0.4.4/src/EventStore.Replicator.Esdb.Grpc/ConnectionExtensions.cs). Since i try to go with TCP, this bug is less important to our project.

(Setup: Replicator 0.4.4, EventStore reader 20.10, EventStore sink 21.10, on Kubernetes with HELM)

Thank you and best regards, Adrian

alexeyzimarev commented 2 years ago

It's fixed in 0.4.5