-
Notifications
You must be signed in to change notification settings - Fork 1
Fix validator #576
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
Fix validator #576
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1362,19 +1362,24 @@ func (db *dbClient) deleteExpiredEvents(ctx context.Context) (err error) { | |||||
| events | ||||||
| WHERE | ||||||
| expiration <= :cutoff | ||||||
| and hidden = false | ||||||
| and deleted = false | ||||||
| ORDER BY lookup_created_at ASC | ||||||
ice-dionysos marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| LIMIT :batch_size | ||||||
| FOR UPDATE SKIP LOCKED | ||||||
| ) | ||||||
| DELETE FROM events | ||||||
| WHERE id IN (SELECT id FROM expired_events) | ||||||
| DELETE FROM events AS de | ||||||
| USING expired_events AS ee | ||||||
| WHERE | ||||||
| de.id = ee.id | ||||||
| RETURNING | ||||||
| kind, | ||||||
| created_at, | ||||||
| id, | ||||||
| pubkey, | ||||||
| sig, | ||||||
| content, | ||||||
| tags` | ||||||
| de.kind, | ||||||
| de.created_at, | ||||||
| de.id, | ||||||
| de.pubkey, | ||||||
| de.sig, | ||||||
| de.content, | ||||||
| de.tags` | ||||||
| params := map[string]any{ | ||||||
| "batch_size": batchSize, | ||||||
| "cutoff": time.Now().UnixNano(), | ||||||
|
|
@@ -1393,7 +1398,7 @@ func (db *dbClient) deleteExpiredEvents(ctx context.Context) (err error) { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| if len(events) < batchSize { | ||||||
| if len(events) < batchSize || ctx.Err() != nil { | ||||||
|
||||||
| if len(events) < batchSize || ctx.Err() != nil { | |
| if len(events) < batchSize { |
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.
The new filtering conditions
hidden = false AND deleted = falsechange the behavior of expired event cleanup by excluding hidden and deleted events from being deleted based on expiration. This means that events marked as hidden or deleted will persist even if they have expired, which could lead to accumulation of expired events that were previously marked for deletion. If this is intentional to prevent double-processing of already-deleted events, this should be documented. Otherwise, this could lead to a buildup of expired events in the database that were marked as hidden or deleted but never actually removed.