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

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

Open
januswx opened this issue Dec 12, 2023 · 1 comment

Comments

@januswx
Copy link

januswx commented Dec 12, 2023

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+d__7.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Masa.Contrib.Data.IdGenerator.Snowflake.Internal.WorkerIdBackgroundServices+d__7, Masa.Contrib.Data.IdGenerator.Snowflake, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]](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+d__12.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.Extensions.Hosting.Internal.Host+d__12, Microsoft.Extensions.Hosting, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](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+d__4.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions+d__4, Microsoft.Extensions.Hosting.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](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+<

$>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.$(System.String[])
at Program.(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 januswx changed the title 雪花ID在使用Redis的时候在.net8下异常 .net8环境下,雪花ID在使用Redis的时候发生Stack overflow异常 Dec 12, 2023
@duiapro duiapro added bug Something isn't working and removed bug Something isn't working labels Apr 3, 2024
@duiapro
Copy link
Contributor

duiapro commented Apr 3, 2024

请提供完整项目

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants