Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEXT_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ The release notes should contain at least the following sections:

## Important information

* Fixed a bug where the `evict` command ignored entries without a locality. If your DSS instance does not have a locality set, the next `evict` run may be slow while it processes the backlog of old entries.

## Minimal database schema version

| Schema | CockroachDB | Yugabyte |
Expand Down
38 changes: 22 additions & 16 deletions pkg/rid/store/datastore/identification_service_area.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,23 +213,29 @@ func (r *repo) SearchISAs(ctx context.Context, cells s2.CellUnion, earliest *tim
// ListExpiredISAs lists all expired ISAs based on writer.
// The function queries both empty writer and null writer when passing empty string as a writer.
func (r *repo) ListExpiredISAs(ctx context.Context, writer string, threshold time.Time) ([]*ridmodels.IdentificationServiceArea, error) {
writerQuery := "'" + writer + "'"
if len(writer) == 0 {
writerQuery = "'' OR writer = NULL"
isasInCellsQuery := fmt.Sprintf(`
SELECT
%s
FROM
identification_service_areas
WHERE
ends_at <= $1
AND
(writer = '' OR writer IS NULL)
LIMIT $2`, isaFields)
return r.fetchISAs(ctx, isasInCellsQuery, threshold, dssmodels.MaxResultLimit)
}

var (
isasInCellsQuery = fmt.Sprintf(`
SELECT
%s
FROM
identification_service_areas
WHERE
ends_at <= $1
AND
(writer = %s)
LIMIT $2`, isaFields, writerQuery)
)

return r.fetchISAs(ctx, isasInCellsQuery, threshold, dssmodels.MaxResultLimit)
isasInCellsQuery := fmt.Sprintf(`
SELECT
%s
FROM
identification_service_areas
WHERE
ends_at <= $1
AND
writer = $2
LIMIT $3`, isaFields)
return r.fetchISAs(ctx, isasInCellsQuery, threshold, writer, dssmodels.MaxResultLimit)
}
35 changes: 20 additions & 15 deletions pkg/rid/store/datastore/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,22 +274,27 @@ func (r *repo) SearchSubscriptionsByOwner(ctx context.Context, cells s2.CellUnio
// ListExpiredSubscriptions lists all expired Subscriptions based on writer.
// The function queries both empty writer and null writer when passing empty string as a writer.
func (r *repo) ListExpiredSubscriptions(ctx context.Context, writer string, threshold time.Time) ([]*ridmodels.Subscription, error) {
writerQuery := "'" + writer + "'"
if len(writer) == 0 {
writerQuery = "'' OR writer = NULL"
query := fmt.Sprintf(`
SELECT
%s
FROM
subscriptions
WHERE
ends_at <= $1
AND
(writer = '' OR writer IS NULL)`, subscriptionFields)
return r.process(ctx, query, threshold)
}

var (
query = fmt.Sprintf(`
SELECT
%s
FROM
subscriptions
WHERE
ends_at <= $1
AND
(writer = %s)`, subscriptionFields, writerQuery)
)

return r.process(ctx, query, threshold)
query := fmt.Sprintf(`
SELECT
%s
FROM
subscriptions
WHERE
ends_at <= $1
AND
writer = $2`, subscriptionFields)
return r.process(ctx, query, threshold, writer)
}
Loading