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

General database deletion strategy #17

Open
io7m opened this issue Sep 24, 2023 · 4 comments
Open

General database deletion strategy #17

io7m opened this issue Sep 24, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request server Issues involving the server

Comments

@io7m
Copy link
Member

io7m commented Sep 24, 2023

Deletion of content should be undoable for a given duration.

Something like:

CREATE TABLE x (
  data integer not null,
  deleted timestamp with time zone
)

Reads on the table will not return any rows where deleted is non-null. The maintenance service will delete rows where deleted describes a time older than a configurable retention period. Undoing a deletion means setting deleted back to null.

How are foreign key constraints handled?

@io7m io7m added the enhancement New feature or request label Sep 24, 2023
@io7m io7m self-assigned this Sep 24, 2023
@io7m
Copy link
Member Author

io7m commented Sep 24, 2023

This is too complex and heavyweight in the general case. Deleting an entry from one table might entail deleting an entry from almost every other table...

db

@io7m
Copy link
Member Author

io7m commented Sep 24, 2023

Deleting a row from repositories will result in deleting from all of the following transitive dependencies:

  • repository_commits
  • repository_commit_tags
  • repository_commit_branches
  • archives
  • repository_commit_tags
  • assignments
  • assignment_executions
  • work_items
  • work_item_logs
  • assignment_execution_logs
  • repository_keys

io7m added a commit that referenced this issue Sep 24, 2023
Affects: #17
Affects: #6
io7m added a commit that referenced this issue Sep 24, 2023
Affects: #6
Affects: #17
io7m added a commit that referenced this issue Sep 25, 2023
@io7m
Copy link
Member Author

io7m commented Sep 25, 2023

This is going to be addressed case by case. Deleting an agent label, for example, will quietly cascade to a deletion of that label from all associated agents.

Deleting an assignment will quietly cascade to deleting all execution records associated with it.

Deleting a repository, on the other hand, won't cascade and won't be allowed until all of the associated assignments are deleted. There needs to be an API to return a list of the objects referring to a given repository.

@io7m
Copy link
Member Author

io7m commented Sep 25, 2023

In cases where there's a unique identifier that exists on other systems (like agent IDs), the object in question is marked as deleted and internal data is redacted, instead of actually deleting database rows. That prevents the re-use of the identifier whilst keeping the rest of the object effectively invisible.

io7m added a commit that referenced this issue Sep 25, 2023
io7m added a commit that referenced this issue Sep 29, 2023
io7m added a commit that referenced this issue Sep 29, 2023
Affects: #10
Affects: #17
Affects: #6
@io7m io7m added the server Issues involving the server label Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request server Issues involving the server
Projects
None yet
Development

No branches or pull requests

1 participant