/[wait]/trunk/script/wait_admin
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/script/wait_admin

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 100 by dpavlin, Thu May 27 22:04:30 2004 UTC revision 101 by dpavlin, Sun May 30 12:49:46 2004 UTC
# Line 56  try to recover from following cases: Line 56  try to recover from following cases:
56    
57  =item * out of sync catalog and meta file data  =item * out of sync catalog and meta file data
58    
59    =item * corrupted table data in catalog/meta (remove only!)
60    
61  =back  =back
62    
63  This will be done performing following steps:  This will be done performing following steps:
# Line 185  if ($meta = do $meta_file) { Line 187  if ($meta = do $meta_file) {
187  =item * compare content of meta and catalog files  =item * compare content of meta and catalog files
188    
189  Data might differ, depending on ordering of variables in Storable and  Data might differ, depending on ordering of variables in Storable and
190  Data::Dumper structures and ability to store structure correctly (it seems that there is always difference in one variable).  Data::Dumper structures and ability to store structure correctly (it seems that there is always difference in 'attr' variable). If you select
191    B<-verbose> flag, you will also see diff between catalog and meta file, so
192    you can decide do you want to re-sync them or not.
193    
194  If differences are found, you will be offered to select master copy (catalog  If differences are found, you will be offered to select master copy (catalog
195  or meta). You can also accept default none which will skip synchronization  or meta). You can also accept default none which will skip synchronization
# Line 291  and testing for table directories. Line 295  and testing for table directories.
295    
296  =cut  =cut
297    
298    sub remove_table {
299            my $t = shift;
300    
301            if (do_fix("Do you want to remove table '$t' from database?")) {
302                    delete $catalog->{'tables'}->{$t} || warn "can't delete table $t from catalog!";
303                    $cc++;
304                    log_info("table '$t' removed from database $OPT{database}");
305            }
306    }
307    
308  my @tables = keys %{$c->{'tables'}};  my @tables = keys %{$c->{'tables'}};
309  @tables = qw/$OPT{table}/ if ($OPT{table});  @tables = qw/$OPT{table}/ if ($OPT{table});
310    
311  foreach my $t (@tables) {  foreach my $t (@tables) {
312          log_info "checking table '$t'";          log_info "checking table '$t'";
313            if (! $c->{'tables'}->{$t}) {
314                    log_warning("table $t key exists, but no data!");
315                    remove_table($t);
316                    next;
317            }
318          my $tc = blessed $c->{'tables'}->{$t};          my $tc = blessed $c->{'tables'}->{$t};
319          if ($tc) {          if ($tc) {
320                  if ($tc eq "WAIT::Table") {                  if ($tc eq "WAIT::Table") {
# Line 305  foreach my $t (@tables) { Line 324  foreach my $t (@tables) {
324                                  log_info("table directory exists");                                  log_info("table directory exists");
325                          } else {                          } else {
326                                  log_error("can't find directory for table '$t', it should be '$db_dir/$t'");                                  log_error("can't find directory for table '$t', it should be '$db_dir/$t'");
327                                  if (do_fix("Do you want to remove table '$t' from database?")) {                                  remove_table($t);
                                         delete $catalog->{'tables'}->{$t} || die "can't delete table $t from catalog!";  
                                         $cc++;  
                                         log_info("table '$t' removed from database $OPT{database}");  
                                 }  
328                          }                          }
329    
330                  } else {                  } else {
331                          log_error("table '$t' should be blessed to WAIT::Table and not to $tc!");                          log_error("table '$t' should be blessed to WAIT::Table and not to $tc!");
332                            remove_table($t);
333                  }                  }
334          } else {          } else {
335                  log_error("table '$t' isn't blessed");                  log_error("table '$t' isn't blessed");
336                    remove_table($t);
337          }          }
338  }  }
339    

Legend:
Removed from v.100  
changed lines
  Added in v.101

  ViewVC Help
Powered by ViewVC 1.1.26