frostfsid: Make migration idempotent #135

Merged
fyrchik merged 1 commit from achuprov/frostfs-contract:bugfix/frostfsid_migration into master 2024-12-12 06:28:20 +00:00
Member
No description provided.
achuprov added 3 commits 2024-12-05 14:17:41 +00:00
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
[#135] common: Update version
All checks were successful
DCO action / DCO (pull_request) Successful in 54s
Code generation / Generate wrappers (pull_request) Successful in 1m59s
Tests / Tests (pull_request) Successful in 2m4s
d1b0bd3676
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
requested reviews from fyrchik, storage-core-developers, storage-core-committers 2024-12-05 14:17:41 +00:00
achuprov reviewed 2024-12-05 14:24:28 +00:00
@ -652,0 +693,4 @@
updateContractFail(t, c1, e, c.Hash, args, "frostfsid contract contains duplicate keys")
invoker.Invoke(t, stackitem.Null{}, deleteSubjectMethod, subjBKeyAddr)
updateContract(t, c1, e, c.Hash, args)
updateContract(t, c1, e, c.Hash, args)
Author
Member

Сheck idempotency of the update

Сheck idempotency of the `update`
fyrchik reviewed 2024-12-06 03:52:29 +00:00
@ -651,1 +652,4 @@
const frostfsidContractName = "frostfsid"
func TestFrostfsid_Migration(t *testing.T) {
Owner

This is one time test, I do not see it being useful.
Could you remove it?

This is one time test, I do not see it being useful. Could you remove it?
fyrchik marked this conversation as resolved
fyrchik reviewed 2024-12-06 03:53:07 +00:00
@ -12,3 +12,3 @@
// any migration routines.
prevMajor = 0
prevMinor = 20
prevMinor = 21
Owner

21.0 is not deployed anywhere, we will definitely update on 21.1 in one step

21.0 is not deployed anywhere, we will definitely update on 21.1 in one step
achuprov marked this conversation as resolved
achuprov force-pushed bugfix/frostfsid_migration from d1b0bd3676 to cb5dc744a3 2024-12-06 11:49:21 +00:00 Compare
fyrchik reviewed 2024-12-06 12:21:41 +00:00
@ -116,2 +116,3 @@
if isUpdate {
it := storage.Find(ctx, subjectKeysPrefix, storage.ValuesOnly)
it := storage.Find(ctx, addressPrefix, storage.KeysOnly)
migrationCompleted := false
Owner

What do you need this flag for?

What do you need this flag for?
Author
Member

This flag means that contracts do not contain keys with addressPrefix. There are only two possible cases: either the contract does not contain subjects, or the migration wasn't executed. In both cases, the Update operation is idempotent

This flag means that contracts do not contain keys with `addressPrefix`. There are only two possible cases: either the contract does not contain subjects, or the migration wasn't executed. In both cases, the `Update` operation is idempotent
Owner

In what situation can it be true?

In what situation can it be true?
Author
Member

The flag can be set to true if the deploy is run again after migration

The flag can be set to true if the `deploy` is run again after migration
Owner

It runs only on update.
The not-run-twice logic is achived via Version variables.

It runs only on update. The not-run-twice logic is achived via Version variables.
fyrchik marked this conversation as resolved
achuprov force-pushed bugfix/frostfsid_migration from cb5dc744a3 to 871aa280b4 2024-12-10 18:24:41 +00:00 Compare
fyrchik reviewed 2024-12-11 10:16:47 +00:00
@ -102,18 +102,17 @@ const (
func _deploy(data any, isUpdate bool) {
ctx := storage.GetContext()
args := data.(struct {
Owner

This is unrelated to the commit.

This is unrelated to the commit.
fyrchik marked this conversation as resolved
achuprov force-pushed bugfix/frostfsid_migration from 871aa280b4 to 776b36499d 2024-12-11 15:38:27 +00:00 Compare
achuprov force-pushed bugfix/frostfsid_migration from 776b36499d to 9544465be3 2024-12-11 15:40:40 +00:00 Compare
achuprov force-pushed bugfix/frostfsid_migration from 9544465be3 to bc31d591e8 2024-12-11 15:42:42 +00:00 Compare
achuprov force-pushed bugfix/frostfsid_migration from bc31d591e8 to 01597b5dde 2024-12-12 06:18:47 +00:00 Compare
fyrchik approved these changes 2024-12-12 06:20:47 +00:00
fyrchik merged commit a3021f18cf into master 2024-12-12 06:28:20 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-developers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-contract#135
No description provided.