a1c69079b7b57db91458371d8367d55b7b016c79
max
  Fri Apr 21 07:12:04 2023 -0700
#Preview2 week - bugs introduced now will need a build patch to fix
fixing mysql tables after gbic run, reported by Lon, no redmine

diff --git src/product/installer/browserSetup.sh src/product/installer/browserSetup.sh
index 5fc5ca5..242fd2a 100644
--- src/product/installer/browserSetup.sh
+++ src/product/installer/browserSetup.sh
@@ -1617,30 +1617,32 @@
 
     echo2 Downloading hgFixed.refLink, required for all RefSeq tracks
     $RSYNC --progress -avp $RSYNCOPTS $HGDOWNLOAD::mysql/hgFixed/refLink.* $MYSQLDIR/hgFixed/ 
     chown -R $MYSQLUSER:$MYSQLUSER $MYSQLDIR/hgFixed
 
     # download /gbdb files
     for db in $DBS; do
        echo2 Downloading $GBDBDIR files for assembly $db
        mkdir -p $GBDBDIR
        $RSYNC --progress -avp $RSYNCOPTS $HGDOWNLOAD::gbdb/$db/ $GBDBDIR/$db/
        chown -R $APACHEUSER:$APACHEUSER $GBDBDIR/$db
     done
 
     set +f
 
+    mysqlCheck
+
     goOffline # modify hg.conf and remove all statements that use the UCSC download server
 
     echo2
     echo2 Install complete. You should now be able to point your web browser to this machine
     echo2 and use your UCSC Genome Browser mirror.
     echo2
 
     showMyAddress
 
     echo2 If you have not downloaded the human hg38 assembly and you get an error message 
     echo2 'Could not connect to database' on the genome selection page, then modify 
     echo2 the hg.conf file and change the organism, e.g. to Mouse if you downloaded mouse.
     echo2 with a command like "'nano /usr/local/apache/cgi-bin/hg.conf'"
     echo2 Search for Human in this file and replace it with the organism of the 
     echo2 you downloaded.
@@ -1682,30 +1684,37 @@
     if [ -f /etc/init.d/mysql ]; then 
             service mysql start
     elif [ -f /etc/init.d/mysqld ]; then 
             service mysqld start
     elif [ -f /usr/lib/systemd/system/mariadb.service ]; then
             # RHEL 7, etc use systemd instead of SysV
             systemctl start mariadb
     elif [ -f /usr/lib/systemd/system/mysql.service ]; then
             # at least seen in Fedora 17
             systemctl start mysql
     else
         echo2 Could not find mysql nor mysqld file in /etc/init.d nor a systemd command. Please email genome-mirror@soe.ucsc.edu.
     fi
 }
 
+function mysqlCheck
+# check all mysql tables. Rarely, some of them are in an unclosed state on the download server, this command will close them
+{
+    echo2 Checking all mysql tables after the download to make sure that they are closed
+    mysqlcheck --all-databases --auto-repair --quick --fast --silent
+}
+
 # only download a set of minimal mysql tables, to make a genome browser that is using the mysql failover mechanism
 # faster. This should be fast enough in the US West Coast area and maybe even on the East Coast.
 function downloadMinimal
 {
     DBS=$*
     if [ "$DBS" == "" ] ; then
         echo2 Argument error: the '"minimal"' command requires at least one assembly name, like hg19 or mm10.
         exit 100
     fi
 
     echo2
     echo2 Downloading minimal tables for databases $DBS 
 
     # only these db tables are copied over by default
     minRsyncOpt="--include=cytoBand.* --include=chromInfo.* --include=cytoBandIdeo.* --include=kgColor.* --include=knownAttrs.* --include=knownGene.* --include=knownToTag.* --include=kgXref.* --include=ensemblLift.* --include=ucscToEnsembl.* --include=wgEncodeRegTfbsCells.* --include=encRegTfbsClusteredSources.* --include=tableList.* --include=refSeqStatus.* --include=wgEncodeRegTfbsCellsV3.* --include=extFile.* --include=trackDb.* --include=grp.* --include=ucscRetroInfo5.* --include=refLink.* --include=ucscRetroSeq5.* --include=ensemblLift.* --include=knownCanonical.* --include=gbExtFile.* --include=flyBase2004Xref --include=hgFindSpec.* --include=ncbiRefSeq*"
@@ -1731,30 +1740,32 @@
 
     startMysql
 
     echo2 Hiding some tracks by default and removing some tracks from searches
     for db in $DBS; do
        echo $db
        for track in $hideTracks; do
             mysql $db -e 'UPDATE trackDb set visibility=0 WHERE tableName="'$track'"'
         done
 
        for track in $notSearchTables; do
             mysql $db -e 'DELETE from hgFindSpec WHERE searchTable="'$track'"'
         done
     done
 
+    mysqlCheck
+
     echo2 
     echo2 The mirror should be functional now. It contains some basic assembly tables 
     echo2 and will download missing data from the UCSC servers. This requires
     echo2 two open ports, outgoing, TCP, from this machine:
     echo2 - to genome-mysql.soe.ucsc.edu, port 3306, to load MySQL tables
     echo2 - to hgdownload.soe.ucsc.edu, port 80, to download non-MySQL data files
     echo2 - or the above two servers European counterparts:
     echo2   genome-euro-mysql.soe.ucsc.edu and hgdownload-euro.soe.ucsc.edu
     echo2
     showMyAddress
     goOnline
 }
 
 function checkDownloadUdr () 
 {