[SERVER-73383] Defragmentation may start over right after finishing Created: 27/Jan/23  Updated: 29/Oct/23  Resolved: 22/Mar/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 5.3.0, 6.0.0, 6.1.0, 6.2.0-rc6
Fix Version/s: 7.0.0-rc0, 6.0.6, 6.3.1

Type: Bug Priority: Major - P3
Reporter: Silvia Surroca Assignee: Silvia Surroca
Resolution: Fixed Votes: 0
Labels: sharding-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
is depended on by SERVER-71917 Update defragmentation tests to use v... Closed
Problem/Incident
is caused by SERVER-61555 Link the defragmentation policy to Co... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.3, v6.0
Sprint: Sharding EMEA 2023-02-06, Sharding EMEA 2023-02-20, Sharding EMEA 2023-03-06, Sharding EMEA 2023-03-20, Sharding EMEA 2023-04-03
Participants:
Linked BF Score: 5

 Description   

It may happen that defragmentation start over right after finishing.

This is the flow that leads to a defragmentation undesired restart on collA:

1. The Balancer thread reads all the collection entries when collA defragmentation didn't finish yet.

2. Defragmentation on collA finishes and the BalancerSecondary thread removes the _defragmentationStates collection entry and clears the defragmentation flags on collA config.collections entry

3. The Balancer calls startCollectionDefragmentation using a stale config.collections entry for collA and an updated _defragmentationStates map

4. Due to point 3, on startCollectionDefragmentation function, we don't return on this condition and we init the collection defragmentation again. 

 

Note that when defragmentation starts over unexpectedly, the defragmentCollection field for collA remains unset, while the defragmentationPhase field has a valid defragmentation phase other than null.



 Comments   
Comment by Githook User [ 13/Apr/23 ]

Author:

{'name': 'Silvia Surroca', 'email': 'silvia.surroca@mongodb.com', 'username': 'silviasuhu'}

Message: SERVER-73383 Defragmentation may start over right after finishing

(cherry picked from commit 713d6f3d730c2ae15c68ba406c5572b47c859747)
Branch: v6.3
https://github.com/mongodb/mongo/commit/61f6d836338319a4b17fcbf87584aa560e58df23

Comment by Githook User [ 27/Mar/23 ]

Author:

{'name': 'Silvia Surroca', 'email': 'silvia.surroca@mongodb.com', 'username': 'silviasuhu'}

Message: SERVER-73383 Defragmentation may start over right after finishing
Branch: v6.0
https://github.com/mongodb/mongo/commit/906a72befc5c84095a3329c97f78f489e8b6e895

Comment by Githook User [ 21/Mar/23 ]

Author:

{'name': 'Silvia Surroca', 'email': 'silvia.surroca@mongodb.com', 'username': 'silviasuhu'}

Message: SERVER-73383 Defragmentation may start over right after finishing
Branch: master
https://github.com/mongodb/mongo/commit/713d6f3d730c2ae15c68ba406c5572b47c859747

Generated at Thu Feb 08 06:24:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.