dolt icon indicating copy to clipboard operation
dolt copied to clipboard

Error starting sql-server: `invalid ref format: refs/heads/` when encountering a database with no main branch.

Open timsehn opened this issue 3 years ago • 4 comments

$ ls -al         
total 24
drwxr-xr-x  21 timsehn  staff   672 Dec 13 08:45 .
drwxr-xr-x   5 timsehn  staff   160 Nov  4 11:13 ..
-rw-r--r--@  1 timsehn  staff  8196 Oct  5 11:29 .DS_Store
drwxr-xr-x   6 timsehn  staff   192 Sep 29 11:23 fiction
drwxr-xr-x   3 timsehn  staff    96 Sep 20 13:23 new_format
drwxr-xr-x   5 timsehn  staff   160 Sep 20 16:23 parquet
drwxr-xr-x   5 timsehn  staff   160 Nov 30 16:09 paylesshealth
drwxr-xr-x   3 timsehn  staff    96 Sep 28 10:00 repro_multikey_dupes
drwxr-xr-x   4 timsehn  staff   128 Dec  8 14:19 soft_deletes
drwxr-xr-x   4 timsehn  staff   128 Nov 14 12:12 test-dashes
drwxr-xr-x   3 timsehn  staff    96 Dec  6 14:50 test-hashes-1
drwxr-xr-x   3 timsehn  staff    96 Dec  6 14:47 test-hashes-2
drwxr-xr-x   4 timsehn  staff   128 Dec  7 10:59 test-working-set-in-server
drwxr-xr-x   4 timsehn  staff   128 Nov  9 17:43 test_branch_control
drwxr-xr-x   6 timsehn  staff   192 Oct 10 16:39 test_crystal
drwxr-xr-x   3 timsehn  staff    96 Oct 13 09:34 test_json_defaults
drwxr-xr-x   3 timsehn  staff    96 Oct 11 11:47 test_remotes_table
drwxr-xr-x   3 timsehn  staff    96 Oct 13 15:05 test_table_view
drwxr-xr-x   3 timsehn  staff    96 Oct  4 12:15 test_trigger_replace
drwxr-xr-x   3 timsehn  staff    96 Oct 17 15:07 test_update_cte
drwxr-xr-x   3 timsehn  staff    96 Oct 28 12:21 testdb
$ dolt sql-server
Starting server with Config HP="localhost:3306"|T="28800000"|R="false"|L="info"|S="/tmp/mysql.sock"
invalid ref format: refs/heads/

I have a bunch of databases in a directory that I've made over multiple versions. I can't start the sql-server.

timsehn avatar Dec 13 '22 16:12 timsehn

It's something in the test_ repos

$ mv test-* ../dolt-again 
$ dolt sql-server        
Starting server with Config HP="localhost:3306"|T="28800000"|R="false"|L="info"|S="/tmp/mysql.sock"
invalid ref format: refs/heads/
$ ls
fiction			paylesshealth		test_branch_control	test_remotes_table	test_update_cte
new_format		repro_multikey_dupes	test_crystal		test_table_view		testdb
parquet			soft_deletes		test_json_defaults	test_trigger_replace
$ mv test* ../dolt-again 
$ dolt sql-server       
Starting server with Config HP="localhost:3306"|T="28800000"|R="false"|L="info"|S="/tmp/mysql.sock"

timsehn avatar Dec 13 '22 17:12 timsehn

Found it:

$ cd testdb 
$ ls
$ ls -al
total 0
drwxr-xr-x   3 timsehn  staff   96 Oct 28 12:21 .
drwxr-xr-x  15 timsehn  staff  480 Dec 13 09:02 ..
drwxr-xr-x   6 timsehn  staff  192 Oct 28 11:41 .dolt
$ dolt sql-server
Starting server with Config HP="localhost:3306"|T="28800000"|R="false"|L="info"|S="/tmp/mysql.sock"
invalid ref format: refs/heads/

timsehn avatar Dec 13 '22 17:12 timsehn

Looks like this is a repo where I deleted the main branch:

$ dolt branch
  to_keep

timsehn avatar Dec 13 '22 17:12 timsehn

We should at least tell you the database where the error is happening.

timsehn avatar Dec 13 '22 17:12 timsehn

Jennifer and I have been working on repro'ing this one. I wasn't able to repro by deleting the main branch, nor by deleting main and then editing .dolt/repo_state.json to still refer to main.

but... I was able to repro the exact error message if I manually edited .dolt/repo_state.json to set head to "refs/heads/". I bet if you look in your .dolt dir for that db, you'll see the same, invalid metadata.

We're still not sure how we got into that state yet, but we'll poke around a little bit more to see if we can come up with anything.

Since we are able to repro the error condition though, we can look into adding a better error message that at least tells you which database has the issue.

fulghum avatar Feb 02 '23 23:02 fulghum