-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: asynchronous garbage collector (#516)
Problem: deleting files from the STORE message handler causes latency in the message processing pipeline when deleting large files. Solution: delete files asynchronously. We now spawn a garbage collector task every 24 hours by default that will look at the list of files and delete files without pins. This PR also introduces the concept of grace period pins: files without a tx or message pin can now be pinned for an arbitrary amount of time. This applies to files uploaded by users in unauthenticated mode and to files deleted by FORGET messages. The default is to give 24 hours of grace period for files.
- Loading branch information
1 parent
0e4a3ea
commit 29139b1
Showing
16 changed files
with
456 additions
and
62 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
deployment/migrations/versions/0020_88a25ae08ebf_grace_period_file_pins.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"""grace period file pins | ||
Revision ID: 88a25ae08ebf | ||
Revises: 3bf484f2cc95 | ||
Create Date: 2023-11-02 22:43:40.223477 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "88a25ae08ebf" | ||
down_revision = "3bf484f2cc95" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column( | ||
"file_pins", sa.Column("delete_by", sa.TIMESTAMP(timezone=True), nullable=True) | ||
) | ||
op.create_index( | ||
"ix_file_pins_delete_by", | ||
"file_pins", | ||
["delete_by"], | ||
unique=False, | ||
postgresql_where=sa.text("delete_by IS NOT NULL"), | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index( | ||
"ix_file_pins_delete_by", | ||
table_name="file_pins", | ||
postgresql_where=sa.text("delete_by IS NOT NULL"), | ||
) | ||
op.drop_column("file_pins", "delete_by") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import abc | ||
import datetime as dt | ||
from typing import Optional | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.