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

Correct tally_snapshot table constraints

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • None
    • None
    • 5
    • True
    • Hide

      None

      Show
      None
    • False
    • 5

      1. The unit_of_measure column is currently part of the tally_snapshot uniqueness constraint, but it is no longer needed and can be removed from the table. The issue arises because PostgreSQL does not treat NULL values as part of a uniqueness constraint, which can result in duplicate records.
      2. The columns snapshot_date, org_id, product_id, and granularity currently allow NULL values, but they should have NOT NULL constraints to ensure data integrity.

      We discovered an issue in CI pipelines which we suspect there might be a "potential" race condition during the retally(same tally rerun again) process, where the tally_state table is not being properly locked. This could lead to the creation of duplicate entries in the tally_snapshot table.

       

      TODO - split cards

      • API to delete rows where there are nulls in any of those columns
      • THEN Add constraint (liquibase)
      • DROP UOM column (liquibase) from tally_snapshot, adjust the the uniqueness constraint if it doesn't update that automatically
      •  

       

      Acceptance criteria:

      1. unit_of_measure column is removed from the table.
      2. add billing_provider and billing_account_id columns into the unique index.
      3. Not null constraints are added to the org_id, snapshot_date, granularity, and product_id columns.
      4. Enable Test MR: SWATCH-3466 [Make the sync_tally method more robust|iqe test]
      5. Make sure in stage applying unique constraint is quick and doesn't cause any db issues.

              Unassigned Unassigned
              karshah@redhat.com Kartik Shah
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: