Skip to content

Conversation

@hll1213181368
Copy link
Contributor

we read from an old cluster that had -1 denoting !isMigrating, but new cluster migrating_slot value is string type. so we should return "-1" is not -1.

@git-hulk
Copy link
Member

git-hulk commented Sep 7, 2025

@hll1213181368 Can you share which version(or commit id) you're using? I cannot find which version was using the string type for the migration slot.

@hll1213181368
Copy link
Contributor Author

hll1213181368 commented Sep 8, 2025

@hll1213181368 Can you share which version(or commit id) you're using? I cannot find which version was using the string type for the migration slot.

@git-hulk

in the slot.go file. The function of MigrateSlot's String() returns string type to caller. The cases are following:
1)return null if new version is not migrating.
2)return string if new version is migrating.
3)return "-1" if old version is not migrating.

So I think, we should return string to caller.

@hll1213181368 hll1213181368 changed the title Fix old cluster that had -1 denoting isNotMigrating, compatible cluster migrating_slot value is string type Fix old cluster that had -1 denoting isNotMigrating, compatible new cluster migrating_slot value is string type Sep 8, 2025
Compatible with old version migrating_slot  is -1 to return null
@hll1213181368
Copy link
Contributor Author

@git-hulk Please review my pull. I modify the cluster is not migrating to return nil. Compatibly with old version return -1.

@greatsharp
Copy link
Contributor

int -1 is used before @bseto chaning migrate single slot to SlotRange,
suggest to return "migrating_slot":null when fetching old cluster info with -1 from storage,
and suggest to update old cluster info with -1 back into storage with "migrating_slot":null too.

@git-hulk
Copy link
Member

git-hulk commented Sep 19, 2025

@greatsharp @hll1213181368 I'm sorry that I cannot get what's going wrong in your case.

What your change is from -1 to null when storing, but the PR title is fixing the compatibility issue.

@hll1213181368
Copy link
Contributor Author

@greatsharp @hll1213181368 I'm sorry that I cannot get what's going wrong in your case.

What your change is from -1 to null when storing, but the PR title is fixing the compatibility issue.

@git-hulk 我直接中文交流吧。
之前旧版本单slot迁移的时候,migrating_slot返回字段值为整型,不处于迁移中,migrating_slot返回-1,这些信息保存在etcd中。

现在新版本支持slot范围迁移,migrating_slot返回的是字符串,例如:正在迁移1024-2048区间段,返回的是“1024-2048”;如果不处于迁移中,返回的是null。

现在为了兼容之前旧集群保存在etcd中的migrating_slot为-1信息。针对新旧集群,如果不处于迁移中,都返回nil。旧集群在新版本控制器做切换更新拓扑后,会把之前-1的更改为nil。

@hll1213181368 hll1213181368 changed the title Fix old cluster that had -1 denoting isNotMigrating, compatible new cluster migrating_slot value is string type Fix old cluster that had -1 denoting isNotMigrating, compatible new cluster migrating_slot value type Sep 19, 2025
@git-hulk git-hulk changed the title Fix old cluster that had -1 denoting isNotMigrating, compatible new cluster migrating_slot value type Marshal the value into the null value if the slot is not migrating Sep 19, 2025
git-hulk
git-hulk previously approved these changes Sep 19, 2025
modify the TestMigratingSlot_MarshalJSON expected value
@codecov-commenter
Copy link

codecov-commenter commented Sep 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.30%. Comparing base (6c56470) to head (2fc56e6).
⚠️ Report is 92 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable     #346      +/-   ##
============================================
+ Coverage     43.38%   47.30%   +3.91%     
============================================
  Files            37       45       +8     
  Lines          2971     4446    +1475     
============================================
+ Hits           1289     2103     +814     
- Misses         1544     2135     +591     
- Partials        138      208      +70     
Flag Coverage Δ
unittests 47.30% <100.00%> (+3.91%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hll1213181368
Copy link
Contributor Author

@git-hulk Please review my PR.

After we will commit new PR to fix tryUpdateMigrationStatus function code:
if !sourceNodeClusterInfo.MigratingSlot.Equal(shard.MigratingSlot.SlotRange){}


sourceNodeClusterInfo.MigratingSlot maybe return nil

@git-hulk git-hulk merged commit 686b338 into apache:unstable Sep 29, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants