You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cloudstack.apache.org by Matheus Fontes <ma...@ghz.com.br> on 2022/09/08 18:08:44 UTC

Re: Usage computing removed items

I found a query that maybe a problem:
When usage job start it founds a VOLUME.DELETE in usage_event table and after that it look for a register in usage_volume table with that query:

SELECT usage_volume.id, usage_volume.zone_id, usage_volume.account_id, usage_volume.domain_id, usage_volume.volume_id, usage_volume.disk_offering_id, usage_volume.template_id, usage_volume.size, usage_volume.created, usage_volume.deleted FROM usage_volume WHERE usage_volume.account_id = 9  AND usage_volume.id = 110  AND usage_volume.deleted IS NULL;
Empty set (0.00 sec)

but its return empty because the field filter is wrong. I think the query needs to look for a volume_id field.
SELECT usage_volume.id, usage_volume.zone_id, usage_volume.account_id, usage_volume.domain_id, usage_volume.volume_id, usage_volume.disk_offering_id, usage_volume.template_id, usage_volume.size, usage_volume.created, usage_volume.deleted FROM usage_volume WHERE usage_volume.account_id = 9  AND usage_volume.volume_id = 110  AND usage_volume.deleted IS NULL;
+----+---------+------------+-----------+-----------+------------------+-------------+-------------+---------------------+---------+
| id | zone_id | account_id | domain_id | volume_id | disk_offering_id | template_id | size        | created             | deleted |
+----+---------+------------+-----------+-----------+------------------+-------------+-------------+---------------------+---------+
| 74 |       1 |          9 |         2 |       110 |               78 |        NULL | 10737418240 | 2021-06-08 19:19:38 | NULL    |
+----+---------+------------+-----------+-----------+------------------+-------------+-------------+---------------------+---------+
1 row in set (0.00 sec)

WIth this wrong query, the usage_volume line will never be found and will never be update with correct deleted field.

Is there someone else experiencing this problem?



> On 26 Jul 2022, at 17:30, Matheus Fontes <ma...@ghz.com.br> wrote:
> 
> Hi,
> Is anyone having  problems with usage computing removed items?
> We have a user that reported the problem.
> The volume was deleted since 2022-05-06
> 
> mysql> select id,account_id,created,removed,state from volumes where id=3246;
> +------+------------+---------------------+---------------------+----------+
> | id   | account_id | created             | removed             | state    |
> +------+------------+---------------------+---------------------+----------+
> | 3246 |        545 | 2021-04-08 17:03:16 | 2022-05-06 15:06:52 | Expunged |
> +------+------------+---------------------+---------------------+----------+
> 
> 
> In usage process we can see it on parsing volume call:
> 2022-07-26 00:18:17,471 DEBUG [usage.parser.VolumeUsageParser] (Usage-Job-1:null) (logid:) Parsing all Volume usage events for account: 545
> 2022-07-26 00:18:17,472 DEBUG [usage.parser.VolumeUsageParser] (Usage-Job-1:null) (logid:) Total running time 86400000ms
> 2022-07-26 00:18:17,472 DEBUG [usage.parser.VolumeUsageParser] (Usage-Job-1:null) (logid:) Creating Volume usage record for vol: 3246, usage: 24, startDate: Mon Jul 25 00:00:00 BRT 2022, endDate: Mon Jul 25 23:59:59 BRT 2022, for account: 545
> 2022-07-26 00:18:17,484 DEBUG [usage.parser.VolumeUsageParser] (Usage-Job-1:null) (logid:) Total running time 86400000ms
> 2022-07-26 00:18:17,484 DEBUG [usage.parser.VolumeUsageParser] (Usage-Job-1:null) (logid:) Creating Volume usage record for vol: 3246, usage: 24, startDate: Mon Jul 25 00:00:00 BRT 2022, endDate: Mon Jul 25 23:59:59 BRT 2022, for account: 545
> 
> 
> And it are being computed to account:
> (ascenty) # > list usagerecords domainid=XXXXXXXXXXXXXXXXXXX accountid=d14c8cb9-fd92-43c8-9ddb-f2ed4e9af5a8 type=6 startdate=2022-07-25 enddate=2022-07-25 filter=account,rawusage,size,startdate,usage,usagetype,
> {
>  "count": 2,
>  "usagerecord": [
>    {
>      "accountid": "d14c8cb9-fd92-43c8-9ddb-f2ed4e9af5a8",
>      "rawusage": "24",
>      "size": 53687091200,
>      "startdate": "2022-07-25'T'00:00:00-03:00",
>      "usage": "24 Hrs",
>      "usagetype": 6
>    },
>    {
>      "accountid": "d14c8cb9-fd92-43c8-9ddb-f2ed4e9af5a8",
>      "rawusage": "24",
>      "size": 53687091200,
>      "startdate": "2022-07-25'T'00:00:00-03:00",
>      "usage": "24 Hrs",
>      "usagetype": 6
>    }
>  ]
> }