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

chore: refactor delete requests store interface to prepare for replacing boltdb with sqlite for storing delete requests #16181

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sandeepsukhani
Copy link
Contributor

What this PR does / why we need it:
We currently use botldb to store delete requests. However, because it is a key/value store that requires us to craft the KVs to store all the details, it is difficult to add more details. I am working on replacing boltdb with SQLite to store the delete requests, which would let us add more details to the requests and optimize intensive queries that cause the compactor to use too many resources.

Here is how the delete requests store interface will look:

type DeleteRequestsStore interface {
	AddDeleteRequest(ctx context.Context, userID, query string, startTime, endTime model.Time, shardByInterval time.Duration) (string, error)
	GetAllRequests(ctx context.Context) ([]DeleteRequest, error)
	GetAllDeleteRequestsForUser(ctx context.Context, userID string) ([]DeleteRequest, error)
	RemoveDeleteRequest(ctx context.Context, userID string, requestID string) error
	GetDeleteRequest(ctx context.Context, userID, requestID string) (DeleteRequest, error)
	GetCacheGenerationNumber(ctx context.Context, userID string) (string, error)
	MergeShardedRequests(ctx context.Context) error

	// ToDo(Sandeep): To keep changeset smaller, below 2 methods treat a single shard as individual request. This can be refactored later in a separate PR.
	MarkShardAsProcessed(ctx context.Context, req DeleteRequest) error
	GetUnprocessedShards(ctx context.Context) ([]DeleteRequest, error)
	GetAllShards(ctx context.Context) ([]DeleteRequest, error)

	Stop()
	Name() string
}

Special notes for your reviewer:
The thing to note here is that both stores will have different mechanisms to store the shards, so I have tried to abstract it away where possible.

Checklist

  • Tests updated

@sandeepsukhani sandeepsukhani requested a review from a team as a code owner February 11, 2025 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant