-
Bug
-
Resolution: Done
-
Undefined
-
None
-
None
Sometimes, but not always, the value for tally_measurement.value is getting written to the DB off by 0.000000000000001
For example, an hourly tally produced a value of 9.799999999999999 initially. Then after clearing the DB of everything except events, and running the tallying again, it ended up as 9.8
I have also seen this in the opposite direction where the expected value is 9.6 but results in 9.600000000000001
NOTE: This issue appears to be random and is not always reproducible. Sometimes not including the last event below seems to reproduce more frequently.
Steps To Reproduce:
1. Load some events into the DB
INSERT INTO public.events (event_id, "timestamp", data, event_type, event_source, instance_id, org_id, metering_batch_id, record_date) VALUES ('ac69e237-1387-4236-8099-33ef204210d8', '2023-12-05 07:00:00-04', '{"sla": "Premium", "role": "osd", "org_id": "org123", "event_id": "ac69e237-1387-4236-8099-33ef204210d8", "timestamp": "2023-12-05T11:00:00+00:00", "event_type": "snapshot_redhat.com:openshift_dedicated:4cpu_hour", "expiration": "2023-12-05T12:00:00+00:00", "instance_id": "6137ea0b-7d79-4caa-9c15-9fb2470876cd", "display_name": "6137ea0b-7d79-4caa-9c15-9fb2470876cd", "event_source": "prometheus", "measurements": [{"uom": "Cores", "value": 2.9}], "product_tag": ["rosa"], "service_type": "OpenShift Cluster", "account_number": "account_org123", "billing_provider": "red hat", "billing_account_id": "redhat1"}', 'snapshot_redhat.com:openshift_dedicated:4cpu_hour', 'prometheus', '6137ea0b-7d79-4caa-9c15-9fb2470876cd', 'org123', NULL, '2023-12-06 14:16:55.418313-04'); INSERT INTO public.events (event_id, "timestamp", data, event_type, event_source, instance_id, org_id, metering_batch_id, record_date) VALUES ('3dea8bdb-fd1c-43c8-8cf7-414d43a514bf', '2023-12-05 07:00:00-04', '{"sla": "Premium", "role": "osd", "org_id": "org123", "event_id": "3dea8bdb-fd1c-43c8-8cf7-414d43a514bf", "timestamp": "2023-12-05T11:00:00+00:00", "event_type": "snapshot_redhat.com:openshift_dedicated:4cpu_hour", "expiration": "2023-12-05T12:00:00+00:00", "instance_id": "fe304292-a71d-4d2d-a1ea-02095dde5d04", "display_name": "fe304292-a71d-4d2d-a1ea-02095dde5d04", "event_source": "prometheus", "measurements": [{"uom": "Cores", "value": 3.0}], "product_tag": ["rosa"], "service_type": "OpenShift Cluster", "account_number": "account_org123", "billing_provider": "red hat", "billing_account_id": "redhat1"}', 'snapshot_redhat.com:openshift_dedicated:4cpu_hour', 'prometheus', 'fe304292-a71d-4d2d-a1ea-02095dde5d04', 'org123', NULL, '2023-12-06 14:16:55.418607-04'); INSERT INTO public.events (event_id, "timestamp", data, event_type, event_source, instance_id, org_id, metering_batch_id, record_date) VALUES ('98c8252f-57d8-456d-b51a-6ca9f381d6b3', '2023-12-05 07:00:00-04', '{"sla": "Premium", "role": "osd", "org_id": "org123", "event_id": "98c8252f-57d8-456d-b51a-6ca9f381d6b3", "timestamp": "2023-12-05T11:00:00+00:00", "event_type": "snapshot_redhat.com:openshift_dedicated:4cpu_hour", "expiration": "2023-12-05T12:00:00+00:00", "instance_id": "ac519a5a-bc56-45ac-b1e6-32a3140d9f2d", "display_name": "ac519a5a-bc56-45ac-b1e6-32a3140d9f2d", "event_source": "prometheus", "measurements": [{"uom": "Cores", "value": 2.3}], "product_tag": ["rosa"], "service_type": "OpenShift Cluster", "account_number": "account_org123", "billing_provider": "red hat", "billing_account_id": "redhat1"}', 'snapshot_redhat.com:openshift_dedicated:4cpu_hour', 'prometheus', 'ac519a5a-bc56-45ac-b1e6-32a3140d9f2d', 'org123', NULL, '2023-12-06 14:16:55.418753-04'); INSERT INTO public.events (event_id, "timestamp", data, event_type, event_source, instance_id, org_id, metering_batch_id, record_date) VALUES ('97a860be-f52d-46db-838c-414b3ee82fe9', '2023-12-05 07:00:00-04', '{"sla": "Premium", "role": "osd", "org_id": "org123", "event_id": "97a860be-f52d-46db-838c-414b3ee82fe9", "timestamp": "2023-12-05T11:00:00+00:00", "event_type": "snapshot_redhat.com:openshift_dedicated:4cpu_hour", "expiration": "2023-12-05T12:00:00+00:00", "instance_id": "7681cdcf-e2c9-4532-bfe0-83b38374c116", "display_name": "7681cdcf-e2c9-4532-bfe0-83b38374c116", "event_source": "prometheus", "measurements": [{"uom": "Cores", "value": 1.4}], "product_tag": ["rosa"], "service_type": "OpenShift Cluster", "account_number": "account_org123", "billing_provider": "red hat", "billing_account_id": "redhat1"}', 'snapshot_redhat.com:openshift_dedicated:4cpu_hour', 'prometheus', '7681cdcf-e2c9-4532-bfe0-83b38374c116', 'org123', NULL, '2023-12-06 14:16:55.418892-04'); INSERT INTO public.events (event_id, "timestamp", data, event_type, event_source, instance_id, org_id, metering_batch_id, record_date) VALUES ('753366fc-3591-4ebc-97f2-0f58c1b4d6cb', '2023-12-05 07:00:00-04', '{"sla": "Premium", "role": "osd", "org_id": "org123", "event_id": "753366fc-3591-4ebc-97f2-0f58c1b4d6cb", "timestamp": "2023-12-05T11:00:00+00:00", "event_type": "snapshot_redhat.com:openshift_dedicated:4cpu_hour", "expiration": "2023-12-05T12:00:00+00:00", "instance_id": "e3a5225b-a826-43ab-9374-0c4fe40fde60", "display_name": "e3a5225b-a826-43ab-9374-0c4fe40fde60", "event_source": "prometheus", "measurements": [{"uom": "Cores", "value": 0.2}], "product_tag": ["rosa"], "service_type": "OpenShift Cluster", "account_number": "account_org123", "billing_provider": "red hat", "billing_account_id": "redhat1"}', 'snapshot_redhat.com:openshift_dedicated:4cpu_hour', 'prometheus', 'e3a5225b-a826-43ab-9374-0c4fe40fde60', 'org123', NULL, '2023-12-06 14:16:55.419027-04');
2. Run the hourly tally.
http POST ":8000/api/rhsm-subscriptions/v1/internal/tally/hourly?org=org123&start=2023-12-05T00:00Z&end=2023-12-06T23:00Z" x-rh-swatch-psk:placeholder Origin:console.redhat.com
3. Check the current values from the tally_measurements table
psql -U rhsm-subscriptions rhsm-subscriptions -c "select value from tally_measurements"
4. Clear the data.
psql -U rhsm-subscriptions rhsm-subscriptions -c "truncate hosts cascade; truncate tally_snapshots cascade; truncate billable_usage_remittance cascade;"
5. Re-run the hourly tally.
6. Check the current values from the tally_measurements table
psql -U rhsm-subscriptions rhsm-subscriptions -c "select value from tally_measurements"
Done
- Find out why this is happening
- Share with the team why it's happening
- Make it stop happening (or create new cards to be refined if the solution is complex)