Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Dolt reflog support #6882

Merged
merged 29 commits into from
Nov 2, 2023
Merged

Feature: Dolt reflog support #6882

merged 29 commits into from
Nov 2, 2023

Conversation

fulghum
Copy link
Contributor

@fulghum fulghum commented Oct 25, 2023

A new dolt_reflog() table function allows you to query Dolt's chunk journal to view the history of named refs, such as branches and tags.

Usage Example:

> select * from dolt_reflog('branch1');
+--------------------+---------------------+----------------------------------+-------------------------------+
| ref                | ref_timestamp       | commit_hash                      | commit_message                |
+--------------------+---------------------+----------------------------------+-------------------------------+
| refs/heads/branch1 | 2023-10-25 20:54:37 | v531ptpmv2tquig8v591tsjghtj84ksg | inserting row 42              |
| refs/heads/branch1 | 2023-10-25 20:53:12 | rvt34lqrbtdr3dhnjchruu73lik4e398 | inserting row 100000          |
| refs/heads/branch1 | 2023-10-25 20:53:06 | v531ptpmv2tquig8v591tsjghtj84ksg | inserting row 42              |
| refs/heads/branch1 | 2023-10-25 20:52:43 | ihuj1l7fmqq37sjhtlrgpup5n76gfhju | inserting row 1 into table xy |
+--------------------+---------------------+----------------------------------+-------------------------------+
4 rows in set (0.00 sec)

Documentation: dolthub/docs#1815

Compatibility:
This change needs to be released as a minor version bump because it changes the chunk journal record format for root hash records to include a timestamp field. Older versions of Dolt's chunk journal reader aren't forward compatible to read this new format (but the chunk journal reader is backwards compatible to still read older journals). If a customer needs to downgrade after using a version with this support, they can stop their sql-server, run dolt gc to move the chunk journal content into oldgen, delete the chunk journal file if necessary (it should be removed automatically by dolt gc), and then restart their sql-server with an older Dolt version.

Future Extensions:

  • root author – I started looking at recording the SQL user who created the new root value, but was hesitant to put too much data into the chunk journal records. This does seem like useful information to track though, so I'm still thinking about whether this is worth adding now or later.
  • reflog rows for deletion – Currently, dolt_reflog() results show when a ref is changed to a new value, but there is not a row in the result set marking when the ref is deleted. This would be shown as a NULL commit_hash and commit_message. Combining this with the point above would allow the reflog to show who deleted a ref.
  • show all refs – The current implementation requires a ref name and filters results on that ref. We should allow viewing the full reflog without filtering on a ref.

@fulghum fulghum marked this pull request as ready for review October 30, 2023 23:56
@fulghum fulghum requested a review from zachmu October 30, 2023 23:56
Copy link
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good, just a couple comments

go/store/nbs/journal.go Outdated Show resolved Hide resolved
go/store/nbs/journal.go Outdated Show resolved Hide resolved
go/libraries/doltcore/sqle/reflog_table_function.go Outdated Show resolved Hide resolved
@fulghum fulghum merged commit b641a45 into main Nov 2, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants