Skip to content

[IOTDB-172]fix a bug of TsFileResource updateTime #347

Merged
jixuan1989 merged 3 commits intoapache:masterfrom
LeiRui:ResourceUpdateTime
Aug 22, 2019
Merged

[IOTDB-172]fix a bug of TsFileResource updateTime #347
jixuan1989 merged 3 commits intoapache:masterfrom
LeiRui:ResourceUpdateTime

Conversation

@LeiRui
Copy link
Contributor

@LeiRui LeiRui commented Aug 21, 2019

Bug Description:
When recovering a TsFile's device -> start time and device -> end time map and the TsFile's resource file happens not to exist, the TsFile itself will be read to update the start and end time map instead. It is implemented by TsFileRecoverPerformer.recover as follows:

for (TsDeviceMetadataIndex index : deviceMetadataIndexList) {
  TsDeviceMetadata deviceMetadata = reader.readTsDeviceMetaData(index);
  List<ChunkGroupMetaData> chunkGroupMetaDataList = deviceMetadata.getChunkGroupMetaDataList();
  for (ChunkGroupMetaData chunkGroupMetaData : chunkGroupMetaDataList) {
    for (ChunkMetaData chunkMetaData : chunkGroupMetaData.getChunkMetaDataList()) {
      tsFileResource.updateTime(chunkGroupMetaData.getDeviceID(), chunkMetaData.getStartTime());
      tsFileResource.updateTime(chunkGroupMetaData.getDeviceID(), chunkMetaData.getEndTime());
    }
  }
}

The updateTime function uses the first-coming value as the startTime:

  public void updateTime(String deviceId, long time) {
    startTimeMap.putIfAbsent(deviceId, time);
    Long endTime = endTimeMap.get(deviceId);
    if (endTime == null || endTime < time) {
      endTimeMap.put(deviceId, time);
    }
  }

So when root.vehicle.d0 has a chunkgroup of chunkMetadata listed as:
s3: startTime=3000, endTime=10000;
s1: startTime=1000, endTime=10000;
s2: startTime=2000, endTime=10000;
By the current code, the updated start time will be the first coming 3000, which is not correct.


By the way, I also change updateTime in LogReplayer.replayLogs to updateStartTime and updateEndTime. If there is something I haven't noticed, please tell me.

@MyXOF
Copy link
Member

MyXOF commented Aug 21, 2019

please add ut to cover this case

@LeiRui
Copy link
Contributor Author

LeiRui commented Aug 21, 2019

please add ut to cover this case

added ☺️

@jixuan1989
Copy link
Member

Hi, is there an jira issue attached this PR?
We need to manage the solved version on that.

}

@Deprecated
public void updateTime(String deviceId, long time) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may just remove this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@LeiRui
Copy link
Contributor Author

LeiRui commented Aug 22, 2019

Hi, is there an jira issue attached this PR?
We need to manage the solved version on that.

Added. See IOTDB-172.

remove useless `updateTime` method
@LeiRui LeiRui changed the title fix a bug of TsFileResource updateTime [IOTDB-172]fix a bug of TsFileResource updateTime Aug 22, 2019
@jixuan1989 jixuan1989 merged commit 1a09243 into apache:master Aug 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants