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

Automatically prune history of a document #1121

Closed
fflorent opened this issue Jul 24, 2024 · 6 comments · Fixed by #1262
Closed

Automatically prune history of a document #1121

fflorent opened this issue Jul 24, 2024 · 6 comments · Fixed by #1262
Labels
enhancement New feature or request gouv.fr

Comments

@fflorent
Copy link
Collaborator

fflorent commented Jul 24, 2024

History actions are mostly useful when displayed through the UI, otherwise even for much advanced users, it can be very difficult to consult and have a clear vision of the actions that have been done.

Also these actions can dramatically increase the size of the document.

Because of that, we tend to think it would make sense to regularly prune the oldest ones. The documents snapshots would help find older history in most cases. What do you think?

@fflorent
Copy link
Collaborator Author

fflorent commented Jul 24, 2024

Functional considerations:

I have several questions in mind if that what we would like to do:

  • should we let the admin configure that? should a value of 0 be valid and tell we don't want action history at all?
  • how many actions do we want to keep by default?
  • do we want to prune history actions per table or per document? the latest option seems much simpler, the first one maybe more user-friendly

Technical considerations:

@paulfitz
Copy link
Member

Hi @fflorent, there is some existing auto-pruning logic:

// History will from time to time be pruned back to within these limits
// on rows and the maximum total number of bytes in the "body" column.
// Pruning is done when the history has grown above these limits, to
// the specified factor.
const ACTION_HISTORY_MAX_ROWS = 1000;
const ACTION_HISTORY_MAX_BYTES = 1000 * 1000 * 1000; // 1 GB.
const ACTION_HISTORY_GRACE_FACTOR = 1.25; // allow growth to 1250 rows / 1.25 GB.
const ACTION_HISTORY_CHECK_PERIOD = 10; // number of actions between size checks.

Making it configurable would be easy and desirable.

Pruning to 0 would currently leave the document unusable, since in there is currently no way to work with a document with a null "current last action". I'm sure this could be overcome. An alternative could be to add an empty action and then prune everything before it.

Pruning history actions per table would be a significant project, since it would require rewriting history, not just removing it.

One reason not to prune much history: I don't know if you use the functionality for working-on-a-copy, making-edits, then replacing-original? Any feature like this relies on versions of a Grist document being comparable in the 3-way sense needed for version control (meaning that the common ancestor of the versions is known). Once you prune history, documents that diverged before the beginning of that history become incomparable in the version control sense - you can see changes, but there's no way to know if they were e.g. removals on one side or additions on the other.

An idea that rattles around from time to time is external storage of history.

@paulfitz
Copy link
Member

External storage of history is attractive since documents could retain hashes of history items - these already exist - and only consult their actual content when needed, such as for version comparison. There could be a shared mechanism with external attachments. But this is a relatively large change.

@fflorent
Copy link
Collaborator Author

Thanks @paulfitz! I understand that it should be quite easy to let the admin configure the history, but we should advise (or force) them to have a minimal size for the feature you mention (and at least have at least one history action in the document if that's what they really want).

External storage of history is attractive since documents could retain hashes of history items - these already exist - and only consult their actual content when needed, such as for version comparison. There could be a shared mechanism with external attachments. But this is a relatively large change.

I created this issue to track the idea

@vviers
Copy link
Collaborator

vviers commented Oct 10, 2024

Nice-to-have : automatically and retroactively prune document history in snapshots as well once ACTION_HISTORY_MAX_ROWS and ACTION_HISTORY_MAX_BYTES are configured

@fflorent
Copy link
Collaborator Author

We will only implement solution in #1262, which is enough for our own use case.

@github-project-automation github-project-automation bot moved this from Needs feedback to Done in French administration Board Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gouv.fr
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants