Original Submission When migrating a repo to Gerrit, Tuleap has to perform several steps in sequence. One of these steps is to create new groups if needed and assign members in these groups.
If a group is composed of several users, Tuleap will flush all caches each time after adding each individual user, one at a time! This has a detrimental effect on the server response time to users when performing these operations.
Currently the workflow is as follows:
foreach group
gerrit ls-groups // Why doing an ls-groups inside a loop?? This won't scale well to thousands of groups.
foreach username
gerrit set-account username
gerrit gsql --format json -c INSERT\ INTO\ account_group_members\ ......
gerrit flush-caches
end
end
Instead, you should find a way to add all users to a group in a single GSQL call (not sure it's possible, though). Also, Tuleap should flush the proper caches only at the very end of the operation, maybe between each group and at least once at the very end, but certainly not for each user. Imagine the case where a group is composed of hundreds of users!!
foreach group
gerrit ls-groups // Can't you move this before the loop and save the results instead?
foreach username
gerrit set-account username
gerrit gsql --format json -c INSERT\ INTO\ account_group_members\ ......
// Renove this: gerrit flush-caches
end
// Move it here: gerrit flush-caches
end
// Or move it here: gerrit flush-caches
Please take into consideration the note I left in the workflow regarding the potentially abusive use of ls-groups inside a loop. I am afraid it will cause performance issues when dealing with thousands of groups, so please consider running it once and save its output instead of running it inside a loop.
Resolution to this bug is related to bug #3241. Regardless of where the flush-cache instruction is relocated it cannot flush *all* caches this way, ever.