Fix day-based table rolling time range strategy in JDBC storage. (#11915)

This commit is contained in:
Chen Ziyan 2024-02-22 23:15:38 +08:00 committed by GitHub
parent f021b7bdd9
commit 0f7844278a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 5 additions and 4 deletions

View File

@ -53,6 +53,7 @@
* Fix ServiceInstance `in` query.
* Mock `/api/v1/status/buildinfo` for PromQL API.
* Fix table exists check in the JDBC Storage Plugin.
* Fix day-based table rolling time range strategy in JDBC storage.
#### UI

View File

@ -68,12 +68,12 @@ public class CoreModuleConfig extends ModuleConfig {
* The time to live of all metrics data. Unit is day.
*/
private int metricsDataTTL = 3;
private int metricsDataTTL = 7;
/**
* The time to live of all record data, including tracing. Unit is Day.
*/
private int recordDataTTL = 7;
private int recordDataTTL = 3;
private int gRPCThreadPoolSize;

View File

@ -202,7 +202,7 @@ public class TableHelper {
getConfigService().getRecordDataTTL() :
getConfigService().getMetricsDataTTL();
return LongStream
.rangeClosed(0, ttl)
.range(0, ttl)
.mapToObj(it -> TimeBucket.getTimeBucket(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(it), DownSampling.Day))
.distinct()
.collect(toList());

View File

@ -51,7 +51,7 @@ public class JDBCHistoryDeleteDAO implements IHistoryDeleteDAO {
@SneakyThrows
public void deleteHistory(Model model, String timeBucketColumnName, int ttl) {
final var endTimeBucket = TimeBucket.getTimeBucket(clock.millis() + TimeUnit.DAYS.toMillis(1), DownSampling.Day);
final var startTimeBucket = TimeBucket.getTimeBucket(clock.millis() - TimeUnit.DAYS.toMillis(ttl), DownSampling.Day);
final var startTimeBucket = TimeBucket.getTimeBucket(clock.millis() - TimeUnit.DAYS.toMillis(ttl - 1), DownSampling.Day);
log.info(
"Deleting history data, ttl: {}, now: {}. Keep [{}, {}]",
ttl,