diff --git a/store/slot.go b/store/slot.go index 394ced5..ea3ec1a 100644 --- a/store/slot.go +++ b/store/slot.go @@ -227,13 +227,7 @@ func (s *MigratingSlot) UnmarshalJSON(data []byte) error { func (s *MigratingSlot) MarshalJSON() ([]byte, error) { if !s.IsMigrating { - // backwards compatibility. When we read from an old cluster that had `-1` - // denoting !isMigrating. The MigratingSlot field will not be nil. So when - // this field is marshal'd back into JSON format, we can keep it as it was - // which was `-1`. - // The only case this turns back to null is if a migration happens on this - // shard, and the function `ClearMigrateState()` is called on the shard. - return json.Marshal(NotMigratingInt) + return json.Marshal(nil) } return json.Marshal(s.String()) } diff --git a/store/slot_test.go b/store/slot_test.go index 6226323..0403320 100644 --- a/store/slot_test.go +++ b/store/slot_test.go @@ -94,17 +94,15 @@ func TestMigratingSlot_MarshalUnmarshalJSON(t *testing.T) { migratingSlot = MigratingSlot{SlotRange: SlotRange{Start: 0, Stop: 0}, IsMigrating: false} migratingSlotBytes, err = json.Marshal(&migratingSlot) require.NoError(t, err) - err = json.Unmarshal(migratingSlotBytes, &migratingSlot) - require.NoError(t, err) - assert.Equal(t, MigratingSlot{SlotRange{Start: 0, Stop: 0}, false}, migratingSlot) + // null []byte equal + assert.Equal(t, "null", string(migratingSlotBytes)) // same test as earlier, but checks that it resets the start and stop migratingSlot = MigratingSlot{SlotRange: SlotRange{Start: 5, Stop: 5}, IsMigrating: false} migratingSlotBytes, err = json.Marshal(&migratingSlot) require.NoError(t, err) - err = json.Unmarshal(migratingSlotBytes, &migratingSlot) - require.NoError(t, err) - assert.Equal(t, MigratingSlot{SlotRange{Start: 0, Stop: 0}, false}, migratingSlot, "expects start and stop to reset to 0") + // null []byte equal + assert.Equal(t, "null", string(migratingSlotBytes)) } // TestMigratingSlot_MarshalJSON will checks the resulting string @@ -122,7 +120,7 @@ func TestMigratingSlot_MarshalJSON(t *testing.T) { migratingSlot = MigratingSlot{SlotRange: SlotRange{Start: 5, Stop: 10}, IsMigrating: false} migratingSlotBytes, err = json.Marshal(&migratingSlot) require.NoError(t, err) - assert.Equal(t, `-1`, string(migratingSlotBytes)) + assert.Equal(t, `null`, string(migratingSlotBytes)) } func TestMigrateSlotRange_MarshalAndUnmarshalJSON(t *testing.T) {