AuthEceSoftEng / cenote-api

API server & web client used by cenote.

Home Page:https://cenote.sidero.services/api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(2.5) Cockroach tables and Redis keys are not deleted when a project is deleted [2.5]

johnantonn opened this issue · comments

Since the organization info is stored in mongo and the actual data (event collections and properties) are stored in cockroach, upon a delete organization request, the router should not only delete the organization from mongo, but issue commands to delete its associated data from cockroach as well.

Redis keys will be deleted as well by doing the above, because their deletion is tied with the deletion of cockorach tables and columns.

After discussing with @iamnapo and @asymeon we decided to break the deletion of cockroach tables in two phases:

  • When a user deletes columns/tables, they are renamed to 'DELETED_OLD_NAME".
  • A script cleans up the columns/tables that are marked as 'DELETED' whenever it is executed.

Additional logic needs to be introduced for the cases where an event collection, say X, is deleted (it's renamed as deleted_X in cockroachdb) and then it's re-created and re-deleted. The second deletion won't succeed because there's already a deleted_X table in cockroach (unless of course the cleanup script has been executed in the meantime).

Count logic should be inserted to increment deleted tables from cockroach, e.g. deleted_X_1, deleted_X_2 etc.