-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fixed Actor metadata is stored under 'actors||actortype' partitionkey #7643
base: master
Are you sure you want to change the base?
Conversation
Changed that the Actor metadata is stored under correct partitionkey via 'constructCompositionKey' instead of 'calculatePartitionKey' which is used for the reminders partitions. This results in that the Actor metadata can be found and updated when a reminder gets stored or deleted, otherwise this will create a new metadata record with incorrect metadata configuration like 'partitionCount'. Issue: dapr#3380 (components-contrib) Signed-off-by: Mark van den Bosch <markvandenbosch@gmail.com>
Small comment to elaborate on the PR: I did some investigations regarding the issue 3380 which is reported to the compontents-contrib and I compared the behaviour in v1.10.4 (where it was working) and where it got broken (versions above that) and it turns out that when you create a reminder it will do a 'getActorMetadata' request based with a partitionKey 'constructCompositeKey("actors", actorType)', but this key is not created during the initial 'migrate' which creates the actor metadata in the fist place. During the initial creating of the actor metadata the partitionKey is based on the metadata.ID which is a GUID and passed through the transaction as a partitionKey. This results in that the metadata can't be found when you call 'storeReminder' or 'deleteReminder' and it will create a new actor metadata record with a incorrect configuration e.g. partitionKey 0. The fix is that it will execute two requests (transactions) instead of one with different metadata on the transactions. I can imaging this is maybe not what you want, but I don't see any way on how to distinguish between reminder partitionKeys and actor metadata partitionKeys in one transaction. Maybe somebody can point me to that? |
I don't think we can do this sadly, because at this stage it's not a single transaction, so if Dapr crashed half-way we'd have inconsistent state (or even if more than 1 Dapr sidecar is trying to write the same data) |
@ItalyPaleAle thanks for your reply. Had the same thought indeed and did some digging into the It's unfortunately not allowed to execute a So, if I change that (use the // Get the database partition key (needed for CosmosDB)
databasePartitionKey := actorMetadata.calculateDatabasePartitionKey(stateKey) Do you know if there is any reason why there is chosen for a GUID as a partitionKey? Or would be Or, Is there a way to obtain the new de facto // Also create a request to save the new metadata, so the new "metadataID" becomes the new de facto referenced list for reminders
stateOperations[len(stateOperations)-1] = r.saveActorTypeMetadataRequest(actorType, actorMetadata, stateMetadata) so that it can be used in the |
Co-authored-by: Cassie Coyle <cassie.i.coyle@gmail.com> Signed-off-by: Mark van den Bosch <markvandenbosch@gmail.com>
Description
Changed that the Actor metadata is stored under correct partitionkey via 'constructCompositionKey' instead of 'calculatePartitionKey' which is used for the reminders partitions.
This results in that the Actor metadata can be found and updated when a reminder gets stored or deleted, otherwise this will create a new metadata record with incorrect metadata configuration like 'partitionCount'.
Issue reference
Please reference the issue this PR will close: 3380 (components-contrib)
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: