From dff910a6bc3aa35840ba3fc33252529fa63dad1d Mon Sep 17 00:00:00 2001 From: Sadhan Sood <106645797+sadhansood@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:20:19 -0800 Subject: [PATCH] Fix how we track object status in analytics (#16322) ## Description This PR fixes how we are tagging object status in object and transaction object table. Currently, all output object statuses are incorrect i.e. created objects are marked as deleted, deleted as mutated and mutated as created. This would require some careful fixing. These are the proposed steps to fix: 1. Stop the ingestion pipelines for object and transaction_object tables (ensure currently running pipelines are done processing) and run the following commands: 2. `UPDATE dataset.OBJECT SET object_status = 'Mutated_tmp' WHERE object_status = 'Created';` 3. `UPDATE dataset.OBJECT SET object_status = 'Created' WHERE object_status = 'Deleted';` 4. `UPDATE dataset.OBJECT SET object_status = 'Deleted' WHERE object_status = 'Mutated';` 5. `UPDATE dataset.OBJECT SET object_status = 'Mutated' WHERE object_status = 'Mutated_tmp';` 6. `UPDATE dataset.TRANSACTION_OBJECT SET object_status = 'Mutated_tmp' WHERE object_status = 'Created';` 7. `UPDATE dataset.TRANSACTION_OBJECT SET object_status = 'Created' WHERE object_status = 'Deleted';` 8. `UPDATE dataset.TRANSACTION_OBJECT SET object_status = 'Deleted' WHERE object_status = 'Mutated';` 9. `UPDATE dataset.TRANSACTION_OBJECT SET object_status = 'Mutated' WHERE object_status = 'Mutated_tmp';` 10. Deploy pipelines with the new binary (which includes this fix) --- crates/sui-analytics-indexer/src/handlers/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/sui-analytics-indexer/src/handlers/mod.rs b/crates/sui-analytics-indexer/src/handlers/mod.rs index 3a131dc477257..a49b850f9816f 100644 --- a/crates/sui-analytics-indexer/src/handlers/mod.rs +++ b/crates/sui-analytics-indexer/src/handlers/mod.rs @@ -147,11 +147,11 @@ impl ObjectStatusTracker { fn get_object_status(&self, object_id: &ObjectID) -> Option { if self.mutated.contains(object_id) { - Some(ObjectStatus::Created) - } else if self.deleted.contains(object_id) { Some(ObjectStatus::Mutated) - } else if self.created.contains(object_id) { + } else if self.deleted.contains(object_id) { Some(ObjectStatus::Deleted) + } else if self.created.contains(object_id) { + Some(ObjectStatus::Created) } else { None }