|
Investigating the description of the ticket, we can identify three different issues:
- If we have a compound shard key, removeTagRange is not removing correctly the tag from config.tags.
- Since v4.4, it does not apply. We can check the correct behaviour with this simplified reproducible.
(function() {
|
'use strict';
|
// Configure initial sharding cluster
|
const st = new ShardingTest({});
|
|
// Shard collection
|
const db = st.s.getDB("test");
|
st.shardColl(db.coll, {skey1: 1, skey2: 1});
|
|
// Add tag range
|
st.addShardTag(st.shard1.shardName, 'A');
|
assert.commandWorked(st.addTagRange(db.coll.getFullName(), {skey1: MinKey}, {skey1: 10}, "A"));
|
|
// Make sure that tag range has been added
|
assert.eq(1, st.s.getDB("config").tags.find({}).itcount());
|
|
// Remove tag range
|
assert.commandWorked(st.removeTagRange(db.coll.getFullName(), {skey1: MinKey}, {skey1: 10}, "A"));
|
|
// Make sure that tag range has been removed
|
assert.eq(0, st.s.getDB("config").tags.find({}).itcount());
|
|
st.stop();
|
})();
|
- When we use removeTagRange with a non-existent range, the command will return ok: 1.
- This is a correct behaviour because the command has succeeded but it has not removed entries.
- Finally, removeTagRange(nss, min, max, tagName) ignores the tagName. It will remove the range independently of the tag name associated.
- This command (removeTagRange) is an alias of removeRangeFromZone. As we can see in the docs, removeRangeFromZone(nss, min, max) removes the range from the tag without passing this as a parameter. It can be done this way because there is a 1:N relation between tags - ranges. One range can only belong to one tag, thus there is no need to have the tag name to remove a range.
|