studio icon indicating copy to clipboard operation
studio copied to clipboard

Database import from .sql file failes, but process keeps running in the background

Open countfak opened this issue 1 year ago • 2 comments

Quick summary

Hi, I wanted to share my experience with database import from a .sql file. I tried multiple times with different database sizes, last one was around 40MB. The import goes on for a while, then the import failed message appears. But the import process is still running in the background.

Steps to reproduce

Drop a large .sql file with the built-in import functionality of an existing site and start the import. It will likely fail, open up the Activity Monitor app and find the Studio process at the top with high CPU usage, meaning that the import is still running in the background. After a while the CPU usage of the process drops, and the import is actually finished.

What you expected to happen

I wasn't expecting to get the error message if the import process was still running in the background.

What actually happened

Got import failed message even if the import was still running, see above.

Impact

One

Available workarounds?

No but the app is still usable

Platform

Mac Silicon

Logs or notes

No response

countfak avatar Sep 17 '24 08:09 countfak

Thanks for reporting the issue @countfak . We will check it.

wojtekn avatar Sep 17 '24 12:09 wojtekn

Marking this as Triaged but let me know @wojtekn or @countfak if you have a large DB file I could use to test this.

Robertght avatar Oct 04 '24 15:10 Robertght

Just wanted to follow up on this and share my latest successful attempt.

What I tried and didn't work out:

  • import sql file via the built-in import functionality: this causes the issue explained above, not even sure the import finishes and is done correctly, it just takes a lot of time
  • import using all in one wp migration plugin with a .wpress file: this fails with error 400 bad request in the javascript console
  • import via command line with wp cli sqlite (https://github.com/Automattic/wp-cli-sqlite-command): this takes a lot of time too, I didn't wait for the import to finish, probably same as above

What worked for me was:

  • create new site in Studio
  • export sql file from the website that I want to import into Studio
  • replace the url in the database if needed
  • convert sql to sqlite with this: https://github.com/mysql2sqlite/mysql2sqlite
  • move the new database to /wp-content/database/.ht.sqlite (replace existing)

Please note that this only applies in case of large databases with a lot of entries (for reference mine was around 40MB), the built-in import works fine if I try with a smaller database.

countfak avatar Oct 25 '24 22:10 countfak

Thanks for sharing your workaround @countfak, it's useful. We will check how we can improve Studio Importer to support databases of any size.

wojtekn avatar Oct 29 '24 08:10 wojtekn

Hi @countfak and thank you for reporting the issue! In the upcoming Studio release, we have introduced the following:

  • the database import process should be terminated if it fails and it won't be running in the background (this could be tested with Activity Monitor once the new version of the app is released)
  • we also improved the import of larger .sql files and it should now be possible to import databases with a lot of entries

I am going to close this now as it addresses the issue reported. Once the new Studio release is out, would you be able to give it another test and let us know if the issue persists? Feel free to re-open if the issue still happens! 🙇

katinthehatsite avatar Dec 18 '24 19:12 katinthehatsite

Hi @countfak - we have just released a new version of Studio: https://github.com/Automattic/studio/releases Feel free to give it a try and let us know how it goes with the import.

katinthehatsite avatar Jan 03 '25 13:01 katinthehatsite

Hi guys,

I tried with a big database (120MB) and a smaller one (40MB) and after a while it failed both times with the following log:

[2025-01-16T14:01:50.377Z][info][main] Stopping server with ID f1c3b0e6-746d-4487-9b4e-39ccbb22f230
[2025-01-16T14:01:50.568Z][info][site-server-process] Server stopped
[2025-01-16T14:01:50.569Z][info][site-server-process] Stopped watching for file changes
[2025-01-16T14:06:50.375Z][erro][main] Warning during import of /var/folders/jb/st0wpzls6gvd7fq2_c21gvx40000gn/T/studio_backupOCSKay/migrated-wordpress.sql: wp-cli command canceled
[2025-01-16T14:06:50.382Z][erro][main] Error occurred in handler for 'importSite': Error: Database import failed
    at t.SQLImporter.<anonymous> (/Applications/Studio.app/Contents/Resources/app.asar/.webpack/main/index.js:2:2388245)
    at Generator.next (<anonymous>)
    at o (/Applications/Studio.app/Contents/Resources/app.asar/.webpack/main/index.js:2:2386946)

countfak avatar Jan 16 '25 14:01 countfak

Thanks for giving it a test @countfak - let's reopen the issue and keep on investigating

katinthehatsite avatar Jan 16 '25 14:01 katinthehatsite

I am unable to reproduce the issue. I tried with a couple of sql files, biggest one being 829M and as soon as import fails, Electron Helper process which was eating up the CPU also stops doing that.

ashfame avatar Jan 29 '25 10:01 ashfame

I am unable to reproduce the issue. I tried with a couple of sql files, biggest one being 829M and as soon as import fails, Electron Helper process which was eating up the CPU also stops doing that.

hi @ashfame please note that the process thing was reported by me on September 2024, new versions came out in the meanwhile, so it may not be that way anymore. in fact, I think I also checked and couldn't find the process still running after the import failed. that may have been fixed. still, the import fails, that's what I reported in my latest message here.

countfak avatar Jan 29 '25 10:01 countfak

Hi @countfak Yes, that's likely that stray process in background isn't an issue anymore. And import is currently failing on some zips due to a regression that I am looking into. But since your report is prior to that change, it's probably a different issue that I will come back to.

ashfame avatar Jan 29 '25 16:01 ashfame

Documenting the work I am doing in this regard:

  • Expose more info on when a wp-cli command fails
  • Big imports would also time out after 5mins, so I am currently testing a huge import with 24hr timeout

ashfame avatar Feb 04 '25 13:02 ashfame

I realized wp-cli command canceled only happens when the process times out. Anytime an actual error happens, it gets logged to the log file. And since the default timeout for waiting on wp-cli commands is just 5mins, that could be too small of a window for big imports.

So, as a first step which could perhaps be the solution as well, I have created #904 which allows higher timeouts for import/export.

ashfame avatar Feb 07 '25 08:02 ashfame

Hi @countfak Do you mind giving v1.3.4 a try to see if the issue is resolved for you, it has higher timeout limits for import/export?

ashfame avatar Feb 24 '25 17:02 ashfame