This commit is contained in:
@@ -42,6 +42,13 @@ func (p *DeleteProcessor) Handle(ctx context.Context, event outbox.Event) error
|
||||
if status != "PENDING_DELETE" {
|
||||
return nil
|
||||
}
|
||||
var unresolvedProviderRefs int
|
||||
if err := tx.QueryRow(ctx, `SELECT count(*) FROM memory_index_entry WHERE memory_id=$1::uuid AND index_type='provider' AND provider_ref IS NOT NULL AND status<>'DELETED'`, event.AggregateID).Scan(&unresolvedProviderRefs); err != nil {
|
||||
return fmt.Errorf("check provider memory deletion: %w", err)
|
||||
}
|
||||
if unresolvedProviderRefs > 0 {
|
||||
return outbox.Retryable(errors.New("provider memory deletion has not reconciled"))
|
||||
}
|
||||
if _, err := tx.Exec(ctx, `UPDATE memory_index_entry SET embedding=NULL,status='DELETED',provider_ref=NULL,indexed_at=NULL,last_error=NULL,updated_at=now() WHERE memory_id=$1::uuid`, event.AggregateID); err != nil {
|
||||
return fmt.Errorf("delete memory indexes: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user