From 1e36da22bf6669260d59582216abf75d00001516 Mon Sep 17 00:00:00 2001
From: Andrew Yates <ayates@ebi.ac.uk>
Date: Wed, 7 Aug 2013 15:52:16 +0000
Subject: [PATCH] [ENSCORESW-576]. Prevent optimisation of DBs when copying
 from staging.

The production and web teams have reported odd going ons when people copy from
staging onto another server. This is because this script optimises databases
before copying. These DBs should already be optimised so there is no need
to do this stage. In fact it can alter the checksums of the MYI files which
causes the webteam to wonder if data has been switched out without them knowing.
---
 misc-scripts/CopyDBoverServer.pl | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/misc-scripts/CopyDBoverServer.pl b/misc-scripts/CopyDBoverServer.pl
index f2a634cc9c..5d4ca95108 100755
--- a/misc-scripts/CopyDBoverServer.pl
+++ b/misc-scripts/CopyDBoverServer.pl
@@ -77,6 +77,11 @@ Command line switches:
                     index data onto disk.  This may be a time consuming
                     operation for very large tables.  The --noopt flag
                     disables the optimization.
+
+                    DO NOT RUN OPTIMIZE WHEN YOU ARE ON THE STAGING
+                    MACHINES. THESE ARE OPTIMIZED BY THE PRODUCTION
+                    TEAM DURING THE RELEASE CYCLE. ATTEMPTING TO DO
+                    THIS WILL CAUSE THE SCRIPT TO DIE.
   
   --notargetflush   (Optional)
                     Skips table flushing on the target machine.
@@ -432,6 +437,12 @@ while ( my $line = $in->getline() ) {
     $failed = 1;
   }
 
+  if(! $failed && $source_server =~ /^ens-staging\d+$/ && $opt_optimize) {
+    my $tmpl = q{line %d: Source server '%s' is an ens-staging machine. Do not optimize on this server. Rerun with -noopt};
+    warn(sprintf($tmpl, $lineno, $source_server));
+    $failed = 1;
+  }
+
   if ( !$failed ) {
     push( @todo, {
             'source_server'   => $source_server,
-- 
GitLab