Xabaril / AspNetCore.Diagnostics.HealthChecks

Enterprise HealthChecks for ASP.NET Core Diagnostics Package
Apache License 2.0
4.05k stars 793 forks source link

AddHealthCheckEndpoint XX000: more than one owned sequence found #2210

Open maikebing opened 4 months ago

maikebing commented 4 months ago
    services.AddHealthChecksUI(config =>
           {
               config.AddHealthCheckEndpoint(typeof(Startup).Assembly.GetName().Name, $"/healthz");

               try
               {
                   using (Npgsql.NpgsqlConnection connection = new NpgsqlConnection(Configuration.GetConnectionString("DefaultConnection")))
                   {
                       connection.Open();
                       using (var cmd = connection.CreateCommand())
                       {
                           cmd.CommandText = "SELECT  \"Id\", \t \"ServerIPAddress\"  FROM \t\"Plazas\"";
                           using (var reader = cmd.ExecuteReader())
                           {
                               var servers = reader.ToList<(string Id, string ServerIPAddress)>();
                               servers.Distinct(c => c.Id).ToList().ForEach(s => config.AddHealthCheckEndpoint(s.Id, $"http://{s.ServerIPAddress}/healthz"));
                           }
                       }
                   }
               }
               catch (Exception ex)
               {
                   Console.WriteLine("error:"+ex.Message);
               }
           }
        ).AddPostgreSqlStorage(Configuration.GetConnectionString("DefaultConnection"));

Please, fill the following sections to help us fix the issue


**What happened**:
etcom_1  | 2024-05-06T04:49:15.398129684Z fail: Microsoft.EntityFrameworkCore.Update[10000]
etcom_1  | 2024-05-06T04:49:15.398149955Z       An exception occurred in the database while saving changes for context type 'HealthChecks.UI.Data.HealthChecksDb'.
etcom_1  | 2024-05-06T04:49:15.398154827Z       Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.
etcom_1  | 2024-05-06T04:49:15.398158978Z        ---> Npgsql.PostgresException (0x80004005): XX000: more than one owned sequence found
etcom_1  | 2024-05-06T04:49:15.398163309Z          at Npgsql.Internal.NpgsqlConnector.ReadMessageLong(Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
etcom_1  | 2024-05-06T04:49:15.398167368Z          at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
etcom_1  | 2024-05-06T04:49:15.398171503Z          at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398174947Z          at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398178431Z          at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398181720Z          at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398185271Z          at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398188628Z          at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398192802Z          at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398196747Z          at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398200174Z         Exception data:
etcom_1  | 2024-05-06T04:49:15.398203312Z           Severity: ERROR
etcom_1  | 2024-05-06T04:49:15.398207224Z           SqlState: XX000
etcom_1  | 2024-05-06T04:49:15.398210302Z           MessageText: more than one owned sequence found
etcom_1  | 2024-05-06T04:49:15.398244944Z           File: pg_depend.c
etcom_1  | 2024-05-06T04:49:15.398248494Z           Line: 816
etcom_1  | 2024-05-06T04:49:15.398251736Z           Routine: getOwnedSequence
etcom_1  | 2024-05-06T04:49:15.398270111Z          --- End of inner exception stack trace ---
etcom_1  | 2024-05-06T04:49:15.398274658Z          at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398297680Z          at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398326899Z          at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398332115Z          at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398335855Z          at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398339316Z          at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398360719Z          at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398364483Z          at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398367845Z       Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.
etcom_1  | 2024-05-06T04:49:15.398371226Z        ---> Npgsql.PostgresException (0x80004005): XX000: more than one owned sequence found
etcom_1  | 2024-05-06T04:49:15.398374620Z          at Npgsql.Internal.NpgsqlConnector.ReadMessageLong(Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
etcom_1  | 2024-05-06T04:49:15.398379186Z          at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
etcom_1  | 2024-05-06T04:49:15.398382846Z          at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398386155Z          at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398401059Z          at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398494068Z          at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398500750Z          at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398510665Z          at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398532288Z          at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
etcom_1  | 2024-05-06T04:49:15.398545304Z          at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)

What you expected to happen:

How to reproduce it (as minimally and precisely as possible):

Source code sample:

Anything else we need to know?:

Environment: