Home
%3CLINGO-SUB%20id%3D%22lingo-sub-846391%22%20slang%3D%22en-US%22%3ELesson%20Learned%20%23109%3A%20Issues%20exporting%20an%20Azure%20Database%20for%20MySQL%20database%20using%20mysqldump%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-846391%22%20slang%3D%22en-US%22%3E%3CP%3ERemember%20that%20mysqldump%20exports%20the%20data%20using%20SELECT%20command%20and%20all%20the%20rows%20needs%20to%20be%20read%20and%20export%20to%20the%20dump%20file.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt%20is%20key%20to%20review%20the%20CPU%2C%20Storage%20and%20Memory%20usage%20during%20the%20dumping%20process.%20In%20this%20case%2C%20I%20found%20that%20our%20customer%20reached%20the%20maximum%20capacity%20of%20Memory.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESome%20best%20practices%20and%20recomendations%20based%20on%20this%20troubleshooting%20process%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3ERun%20%3CA%20href%3D%22https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.7%2Fen%2Fmysqldump-sql-format.html%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Emysqldump%3C%2FA%3Ein%20the%20same%20region%20of%20the%20Azure%20Database%20for%20MySQL.%20It%20is%20very%20important%3A%3C%2FSPAN%3E%3CUL%3E%0A%3CLI%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3ETo%20save%20money%20because%20we%20could%20have%20some%20additional%20cost%20reaching%20the%20default%20limit%20downloading%20data%20from%20Azure%20to%20OnPremise%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3ETo%20reduce%20the%20networking%20latency.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3EIf%20possible%2C%20enable%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-network%2Fcreate-vm-accelerated-networking-cli%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Eaccelerated%20networking%3C%2FA%3Ein%20the%20computer%20that%20will%20run%20mysqldump.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3EReview%20if%20you%20have%20any%20table%20with%20a%20large%20number%20of%20rows%20or%20with%20blob%20fields.%20I%20suggested%20to%20run%20the%20following%20SQL%20Command%3A%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ESELECT%20*%20FROM%20information_schema.tables%20WHERE%20table_schema%20NOT%20IN%20('information_schema'%2C'mysql'%2C'performance_schema')%3C%2FSTRONG%3E.%20During%20the%20troubleshooting%20steps%20we%20found%20that%20during%20the%20mysqldump%20execution%20the%20Azure%20Database%20for%20MySQL%20reached%20the%2080%25-90%25%20of%20the%20total%20memory%20of%20the%20instance.%20And%20it%20was%20needed%20to%20scale%20up%20the%20MySQL%20Instance%20to%20a%20higher%20database%20tier%20to%20complete%20the%20execution%20of%20mysqldump%20process.%3C%2FLI%3E%0A%3CLI%3EInstead%20to%20export%20of%20the%20databases%20at%20the%20same%20time%2C%20%3CSTRONG%3Etry%20to%20export%20per%20database%20per%20mysqldump%20execution%20if%20needed.%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3EReduce%20to%20the%20%3CSTRONG%3Emaximum%20the%20limit%20active%20transactions%20in%20order%20to%20avoid%20many%3C%2FSTRONG%3Eblockings.%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3EInclude%20the%20following%20command%20line%2C%20%3CSTRONG%3Emysqldump%20--host%20servername.mysql.database.azure.com%20--user%20username%40servername%20-p%20%E2%80%93quick%20%E2%80%93compress%20--verbose%20--databases%20databasename%20%26gt%3B%20bkpdb.sql%3C%2FSTRONG%3E%2C%20with%20the%20following%20goal%2C%20based%20on%20the%20URL%3A%20%3CA%20href%3D%22https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.6%2Fen%2Fmysqldump.html%23mysqldump-performance%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.6%2Fen%2Fmysqldump.html%23mysqldump-performance%3C%2FA%3E%3A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EKnow%20what%20is%20the%20table%20and%20database%20that%20is%20exporting%20mysqldump%20and%20you%20have%20the%20issue.%3C%2FLI%3E%0A%3CLI%3ETo%20have%20a%20verbose%20about%20the%20lines%20to%20be%20executed.%3C%2FLI%3E%0A%3CLI%3ECompress%20the%20communication%20between%20server%20and%20client%3C%2FLI%3E%0A%3CLI%3EExport%20the%20data%20in%20quicker%20mode%3C%2FLI%3E%0A%3CLI%3EDuring%20my%20test%2C%20if%20you%20have%20any%20issue%20exporting%20column%20statistics%20details%20(you%20may%20have%20an%20error%20message)%2C%20please%2C%20add%20in%20the%20command%20line%20--column-statistics%3D0).%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEnjoy!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-846391%22%20slang%3D%22en-US%22%3E%3CP%3EToday%2C%20I%20worked%20on%20a%20service%20request%20that%20our%20customer%20was%20not%20able%20to%20dump%20the%20data%20using%20mysqldump%20and%20the%20process%20took%20too%20much%20time%20or%20reported%20a%20command%20timeout.%20During%20the%20troubleshooting%20process%20we've%20learned%20some%20lessons%20that%20I%20would%20like%20to%20share%20with%20you.%20Please%2C%20remember%20that%20Azure%20Database%20for%20MySQL%20has%20inbuilt%20the%20backup%20database%20and%20there%20is%20not%20needed%20to%20use%20mysqldump%20for%20a%20regular%20backup.%3C%2FP%3E%3C%2FLINGO-TEASER%3E

Remember that mysqldump exports the data using SELECT command and all the rows needs to be read and export to the dump file. 

 

It is key to review the CPU, Storage and Memory usage during the dumping process. In this case, I found that our customer reached the maximum capacity of Memory.

 

Some best practices and recomendations based on this troubleshooting process:

 

  • Run mysqldump in the same region of the Azure Database for MySQL. It is very important:
    • To save money because we could have some additional cost reaching the default limit downloading data from Azure to OnPremise
    • To reduce the networking latency.
  • If possible, enable the accelerated networking in the computer that will run mysqldump.
  • Review if you have any table with a large number of rows or with blob fields. I suggested to run the following SQL Command: SELECT * FROM information_schema.tables WHERE table_schema NOT IN ('information_schema','mysql','performance_schema'). During the troubleshooting steps we found that during the mysqldump execution the Azure Database for MySQL reached the 80%-90% of the total memory of the instance. And it was needed to scale up the MySQL Instance to a higher database tier to complete the execution of mysqldump process.
  • Instead to export of the databases at the same time, try to export per database per mysqldump execution if needed.
  • Reduce to the maximum the limit active transactions in order to avoid many blockings. 
  • Include the following command line, mysqldump --host servername.mysql.database.azure.com --user username@servername -p –quick –compress --verbose --databases databasename > bkpdb.sql, with the following goal, based on the URL: https://dev.mysql.com/doc/refman/5.6/en/mysqldump.html#mysqldump-performance :
      • Know what is the table and database that is exporting mysqldump and you have the issue.
      • To have a verbose about the lines to be executed.
      • Compress the communication between server and client
      • Export the data in quicker mode
      • During my test, if you have any issue exporting column statistics details (you may have an error message), please, add in the command line --column-statistics=0).

 

Enjoy!