MASA.Framework icon indicating copy to clipboard operation
MASA.Framework copied to clipboard

.net8环境下,雪花ID在使用Redis的时候发生Stack overflow异常

Open januswx opened this issue 2 years ago • 1 comments

Description

Stack overflow. Repeat 2911 times:

at System.Text.Json.JsonSerializer.WriteCore[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Text.Json.Utf8JsonWriter, System.__Canon ByRef, System.Text.Json.Serialization.Metadata.JsonTypeInfo1<System.__Canon>) at System.Text.Json.JsonSerializer.Serialize[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Text.Json.Utf8JsonWriter, System.__Canon, System.Text.Json.JsonSerializerOptions) at System.Text.Json.Serialization.JsonConverter1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TryWrite(System.Text.Json.Utf8JsonWriter, System.__Canon ByRef, System.Text.Json.JsonSerializerOptions, System.Text.Json.WriteStack ByRef) at System.Text.Json.Serialization.JsonConverter`1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].WriteCore(System.Text.Json.Utf8JsonWriter, System.__Canon ByRef, System.Text.Json.JsonSerializerOptions, System.Text.Json.WriteStack ByRef)

at System.Text.Json.JsonSerializer.WriteCore[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Text.Json.Utf8JsonWriter, System.__Canon ByRef, System.Text.Json.Serialization.Metadata.JsonTypeInfo1<System.__Canon>) at System.Text.Json.JsonSerializer.Serialize[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Text.Json.Utf8JsonWriter, System.__Canon, System.Text.Json.JsonSerializerOptions) at System.Text.Json.Serialization.JsonConverter1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TryWrite(System.Text.Json.Utf8JsonWriter, System.__Canon ByRef, System.Text.Json.JsonSerializerOptions, System.Text.Json.WriteStack ByRef) at System.Text.Json.Serialization.Metadata.JsonPropertyInfo1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetMemberAndWriteJson(System.Object, System.Text.Json.WriteStack ByRef, System.Text.Json.Utf8JsonWriter) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].OnTryWrite(System.Text.Json.Utf8JsonWriter, System.__Canon, System.Text.Json.JsonSerializerOptions, System.Text.Json.WriteStack ByRef) at System.Text.Json.Serialization.JsonConverter1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TryWrite(System.Text.Json.Utf8JsonWriter, System.__Canon ByRef, System.Text.Json.JsonSerializerOptions, System.Text.Json.WriteStack ByRef) at System.Text.Json.Serialization.JsonConverter1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].WriteCore(System.Text.Json.Utf8JsonWriter, System.__Canon ByRef, System.Text.Json.JsonSerializerOptions, System.Text.Json.WriteStack ByRef) at System.Text.Json.JsonSerializer.WriteCore[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Text.Json.Utf8JsonWriter, System.__Canon ByRef, System.Text.Json.Serialization.Metadata.JsonTypeInfo1<System.__Canon>) at System.Text.Json.JsonSerializer.WriteString[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon ByRef, System.Text.Json.Serialization.Metadata.JsonTypeInfo1<System.__Canon>) at Masa.Contrib.Caching.Distributed.StackExchangeRedis.RedisCacheClient.Publish(System.String, System.Action`1<Masa.BuildingBlocks.Caching.PublishOptions>) at Masa.Contrib.Data.IdGenerator.Snowflake.Distributed.Redis.DistributedWorkerProvider.GetWorkerIdAsync() at Masa.Contrib.Data.IdGenerator.Snowflake.Internal.WorkerIdBackgroundServices+<ExecuteAsync>d__7.MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Masa.Contrib.Data.IdGenerator.Snowflake.Internal.WorkerIdBackgroundServices+<ExecuteAsync>d__7, Masa.Contrib.Data.IdGenerator.Snowflake, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]](<ExecuteAsync>d__7 ByRef) at Masa.Contrib.Data.IdGenerator.Snowflake.Internal.WorkerIdBackgroundServices.ExecuteAsync(System.Threading.CancellationToken) at Microsoft.Extensions.Hosting.BackgroundService.StartAsync(System.Threading.CancellationToken) at Microsoft.Extensions.Hosting.Internal.Host+<StartAsync>d__12.MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.Extensions.Hosting.Internal.Host+<StartAsync>d__12, Microsoft.Extensions.Hosting, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<StartAsync>d__12 ByRef) at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(System.Threading.CancellationToken) at Microsoft.AspNetCore.Builder.WebApplication.StartAsync(System.Threading.CancellationToken) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions+<RunAsync>d__4.MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions+<RunAsync>d__4, Microsoft.Extensions.Hosting.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<RunAsync>d__4 ByRef) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(Microsoft.Extensions.Hosting.IHost, System.Threading.CancellationToken) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(Microsoft.Extensions.Hosting.IHost) at Microsoft.AspNetCore.Builder.WebApplication.Run(System.String) at Program+<<Main>$>d__0.MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon ByRef) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon ByRef) at Program.<Main>$(System.String[]) at Program.<Main>(System.String[])

Reproduction Steps

services.AddSnowflake(distributedIdGeneratorOptions =>
{
    distributedIdGeneratorOptions.UseRedis(
        option => option.GetWorkerIdMinInterval = 5000, redisConfigurationOptions);
});

Expected behavior

No response

Actual behavior

No response

Known Workarounds

情况与 issue #560 相同,#560 通过在services.AddMultilevelCache中自定义JsonSerializerOptions,可以解决,但是在雪花ID这里没有自定义JsonSerializerOptions的地方。

.NET version

8.0

MASA Framework version

1.0.0

Other information

No response

januswx avatar Dec 12 '23 01:12 januswx

请提供完整项目

duiapro avatar Apr 03 '24 02:04 duiapro