Closed gopskrish closed 2 weeks ago
Hi @gopskrish,
The ShardingCache file contains data that isn't held in a database, so loosing the ShardingCache file means that the tenants won't work. I have made the ShardingCache code pretty robust, but I do assume that the ShardingCache file is there. Deleting the ShardingCache file is NOT handled by the current code.
Yes, it could add code to hold the sharing information in a database as a backup, but since building this library I have dementia (see this article) but its not trivial and I would take a long time to create a solution - see this section as to why it would take a long time.
Hi @gopskrish,
I have been looking to this and here is what I plan to do. Can you check that this should fix your problem.
ShardingEntry
) is stored in the FileStore cache.ShardingEntry
data is held.ShardingEntryBackup
is added to the AuthPermissionsDbContext
to hold a backup of the ShardingEntry
in the FileStore cache. NOTE: AuthP is designed to add new migrations on startup.ShardingEntry
is changed (add, update, delete), then the change is applied to FileStore cache AND the ShardingEntryBackup
database. RegisterServiceToRunInJob
that will check if the FileStore cache matches the data in the ShardingEntryBackup
database (NOTE: this is optional. You need to add the new method in your AuthP configuration for it to work). If added it will run one of the three scenarios below:
ShardingEntry
’s in the ShardingEntryBackup
database into the FileStore cache.
ShardingEntryBackup
: The first time you add the RegisterServiceToRunInJob
to check the FileStore there will be no ShardingEntryBackup
. If FileStore cache has entries, then the FileStore cache entries will be written to the ShardingEntryBackup
. This means you are covered if a FileStore cache is deleted later.ShardingEntryBackup
both have entries: In this case it compares the two ShardingEntry
and throws an exception if they don't match. @JonPSmith I hope for your speedy recovery, Yes the suggested solution should be able to solve my problem thanks
Hi @gopskrish,
I have released AuthP version 8.1.0 which provides a backup version of the sharding entries in case that the FileStore Cache file is deleted. See the Securing the sharding data page in the AuthP Wiki.
I have my code deployed in the azure app, but if the server cache is cleared then the ShardingCache file is deleted and since this file is deleted the login breaks.
Is it necessary to cache the sharding and store it as file cache, it's a cache file right, if this file is deleted then the login breaks because, it can't find the db details if the file is not present. Shouldn't if fetch the details from the db if there's no file when the service is restated?
//This is used for a) hold the sharding entries and b) to set a tenant as "Down", builder.Services.AddDistributedFileStoreCache(options => { options.WhichVersion = FileStoreCacheVersions.Class; options.FirstPartOfCacheFileName = "Example6CacheFileStore"; }, builder.Environment);