Skip to content

fix(recommendations): EC2 tenancy and platform missing from the recommendations natural key and rec ID #806

Closed

Description

@cristim

Problem

The recommendations natural key (account_key, provider, service, region, resource_type, engine, term, payment_option, migrations 000032/000043) and recommendationID (internal/scheduler/scheduler.go:1076) omit EC2 tenancy and platform, which live only in the payload Details blob. Two EC2 recs for the same type and term that differ only by tenancy or platform (for example linux vs windows) land on the same key.

persistCollection (scheduler.go:391) upserts all providers' recs in one transaction, so two such recs in one batch raise ON CONFLICT DO UPDATE command cannot affect row a second time and the whole collection write fails, not just one rec. Same failure shape as the AZ case in #792.

Fix

Expand/contract, as planned for #792 (prod runs with auto_migrate=false, migration is a manual database-migration.yml dispatch): add tenancy and platform columns with backfill from payload and a wider unique index (keep the old one), then code writes the columns and conflicts on the wider key, then a later release drops the old index. recIdentityKey (internal/api/purchase_pricing.go:124) and recommendationID must adopt the same fields. Needs a store test with two recs differing only by tenancy/platform.

Deliberately split out of #792 to keep that change scoped. Related: #792.

Activity

  1. cristim commented on Oct 14, 2026

    @cristim
    MemberAuthor

    Deployed: PR #821 merged normally at a3bc552. Automatic AWS deployment 38648834630 succeeded.

    Verified against actual DEV after deployment using the existing approved read-only route: schema version 119, dirty=false; the legacy nine-column index is absent; recommendations_natural_key_az_tp_idx is unique and valid with all eleven intended columns. Armed multi-step Savings Plan count remains zero. The query used BEGIN READ ONLY and ROLLBACK and completed successfully, including tunnel cleanup. No application invocation, manual migration, database write or provider purchase was performed for verification.

    The independently reviewed head's required CI passed before merge. All four post-merge workflows succeeded: full CI 38648834550, automatic AWS deployment 38648834630, pre-commit 38648834662 and frontend 38648834739. Every watcher reached its terminal result. Native PostgreSQL 17 fixture verification additionally passed the production runner's 118 -> 119 -> 118 -> 119 path, coexistence, exact-duplicate rejection and rollback deduplication.

    The recommendation-index issue is resolved in DEV. The separate pre-existing transaction/recovery comment inaccuracies are tracked in #874. The migration's accepted cache-lock trade-off and the test-assertion review disposition are documented on PR #821's inline threads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions