Changeset 19198 for trunk/DataCheck


Ignore:
Timestamp:
08/31/18 17:16:24 (6 years ago)
Author:
Daniela Dorner
Message:
fixed bug in joins, simplified mysql-setup
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataCheck/Sourcefile.sh

    r18784 r19198  
    173173}
    174174
    175 # get the db-setup from the sql.rc
    176 function getdbsetup()
    177 {
    178    db=`grep Database $sqlrc | grep -v '#' | sed -e 's/Database: //' -e 's/ //g'`
    179    pw="--password="`grep Password $sqlrc | grep -v '#' | sed -e 's/Password: //' -e 's/ //g'`
    180    us=`grep User $sqlrc | grep -v '#' | sed -e 's/User: //' -e 's/ //g'`
    181    ho=`grep URL $sqlrc | grep -v '#' | sed -e 's/ //g' -e 's/URL:mysql:\/\///'`
    182    if [ "$sqlpw" != "" ]
    183    then
    184       sqlpwfile="--defaults-file=$sqlpw"
    185       pw=""
    186    fi
    187 #   echo "setup: "
    188 #   echo " db: "$db
    189 #   echo " pw: "$pw
    190 #   echo " us: "$us
    191 #   echo " ho: "$ho
    192 }
    193 
    194175# function to send a mysql query
    195176function sendquery()
    196177{
    197    getdbsetup
     178   #getdbsetup
    198179   printprocesslog "DEBUG sendquery QUERY: "$query
    199    val=`mysql $sqlpwfile -s -u $us $pw --host=$ho $db -e " $query " 2>&1`
     180   val=`mysql --defaults-file=$sqlrc -s -e " $query " 2>&1`
    200181   checkmysql=`echo $?`
    201182   if [ $checkmysql -gt 0 ]
    202183   then
    203       printprocesslog "ERROR could not query DB "$db" on host "$ho" with user "$us" (program: $program, function sendquery) "
     184      printprocesslog "ERROR could not query DB (program: $program, function sendquery, mysqlsetup $sqlrc) "
    204185      printprocesslog "MYSQLERROR [returncode: "$checkmysql"] "$val
    205186      error=`echo $val | grep -E -o 'ERROR [1-9]{1,4}' | grep -E -o '[1-9]{1,4}'`
    206187      # here possible reaction to mysql error
    207       if [ $error -eq 1213 ]
     188      if [ $error -eq 1213 ] || [ $error -eq 1205 ]
    208189      then
    209          printprocesslog "WARN Deadlock found. Should resend query."
     190         #printprocesslog "WARN Deadlock found. Should resend query."
    210191         printprocesslog "DEBUG sendquery QUERY: [2nd try] "$query
    211          val=`mysql $sqlpwfile -s -u $us $pw --host=$ho $db -e " $query " 2>&1`
     192         val=`mysql --defaults-file=$sqlrc -s -e " $query " 2>&1`
    212193         checkmysql2=`echo $?`
    213194         if [ $checkmysql2 -gt 0 ]
    214195         then
    215             printprocesslog "ERROR could not query DB "$db" on host "$ho" with user "$us" (program: $program, function sendquery) [2nd try]"
     196            printprocesslog "ERROR could not query DB (program: $program, function sendquery, mysqlsetup $sqlrc) [2nd try]"
    216197            printprocesslog "MYSQLERROR [returncode: "$checkmysql"] "$val" [2nd try]"
    217198            error2=`echo $val | grep -E -o 'ERROR [1-9]{1,4}' | grep -E -o '[1-9]{1,4}'`
     
    233214      if [ "$warning" != "" ]
    234215      then
    235          printprocesslog "WARN possible problem to query DB "$db" on host "$ho" with user "$us" (program: $program, function sendquery) "
     216         printprocesslog "WARN possible problem to query DB (program: $program, function sendquery, mysqlsetup $sqlrc) "
    236217         printprocesslog "MYSQLWARN [returncode: "$checkmysql"] "$val
    237218         val=
     
    256237function getstepinfo()
    257238{
    258    getdbsetup
     239   #getdbsetup
    259240   needs=( `getfromsetup $step "Needs"` )
    260241   noderestricted=`getfromsetup $step "NodeRestricted"`
     
    283264   for otherstep in ${othersteps[@]}
    284265   do
     266      #printprocesslog "DEBUG "$otherstep
    285267      if ! [ "$otherstep" = "$maintable" ]
    286268      then
    287          query=$query" LEFT JOIN "$otherstep"Status USING("`getfromsetup $otherstep "Primaries"`") "
     269         # joins for needed steps
     270         if [ "$1" = "get" ]
     271         then
     272            query=$query" LEFT JOIN "$otherstep"Status USING("`getfromsetup $otherstep "Primaries"`") "
     273         fi
     274         # joins for influenced steps
     275         if [ "$1" = "set" ]
     276         then
     277            query=$query" "`getfromsetup $otherstep "SpecialJoin2"`
     278            query=$query" LEFT JOIN "$otherstep"Status USING("`getfromsetup $otherstep "Primaries"`") "
     279         fi
    288280      fi
    289281   done
     
    297289   query=$query" FROM "
    298290   othersteps=${needs[@]}
    299    getalljoins
     291   getalljoins "get"
    300292   # add condition
    301293   query=$query" WHERE "
     
    392384   # execute query
    393385   #numproc=`sendquery `#cannot be done with sendquery, because of row counting
    394    if ! numproc=`mysql $sqlpwfile -s -u $us $pw --host=$ho $db -e " $query " | wc -l`
    395    then
    396       printprocesslog "ERROR could not query number of processes from db (program: $program, function getstatus)"
    397       echo `date +%F\ %T`" ERROR could not query number of processes from db (program: $program, function getstatus)"
     386   printprocesslog "DEBUG send query "$query
     387   if ! numproc=`mysql --default-file=$sqlrc -s -e " $query " | wc -l`
     388   then
     389      printprocesslog "ERROR could not query number of processes from db (program: $program, function getstatus, mysqlsetup $sqlrc)"
     390      echo `date +%F\ %T`" ERROR could not query number of processes from db (program: $program, function getstatus, mysqlsetup $sqlrc)"
    398391      continue
    399392   fi
     
    429422               ;;
    430423       stop)   case $check in
    431                   ok)  printprocesslog "DEBUB setstatus stop - ok"
     424                  ok)  printprocesslog "DEBUG setstatus stop - ok"
    432425                       starttime=noreset
    433426                       stoptime="Now()"
     
    470463   # get query
    471464   query=" UPDATE "
    472    getalljoins
     465   getalljoins "set"
    473466   # set the status values according to the new status of the step
    474467   query=$query" SET "
     
    668661               printprocesslog "ERROR "$1" not found."
    669662            else
    670                printprocesslog "WARN "$1" not found."
     663               printprocesslog "WARN "$1" not found. ("$filenight" - "$checknight")"
    671664            fi
    672665         else
     
    675668            if [ $filenight -le $checknight ]
    676669            then
    677                printprocesslog "WARN "$1" not found."
     670               printprocesslog "WARN "$1" not found. ("$filenight" - "$checknight")"
    678671            else
    679672               printprocesslog "INFO "$1" not found."
Note: See TracChangeset for help on using the changeset viewer.