Changeset 41048
- Timestamp:
- Nov 5, 2019, 8:07:53 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20191011/Nebulous/bin/neb-repair
r39926 r41048 45 45 ); 46 46 47 die "can't connect edto Nebulous Server: $server"47 die "can't connect to Nebulous Server: $server" 48 48 unless defined $neb; 49 49 50 50 my $stat = $neb->stat($key); 51 51 die "nebulous key: $key not found" unless $stat; 52 52 53 my $instances = $neb->find_instances($key, 'any'); 53 54 die "no instances found" unless $instances; … … 71 72 72 73 for (my $i = 0; $i <= $#files; $i++) { 74 # count existing files and get the MD5 sums 73 75 if (-e $files[$i]) { 74 76 $existance[$i] = 1; … … 89 91 push @{ $md5sum_valid{$md5sums[$i]} }, $files[$i]; 90 92 $last_f = $files[$i]; 91 } 92 else { 93 } else { 93 94 $existance[$i] = 0; 94 95 $md5sums[$i] = 'NON-EXISTANT'; … … 98 99 } 99 100 101 # check number of copies and number of unique MD5 sum values 100 102 my $N_mds = scalar(keys(%md5sum_uniq)); 101 103 my $N_files = scalar(@files); 104 105 # seems like we should not call neb-replicate until *after* we have 106 # removed 0-byte copies 102 107 if ($N_files < $user_copies) { 103 108 print "Insufficient copies ($N_files) of $key, replicating!\n"; 104 109 system("neb-replicate $key"); 105 110 } 111 106 112 if ($N_mds == 1) { 107 113 print "Nebulous key $key is consistent.\n"; 108 } 109 else { 114 } else { 110 115 my $valid_sum = ''; 111 116 my $valid_file = ''; 112 117 my $m; 113 118 foreach $m (keys %md5sum_valid) { 114 if (($m ne 'd41d8cd98f00b204e9800998ecf8427e') &&($m ne 'NON-EXISTANT')) {119 if (($m ne 'd41d8cd98f00b204e9800998ecf8427e') && ($m ne 'NON-EXISTANT')) { 115 120 if ($valid_sum ne '') { 116 121 die "Too many acceptable files for key $key\n"; … … 122 127 if ($valid_sum eq '') { 123 128 die "No acceptable file for key $key\n"; 124 } 125 else { 129 } else { 126 130 print "Repairing instances\n"; 127 131 foreach $m (keys %md5sum_valid) { … … 130 134 print "\tcp $valid_file $f\n"; 131 135 system("cp $valid_file $f"); 136 137 # if we failed to make a copy, the target ($f) could be inaccessible 132 138 if ($? >> 8 != 0) { 133 139 if ($existance[0] == 1) { 134 # We can fix this with culls and replications. 140 141 # The target is a valid file 0-byte file 142 # but we cannot replace it with the 143 # correct file. We can fix this with 144 # culls and replications. 145 135 146 print "Attempting to fix this.\n"; 136 147 print("neb-replicate $key\n"); 137 148 system("neb-replicate $key"); 138 149 if ($? >> 8 == 0) { 150 # if the neb-replicate succeeded, remove the bad copy with neb-cull 139 151 my $bad_volume = (split /\//, $f)[2]; 140 152 print("neb-cull --volume $bad_volume $key\n"); 141 153 system("neb-cull --volume $bad_volume $key"); 142 } 143 else { 154 } else { 144 155 die "Failed to copy file $valid_file to $f, and subsequent replication also failed!\n"; 145 156 } 146 } 147 else { 157 } else { 148 158 die "Failed to copy file $valid_file to $f!\n"; 149 159 } … … 187 197 =head1 DESCRIPTION 188 198 189 This program repairs instances and corrects instance counts for a nebulous key. 199 This program repairs instances and corrects instance counts for a nebulous key: 200 201 If some of the existing instances have the MD5 sum corresponding to a 202 0-byte file, but the rest have the same, non-zero byte md5sum, then 203 replace the 0-byte files with the non-zero byte version. 204 205 At the end, if the number of instances is less than the value of 206 user.copies, then additional copies are generated. 190 207 191 208 =head1 OPTIONS
Note:
See TracChangeset
for help on using the changeset viewer.
