private void fetchMonthlyStorageUsageAndMaybeRetry() {
    boolean shouldRetry = false;
    try {
      String monthValue = accountStatsStore.queryRecordedMonth();
      if (monthValue.equals(currentMonth)) {
        logger.info("Fetching monthly base from mysql database in periodical thread for this month: {}", currentMonth);
        containerStorageUsageMonthlyBase =
            convertAggregatedAccountStorageStatsToMap(accountStatsStore.queryMonthlyAggregatedAccountStorageStats(),
                config.usePhysicalStorage);
      } else {
        logger.info("Current month [{}] is not the same as month [{}]recorded in mysql database", currentMonth,
            monthValue);
        shouldRetry = true;
      }
    } catch (Exception e) {
      logger.error("Failed to refresh monthly storage usage", e);
      shouldRetry = true;
    }

    if (shouldRetry) {
      if (retries >= config.mysqlStoreRetryMaxCount) {
        logger.error("Failed to refresh monthly storage usage after {} retries, will skip for month: {}", retries,
            currentMonth);
        retries = 0;
        scheduleStorageUsageMonthlyBaseFetcher();
        return;
      }
      retries++;
      if (config.mysqlStoreRetryBackoffMs != 0) {
        logger.info("Schedule to retry to fetch monthly base from mysql database after {} ms, the retry count: {}",
            config.mysqlStoreRetryBackoffMs, retries);
        scheduler.schedule(this::fetchMonthlyStorageUsageAndMaybeRetry, config.mysqlStoreRetryBackoffMs,
            TimeUnit.MILLISECONDS);
      }
    } else {
      retries = 0;
      tryPersistMonthlyUsage();
      // sleep for two seconds so we can move on to next tick
      sleepFor(2000);
      scheduleStorageUsageMonthlyBaseFetcher();
    }
  }
Fetch the container monthly storage usage from mysql and update the in memory cache. If somehow it fails, we will
retry for several times before giving up.
ambry-quota/src/main/java/com/github/ambry/quota/storage/MySqlStorageUsageRefresher.java