User mapping - Investigate non deleted placeholder users
According to the Import User Mapping Kibana dashboard, some placeholder users failed to be deleted after reassignment.
There are two situations where this could happen:
- The user performed actions that caused issues to the reassignment process, like promoting an issue before the reassignment
- Placeholder references weren't created for some records, which caused some resources not to be reassigned.
We should investigate which case was the problem. If it was the number two, we must identify where we aren't creating the placeholder references.
To investigate the problem, we need to request Rails console access.
- We can start the investigation by fetching all source users that the reassignment was completed but is still associated with a placeholder user:
source_users = Import::SourceUser.with_status(:completed).where.not(placeholder_user: nil)
- Then, for each source user, we should check which table is still referencing the placeholder user
source_users.each do |source_user|
puts "Source user: #{source_user.id}"
Import::PlaceholderReferences::AliasResolver.models_with_data.each do |model, data|
columns = data[:columns].values - data[:columns_ignored_on_deletion].to_a
(columns & ::Gitlab::ImportExport::Base::RelationFactory::USER_REFERENCES).each do |user_reference_column|
if model.where(user_reference_column => source_user.placeholder_user_id).any?
puts "#{model} - #{user_reference_column}"
end
end
end
end
- Then, we need to identify what caused the records not to be reassigned
Edited by Rodrigo Tomonari