You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have several clusters powered by Orleans v3.x with ADO.NET grain persistence (MySQL/PostgreSQL, payload in json/jsonb column) and want to upgrade them to v8.2+ with reasonable downtime (shutdown cluster -> deploy new version) and without persistent state loss. To achieve this goal I've tried to:
switch to new packages, annotate DTO and handle another changes described in migration guide
set correct state names in PersistentStateAttribute
slightly change Read/Write/Clear queries as I need to keep storing grain state payload in json column (for better readability and indexing support)
And it's almost here but with one problem: GrainIdHash and GrainTypeHash mismatch.
As I can see hashing algorithm was changed from JenkinsHash to xxHash32 in v7 (#7949). So, to complete the upgrade we need to handle this hashing change. Changing values in database seems to be too hard (big table without primary key, unable to compute new hashes just using SQL). But we have another way to do it: customizing HashPicker in AdoNetGrainStorage. Unfortunately, this property can't be simply configured via dependency injection and the only way to do it is something like that:
siloBuilder.AddAdoNetGrainStorageAsDefault();varstorageDescriptor= siloBuilder.Services.LastOrDefault(static d=> d.IsKeyedService && d.ServiceType ==typeof(IGrainStorage));if(storageDescriptor isnull)thrownew InvalidOperationException("Unable to find IGrainStorage service descriptor.");if(storageDescriptor.KeyedImplementationFactory isnull)thrownew InvalidOperationException("Unexpected IGrainStorage service descriptor content.");
siloBuilder.Services.Remove(storageDescriptor);
siloBuilder.Services.Add(ServiceDescriptor.KeyedSingleton(
storageDescriptor.ServiceType,
storageDescriptor.ServiceKey,(provider,key)=>{varstorage= storageDescriptor.KeyedImplementationFactory.Invoke(provider, key);if(storage is not AdoNetGrainStorage adoNetGrainStorage)thrownew InvalidOperationException("Unexpected IGrainStorage service implementation type."); adoNetGrainStorage.HashPicker =new StorageHasherPicker([new Orleans3Hasher()]);returnadoNetGrainStorage;}));
Although it works (upgraded cluster behaves as expected, existing grain state is available), this workaround is not reliable as it depends on internal Orleans implementation and could stop working after future updates.
Taking into account the above, I propose the following changes:
publicclassAdoNetGrainStorageOptions{// <existing properties>publicIStorageHasherPickerHashPicker{get;set;}}publicclassAdoNetGrainStorage{publicAdoNetGrainStorage(// other parametersIOptions<AdoNetGrainStorageOptions>options){//other assignmentsthis.HashPicker = options.Value.HashPicker;}}
This new property should have the same behavior as AdoNetGrainStorageOptions.GrainStorageSerializer with setting default value via PostConfigure if it's null.
Also it would be nice to add public Orleans v3-compatible IHasher implementation to keep customers from copy-paste JenkinsHash-based hasher.
In addition, I suppose this v3->v7 hashing change should be described in migration guide as its handling is a required step to migrate existing cluster without data loss.
The text was updated successfully, but these errors were encountered:
Hi,
I have several clusters powered by Orleans v3.x with ADO.NET grain persistence (MySQL/PostgreSQL, payload in json/jsonb column) and want to upgrade them to v8.2+ with reasonable downtime (shutdown cluster -> deploy new version) and without persistent state loss. To achieve this goal I've tried to:
PersistentStateAttribute
And it's almost here but with one problem:
GrainIdHash
andGrainTypeHash
mismatch.As I can see hashing algorithm was changed from JenkinsHash to xxHash32 in v7 (#7949). So, to complete the upgrade we need to handle this hashing change. Changing values in database seems to be too hard (big table without primary key, unable to compute new hashes just using SQL). But we have another way to do it: customizing
HashPicker
inAdoNetGrainStorage
. Unfortunately, this property can't be simply configured via dependency injection and the only way to do it is something like that:Although it works (upgraded cluster behaves as expected, existing grain state is available), this workaround is not reliable as it depends on internal Orleans implementation and could stop working after future updates.
Taking into account the above, I propose the following changes:
This new property should have the same behavior as
AdoNetGrainStorageOptions.GrainStorageSerializer
with setting default value viaPostConfigure
if it'snull
.Also it would be nice to add public Orleans v3-compatible
IHasher
implementation to keep customers from copy-paste JenkinsHash-based hasher.In addition, I suppose this v3->v7 hashing change should be described in migration guide as its handling is a required step to migrate existing cluster without data loss.
The text was updated successfully, but these errors were encountered: