Closed pradeepgururani closed 10 months ago
Have tried setting options.TenantType = TenantTypes.HierarchicalTenant | TenantTypes.AddSharding;
as well. With Hierarchical + Sharding we are able to create only top level and no child level.
Is Hierarchical tenancy and sharding mutually exclusive?
Hi @pradeepgururani,
OK, you are trying to create a hierarchical multi-tenant in one database, which is fine (Example4 does this). The problem is you need to use the IAuthTenantAdminService
service. The IShardingOnlyTenantAddRemove
service is only for a sharding-only tenants.
But we don't want only hierarchical multi-tenant. We want it with sharding support. We are fine with the premise that top level tenant alone will have own DBs and child level tenant will reside with their parent tenant db. In our case this is not working while using IAuthTenantAdminService.AddHierarchicalTenantAsync
.
The hasOwnDb parameter is true, but the sharding database name 'SignOn-20240120163734-870' already has tenant(s) using that database.
In your examples we couldn't find any example with hierarchical + sharding combination. We could use help from your side.
I think you haven't understand the different services used for the two sharding approaches: hybrid and sharding-only sharding.
You have selected the hybrid approach so you should use the IAuthTenantAdminService service. The IShardingOnlyTenantAddRemove is only for the sharding-only type, so if you give it a tenant that shares a database then it will give you an error.
I recommend you read the article called The (long) journey to a better sharding multi-tenant application which explains that hybrid type has to have manually manages because a tenant's data might be in a database shared by other tenants, or it could have its own database. What I did find that the sharding-only type has only one way to work, so I created the IShardingOnlyTenantAddRemove
service to make it easier for the developer and admin user.
PS. If you are using Sign up for a new tenant, with versioning with the hybrid type, then you need to create a ISignUpGetShardingEntry
that can handle many tenants sharing one database AND tenants that have their own database. The Sign Up documentation has a section on the ISignUpGetShardingEntry
with examples
We are trying setup multi level tenant app with sharding. We are using the latest version of library. Net framework is 8.0 and DB is postgres.
Following is AuthP configuration:
We are using
IAuthTenantAdminService.AddHierarchicalTenantAsync
to create tenants. We are able to create top level tenants. However we try to create a child tenant, we get following error:Error gives me feeling that for child tenants it is not possible to have their own DB so we tried creating child tenant with
hasOwnDb
property totrue
,false
,null
values but above error is coming in all scenarios.We also tried using
IShardingOnlyTenantAddRemove.CreateTenantAsync
but no avail. Same error.What are we missing?