dotnetcore / dotnetcore/sharding-core

ShardingRuntimeBuilder方式导致内存溢出

Open
#304 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.3k
Forks
183
Avg merge
7h 43m
Merged PRs (30d)
1

Description

我无法在 Startup.cs中使用,因为我的ApplicationDbContext必须在服务器启动完成后再注册的:
services.AddDbContext《ApplicationDbContext>((sp, b) =>
{
var tenantManager = sp.GetRequiredService《ITenantManager>();
if (shardingRuntimeContext!= null)
{
b.UseDefaultSharding《ApplicationDbContext>(shardingRuntimeContext);
}
});
以上代码我无法在 Startup.cs中使用,也就是在服务器启动期间。

所以我在使用ShardingRuntimeBuilder方式,并在ApplicationDbContext的OnConfiguring方法里来实现optionsBuilder.UseDefaultSharding(),但是会出现OnConfiguring方法被无限循环调用,导致内存溢出:

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (shardingRuntimeContext != null)
{
optionsBuilder.UseDefaultSharding《ApplicationDbContext>(shardingRuntimeContext);
}

base.OnConfiguring(optionsBuilder);
}

shardingRuntimeContext变量获取相关的代码这里已经删除省略

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.