dolthub / dolthub/dolt

`dolt gc` does not always clean up orphaned commits

Open
#4,317 2 comments 0 reactions 0 assignees View on GitHub
bug cli
Dominant language
Go
Stars
24.4k
Forks
873
Avg merge
1d 5h
Merged PRs (30d)
108

Description

```
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
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
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
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.