Note keep-around attribution
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
This is part of phase 2 of the keep-around optimization/attribution roadmap.
Background
Currently when a note is created on a commit the commit is kept alive in git by creating a special ref called a keep-around. While this works, the problem with the current keep-around scheme is that these keep-arounds are not bound to the objects that create them, they can never be removed as it is impossible to tell what they were created for.
Keep-arounds requested per hour over two weeks
Keep-arounds created per hour over two weeks
Proposal
Note that this proposal excludes DiffNote as those are for merge requests which keep their own git references.
Since one commit can have many associated notes and since it is relatively easy to check if there are any notes associated with a commit ID. Here is the suggested scheme:
On create
Upsert a new ref based on the commit ID, refs/notes/<commit-id>
, where the ref points to the commit. This is essentially the same scheme as keep-around right now, the difference being that we know that these refs are created by notes.
On remove
Schedule a worker to remove the ref refs/notes/<commit-id>
. This worker will first query the DB to see if there are any notes associated with this commit ID. If there are none remove the ref, otherwise do nothing.
There is already an index on commit_id. So this check should be fast.
CREATE INDEX index_notes_on_commit_id ON notes USING btree (commit_id);
Hidden
This new ref namespace refs/notes/
should be made hidden in gitaly. This ensures that they do not cause too much performance degradation for the end user.
Metrics
Prometheus metrics should be collected both on creation and removal.