gitbucket icon indicating copy to clipboard operation
gitbucket copied to clipboard

Migration from H2 to MariaDB: SQLSyntaxErrorException: (conn:72) Query was empty

Open uli-heller opened this issue 8 years ago • 4 comments
trafficstars

Issue

Impacted version: 4.16.0 (and probably others before as well)

Deployment mode: standalone app with an http frontend (httpd)

Problem description:

When upgrading to 4.16.0, I decided to migrate from H2 to MariaDB. The migration was quite simple. I followed the instructions on the wiki page. Unfortunately, I was not able to import the exported data via the admin gui interface. I got the error "SQLSyntaxErrorException: (conn:72) Query was empty" within the log file and on the browser.

Importing the data via command line works perfecty, i.e.

  • mysql -u{user} -p{password} gitbucket </tmp/gitbucket-export-143901791709498677.sql

uli-heller avatar Sep 02 '17 16:09 uli-heller

@uli-heller Hmm... Could you find a failed query?

takezoe avatar Sep 13 '17 07:09 takezoe

I experienced this same error today in 4.33. The cause was an empty line in the exported SQL.

  • Starting from the built-in H2 instance with a fresh install, I added a project and a couple of test issues. No 3rd party plugins were installed.
  • Went to the admin settings and exported ALL tables
  • The resulting export had an empty line at the end of the SQL file.
  • Restart Gitbucket with it running against MySql
  • Import the SQL file and the import fails with "Query was empty" error message
  • Edit SQL file, remove empty line at the end.
  • Re-run import and it works without issue.

Hope this helps other people that may have run up against this issue.

solsticesurfer avatar Jan 29 '21 21:01 solsticesurfer

Tried to submit a PR to resolve this but it fails with (Compile / scalafmtCheck) 1 files must be formatted. Code appears formatted correctly, it was just a simple if/then check. Haven't found the formatting rules for this project so ¯\_ (ツ)_/¯

For reference: https://github.com/gitbucket/gitbucket/pull/2664

solsticesurfer avatar Jan 29 '21 22:01 solsticesurfer

@solsticesurfer Sorry for late response and thanks for sending a pull request! I was super busy at work last one week. 😭 Maybe we should identify the cause of empty SQL and remove it, but just skipping empty SQL is easier and effective to avoid unpredictable troubles like this. Could you just run sbt scalafmt to fix source code format?

takezoe avatar Feb 07 '21 14:02 takezoe

Closed as #2664 has been merged.

takezoe avatar Oct 22 '23 18:10 takezoe