Geo: Handle orphaned Uploads records
During manual verification of synced attachments on GPRD, I found 235 uploads associated with one project that does not exist. GPRD already had synced these uploads successfully. If it had not yet synced them, they would error on sync with:
NoMethodError: undefined method `hashed_storage?' for nil:NilClass
from /opt/gitlab/embedded/service/gitlab-rails/app/uploaders/file_uploader.rb:60:in `model_path_segment'
from /opt/gitlab/embedded/service/gitlab-rails/app/uploaders/file_uploader.rb:39:in `base_dir'
from /opt/gitlab/embedded/service/gitlab-rails/app/uploaders/file_uploader.rb:44:in `absolute_base_dir'
from /opt/gitlab/embedded/service/gitlab-rails/app/uploaders/file_uploader.rb:30:in `absolute_path'
from /opt/gitlab/embedded/service/gitlab-rails/app/models/upload.rb:32:in `absolute_path'
from /opt/gitlab/embedded/service/gitlab-rails/ee/lib/gitlab/geo/file_transfer.rb:11:in `initialize'
from /opt/gitlab/embedded/service/gitlab-rails/ee/lib/gitlab/geo/file_downloader.rb:26:in `new'
from /opt/gitlab/embedded/service/gitlab-rails/ee/lib/gitlab/geo/file_downloader.rb:26:in `execute'
from (irb):26
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/console.rb:110:in `start'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/console.rb:9:in `start'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:68:in `console'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:14:in `require'
from bin/rails:14:in `<main>'
because that error is raised in upload.absolute_path
when model
is nil
.
-
On sync, we could cover this case by checking if model.nil?
, and marking those as "synced but missing on primary" -
Additionally, attachment verification (not yet implemented in https://gitlab.com/gitlab-org/gitlab-ee/issues/5591) would need to cover this case => Added a TODO item in that issue to check off this item here.
More background info
Project ID: 3944618
Upload IDs: [727776, 727826, 732219, 732599, 733096, 734043, 734097, 738771, 739056, 739575, 739644, 740673, 744713, 746364, 746629, 757786, 757787, 757788, 757789, 758033, 758035, 758107, 758184, 758198, 758243, 758244, 758262, 758274, 759160, 759459, 759570, 763581, 763961, 763975, 764051, 764093, 764136, 764262, 769576, 769577, 769578, 769905, 769908, 769912, 769914, 769923, 770252, 770349, 770455, 770456, 776406, 776654, 777050, 777758, 781586, 781706, 781710, 781721, 781749, 789682, 789794, 790059, 790066, 790849, 790850, 790971, 795620, 795830, 795833, 795834, 801392, 801653, 801656, 801658, 801659, 801778, 801838, 802117, 802150, 802159, 802160, 802162, 802164, 802167, 802241, 815536, 830300, 830301, 831028, 831553, 831978, 877503, 877844, 877845, 877932, 878183, 878299, 878307, 878324, 878342, 878343, 878344, 878345, 878346, 878347, 878348, 878349, 878350, 878351, 878352, 878353, 878486, 878494, 883884, 883897, 884590, 884593, 884596, 884703, 884704, 890511, 890514, 890597, 908050, 914158, 920245, 928364, 928492, 928561, 928653, 933251, 933764, 948523, 948526, 948630, 948676, 948678, 948737, 948743, 948744, 948746, 948749, 948806, 948808, 954749, 955903, 955912, 961659, 961665, 962581, 962642, 992548, 993168, 999137, 999138, 999274, 999288, 999814, 1006474, 1006481, 1006522, 1006527, 1006528, 1006530, 1006533, 1007113, 1007993, 1023650, 1023651, 1023684, 1023688, 1023891, 1024135, 1024141, 1024147, 1024151, 1024181, 1024183, 1024472, 1024570, 1038099, 1038100, 1038101, 1038103, 1044061, 1054337, 1054387, 1071317, 1071496, 1071510, 1071522, 1071553, 1071554, 1071564, 1071566, 1071568, 1072135, 1079687, 1080015, 1087429, 1087831, 1096889, 1096935, 1096936, 1103926, 1104058, 1116161, 1116965, 1116966, 1133732, 1133734, 1154286, 1154288, 1164648, 1192994, 1192997, 1193048, 1193619, 1193620, 1209176, 1226195, 1233774, 1264743, 1308338, 1308342, 1337350, 1337351, 1347250, 1347922, 1347926, 1348079, 1348081, 1378368, 2329134, 2579079]