Uploaded image for project: 'Subscription Watch'
  1. Subscription Watch
  2. SWATCH-3502

Purge tally_snapshots and tally_measurements with org_id is null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • None
    • swatch-tally
    • False
    • Hide

      None

      Show
      None
    • False

      Investigating SWATCH-3478, we found that we have almost 1 M records in tally_snapshots that are not linked to any customer (org_id is null).

      We need to purge these records that are not going to be deleted by the clean up cronjob (which is org_id/timestamp based).

      Query that can be used:

      select * from tally_snapshots where org_id is null
      

      The most recent tally_snapshot without org_id in production is from 2023-01-03, so this was likely to be caused by an old bug that has been already addressed.

      Note that the tally_measurements records that are using any of these tally_snapshots need also to be deleted. And take into account that since we don't use a foreign key from tally_snapshots to tally_measurements, we can't use delete cascade, so we need to delete the tally_measurements before deleting the tally_snapshots.

      Acceptance Criteria

      • Delete the tally_measurements and tally_snapshots
      • Add non null constraint for the org_id column
      • If a liquibase migration script is used, double check that it will finish ok in a certain amount of time. Otherwise, ask for support for DBA to run the delete queries.
        In stage, there are less than 1 M tally snapshots records, and only 132 without org_id
        In prod, there are more than 164 M tally snapshots records, and almost 1 M records without org_id.

              Unassigned Unassigned
              jcarvaja@redhat.com Jose Carvajal Hilario
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: