Hi, what is the `create commit record` API used fo...
# help
u
Hi, what is the
create commit record
API used for? Can I use it to add metadata to an existing commit?
a
Hi @薛宇豪, lakeFS follows the Git model: commits are immutable -- it is literally not possible to change commits. This is an internal "plumbing" API. • "_Internal_" means that the lakeFS API compatibility guarantees do not apply, and this API can change. It will be hard to give a stable API that does this, for instance new internal fields may be added to commits. I would recommend discussing with us if you have specific needs. (Of course it is fine to use this API for experimentation - we just cannot guarantee that it will remain and will not change in future 1.x versions). Using it involves understanding the lakeFS data model - and you will get less support for your use here on #C016726JLJW. • "_Plumbing_" means it is not a complete use feature. So (assuming you have decided to use an internal API) you could use this API to modify metadata at branch head: ◦ create a new commit record with the same metarange ID and your new desired metadata ◦ checkout a temporary hidden new branch at the old branch head to prevent the metarange from being garbage-collected. ◦ hard-reset the branch head to the newly-created commit record ◦ delete that temporary hidden branch - you no longer need it. • You could even modify a commit behind the branch head, by creating successive commit records after the modified commit. Basically you would be implementing the equivalent of
git reset --interactive
at this point. I hope I've convinced you it is possible, but hard to code and ensure it keeps on working.
u
@Ariel Shaqed (Scolnicov) Thank you very much for your detailed explanation! I hope to modify the commit metadata, mainly to record the last access time (roughly, for example, once every hour)
However, it seems that this interface cannot do this.
a
Commits are - by nature - immutable. This gives them their power. So they might not be suitable for what you're trying to do. If I had to do something like this, I would store the mutable information in an external database, indexed by commit ID.
👍 1