Skip to content

Commit c94db16

Browse files
CaideyipiJackieTien97
authored andcommitted
Fixed the cached TTL & time precision problem of PartitionTableAutoCleaner (#15455)
* Update ClusterSchemaInfo.java * partial * Fix (cherry picked from commit 3288914)
1 parent 9ecf8da commit c94db16

File tree

3 files changed

+14
-12
lines changed
  • iotdb-core
    • confignode/src/main/java/org/apache/iotdb/confignode/manager
    • datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/schema
    • node-commons/src/main/java/org/apache/iotdb/commons/schema/table

3 files changed

+14
-12
lines changed

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TTLManager.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.iotdb.commons.conf.CommonDescriptor;
2424
import org.apache.iotdb.commons.exception.IllegalPathException;
2525
import org.apache.iotdb.commons.path.PartialPath;
26+
import org.apache.iotdb.commons.utils.CommonDateTimeUtils;
2627
import org.apache.iotdb.commons.utils.PathUtils;
2728
import org.apache.iotdb.confignode.consensus.request.read.ttl.ShowTTLPlan;
2829
import org.apache.iotdb.confignode.consensus.request.write.database.DatabaseSchemaPlan;
@@ -136,8 +137,12 @@ public int getTTLCount() {
136137
* @return the maximum ttl of the subtree of the corresponding database. return NULL_TTL if the
137138
* TTL is not set or the database does not exist.
138139
*/
139-
public long getDatabaseMaxTTL(String database) {
140-
return ttlInfo.getDatabaseMaxTTL(database);
140+
public long getDatabaseMaxTTL(final String database) {
141+
final long ttl = ttlInfo.getDatabaseMaxTTL(database);
142+
return ttl == Long.MAX_VALUE || ttl < 0
143+
? ttl
144+
: CommonDateTimeUtils.convertMilliTimeWithPrecision(
145+
ttl, CommonDescriptor.getInstance().getConfig().getTimestampPrecision());
141146
}
142147

143148
/** Only used for upgrading from old database-level ttl to device-level ttl. */

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/schema/DataNodeTTLCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public long getTTLForTree(IDeviceID deviceID) {
8787

8888
public long getTTLForTable(final String database, final String table) {
8989
final TsTable tsTable = DataNodeTableCache.getInstance().getTable(database, table);
90-
return tsTable == null ? Long.MAX_VALUE : tsTable.getTableTTL();
90+
return tsTable == null ? Long.MAX_VALUE : tsTable.getCachedTableTTL();
9191
}
9292

9393
/** Get ttl with time precision conversion. */

iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/table/TsTable.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,23 +209,20 @@ public List<TsTableColumnSchema> getColumnList() {
209209

210210
// This shall only be called on DataNode, where the tsTable is replaced completely thus an old
211211
// cache won't pollute the newest value
212-
public long getTableTTL() {
212+
public long getCachedTableTTL() {
213213
// Cache for performance
214214
if (ttlValue < 0) {
215-
final long ttl = getTableTTLInMS();
216-
ttlValue =
217-
ttl == Long.MAX_VALUE
218-
? ttl
219-
: CommonDateTimeUtils.convertMilliTimeWithPrecision(
220-
ttl, CommonDescriptor.getInstance().getConfig().getTimestampPrecision());
215+
ttlValue = getTableTTL();
221216
}
222217
return ttlValue;
223218
}
224219

225-
private long getTableTTLInMS() {
220+
public long getTableTTL() {
226221
final Optional<String> ttl = getPropValue(TTL_PROPERTY);
227222
return ttl.isPresent() && !ttl.get().equalsIgnoreCase(TTL_INFINITE)
228-
? Long.parseLong(ttl.get())
223+
? CommonDateTimeUtils.convertMilliTimeWithPrecision(
224+
Long.parseLong(ttl.get()),
225+
CommonDescriptor.getInstance().getConfig().getTimestampPrecision())
229226
: Long.MAX_VALUE;
230227
}
231228

0 commit comments

Comments
 (0)