-
Notifications
You must be signed in to change notification settings - Fork 2
Add GC functionality to SQLite datastore #31
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
Conversation
| } | ||
|
|
||
| // FIXME: This is REALLY ugly! | ||
| fmt_q := fmt.Sprintf(strings.Replace(query, "$1", "'%s'", 1), formatStringArrayFromUUIDs(uuids)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the problem using parametrized queries on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, Go's SQL adapters can't really convert arrays into IN lists. It is a problem specifically for SQLite as there is no workaround (or at least a simple workaround) unlike other DBMS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I intend to kick this can further down the road at this moment.
| func (ms *sqliteMatcherStore) DeleteUpdateOperations(ctx context.Context, uuids ...uuid.UUID) (int64, error) { | ||
| zlog.Warn(ctx).Msg("sqliteMatcherStore.DeleteUpdateOperations is not implemented!") | ||
| return 0, nil | ||
| const query = `DELETE FROM update_operation WHERE ref IN ($1);` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add to top of this method
zlog.Debug(ctx).Msg(">>> sqliteMatcherStore.DeleteUpdateOperations")There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
| // The returned int64 value indicates the remaining number of update operations needing GC. | ||
| // Running this method till the returned value is 0 accomplishes a full GC of the vulnstore. | ||
| func (ms *sqliteMatcherStore) GC(ctx context.Context, count int) (int64, error) { | ||
| zlog.Warn(ctx).Msg("sqliteMatcherStore.GC is not implemented!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
zlog.Debug(ctx).Msg(">>> sqliteMatcherStore.GC")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
datastore/sqlite_store.go
Outdated
| ) | ||
|
|
||
| // gather any update operations exceeding our keep value. | ||
| // keep+1 is used because PG's array slicing is inclusive, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is Postgres (PG) relevant here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not relevant at all. Gone.
1b6d22b to
be6fb4e
Compare
Fixes: #13