dolt icon indicating copy to clipboard operation
dolt copied to clipboard

`dolt gc` does not always clean up orphaned commits

Open timsehn opened this issue 1 year ago • 2 comments

gc-repro $ dolt init --new-format
Successfully initialized dolt data repository.
gc-repro $ dolt sql -q "create table t (c1 int)"
gc-repro $ dolt add .
gc-repro $ dolt commit -am "added table"
commit 1s93ahl572rhr3i4ho1qg5pt5pjsevun (HEAD -> main) 
Author: Tim Sehn <[email protected]>
Date:  Mon Sep 12 14:26:08 -0700 2022

        added table

gc-repro $ dolt sql -q "insert into t values (0)"
Query OK, 1 row affected
gc-repro $ dolt commit -am "added 0"
commit t69pvj6aanuveil8pr6egsr6mhgpuhpg (HEAD -> main) 
Author: Tim Sehn <[email protected]>
Date:  Mon Sep 12 14:26:37 -0700 2022

        added 0

gc-repro $ dolt sql -q "insert into t values (1)"
Query OK, 1 row affected
gc-repro $ dolt commit -am "added 1"
commit m1eh99sdsvdb337eti1img391e3esmce (HEAD -> main) 
Author: Tim Sehn <[email protected]>
Date:  Mon Sep 12 14:26:44 -0700 2022

        added 1

gc-repro $ dolt reset --hard t69pvj6aanuveil8pr6egsr6mhgpuhpg
gc-repro $ dolt gc
gc-repro $ dolt reset --hard m1eh99sdsvdb337eti1img391e3esmce
error: Failed to reset changes.
cause: target commit not found

This works but I have had other cases where I could still reset to orphaned commits after gc.

rollback $ dolt reset --hard 3ahdn16ocju6mv11ktmgjf8h6id212q9
rollback $ dolt gc
rollback $ dolt sql -q "select * from people"
+----+------------+-----------+--------------------+
| id | first_name | last_name | state_of_residence |
+----+------------+-----------+--------------------+
| 0  | Tim        | Sehn      | California         |
| 1  | Aaron      | Son       | California         |
| 2  | Brian      | Hendriks  | California         |
+----+------------+-----------+--------------------+
rollback $ dolt reset --hard qbhdlidekbpkuji28t209mbgr8mk49r9
rollback $ dolt sql -q "select * from people"
+----+------------+------------+--------------------+
| id | first_name | last_name  | state_of_residence |
+----+------------+------------+--------------------+
| 0  | Tim        | Sehn       | California         |
| 1  | Aaron      | Son        | California         |
| 2  | Brian      | Hendriks   | California         |
| 3  | Zach       | Musgrave   | Washington         |
| 4  | Jason      | Fulghum    | Washington         |
| 5  | Brian      | Fitzgerald | Pennsylvania       |
| 6  | Alec       | Stein      | New York           |
+----+------------+------------+--------------------+

qbhd is after 3ahd in this case as they are all inserts.

timsehn avatar Sep 12 '22 21:09 timsehn

One reason that I can think of for why a commit would not be gc'd, are merge conflicts. Do you have any merge conflicts?

druvv avatar Sep 12 '22 21:09 druvv

One reason that I can think of for why a commit would not be gc'd, are merge conflicts. Do you have any merge conflicts?

No. Definitely not. No branches or merges. Just lots of resets and reverts and things.

timsehn avatar Sep 12 '22 22:09 timsehn