## Describe what's wrong
quota limit was not reached, but the limit was exceeded，Changes from https://github.com/ClickHouse/ClickHouse/pull/20106


## Does it reproduce on recent release?
Version 21.3 or later

## How to reproduce
1、Set the quota of the account
```
CREATE USER IF NOT EXISTS jd_olap IDENTIFIED WITH double_sha1_password BY '123456'

GRANT SHOW, SELECT, INSERT, ALTER, CREATE DATABASE, CREATE TABLE, CREATE VIEW, CREATE DICTIONARY, DROP, TRUNCATE, OPTIMIZE, SYSTEM MERGES, SYSTEM TTL MERGES, SYSTEM FETCHES, SYSTEM MOVES, SYSTEM SENDS, SYSTEM REPLICATION QUEUES, SYSTEM SYNC REPLICA, SYSTEM RESTART REPLICA, SYSTEM FLUSH DISTRIBUTED, dictGet ON jd_olap.* TO jd_olap

CREATE QUOTA jd_olap_10s FOR INTERVAL 10 second MAX queries = 2 TO jd_olap;
```

2、create table
```
CREATE DATABASE IF NOT EXISTS jd_olap on cluster system_cluster;

CREATE TABLE IF NOT EXISTS jd_olap.quota_test_local on cluster system_cluster 
( 
`user` String, 
`max_concurrent_queries` UInt32, 
`max_execution_time` UInt32, 
`requests_per_minute` UInt32,
`dt` Date 
) 
ENGINE = ReplicatedReplacingMergeTree('/clickhouse/system_cluster/jdob_ha/jd_olap/quota_test_local/{shard}', '{replica}') 
PARTITION BY dt 
ORDER BY user 
SETTINGS storage_policy = 'jdob_ha', index_granularity = 8192;
```

3、execute the query（insert， select， alter）, will trigger the problem
![image](https://user-images.githubusercontent.com/20608540/141446196-b4319d2d-834f-4631-b9ba-47493bf9534b.png)


## Expected behavior**
there is a bug where end time is 1970, causing end_loaded.count =0；
![image](https://user-images.githubusercontent.com/20608540/141445667-635134f2-dc8d-4b0f-bca5-f6cc672e533c.png)

the used quota is not reset when it is first calculated (e.g., when a node is restarted or created for the first time) because 1970 is the first end time, the initial used logic is incremented from the first calculated value to the next interval. Used quota values are reset only at the next interval, as must be shown in the following figure: 16:45 and 16:47 are both calculated for the first time on the node restart, and the quota is not reset；
```
2021.11.09 16:49:17.481461 [ 14825 ] {1686DC283041A762} <Information> EnabledQuota: current_time: 2021-11-09 16:49:17, end: 1970-01-01 08:00:00
2021.11.09 16:49:17.481479 [ 14825 ] {1686DC283041A762} <Information> EnabledQuota: need_reset_counters: false, end_load_count: 0, interval.used: 11
```








{
    if (!quota_id)
        return {};
    QuotaUsage usage;
    usage.quota_id = *quota_id;
    usage.quota_name = quota_name;
    usage.quota_key = quota_key;
    usage.intervals.reserve(intervals.size());
    for (const auto & in : intervals)
    {
        usage.intervals.push_back({});
        auto & out = usage.intervals.back();
        out.duration = in.duration;
        out.randomize_interval = in.randomize_interval;
        bool counters_were_reset = false;
        out.end_of_interval = Impl::getEndOfInterval(in, current_time, counters_were_reset);
        for (auto quota_type : collections::range(QuotaType::MAX))
        {
            auto quota_type_i = static_cast<size_t>(quota_type);
            if (in.max[quota_type_i])
                out.max[quota_type_i] = in.max[quota_type_i];
            out.used[quota_type_i] = in.used[quota_type_i];
        }
    }
    return usage;
}
EnabledQuota::EnabledQuota(const Params & params_) : params(params_)