Geo: Fix blob delete events
Problem
(I have not confirmed this problem by testing it yet, I'm just looking at the code)
- When a PackageFile is deleted on the primary, a delete event is published, and the PackageFile record disappears from the DB.
- On a secondary, the delete event is likely (maybe always?) to be processed after the record is deleted from the read-replica DB.
-
Geo::EventService
instantiates a Replicator, callsconsume
, which callsconsume_event_deleted
, which checksin_replicables_for_geo_node?
which callsmodel_record.in_replicables_for_geo_node?
which will fail whenmodel_record
isnil
.
Proposal
-
Don't call in_replicables_for_geo_node?
fromconsume_event_deleted
becausemodel_record
will often or always benil
, somodel_record.in_replicables_for_geo_node?
is not relevant to whether we should try to delete it from the secondary. -
If we do the previous item, then replicate_destroy
will fail callingmodel_record.id
whenmodel_record
isnil
, so we should usemodel_record_id
-
Fix blob_path -
Add tests that should have caught these items
Edited by Michael Kozono