HTHou opened a new pull request, #11452:
URL: https://github.com/apache/iotdb/pull/11452

   ## Description
   
   #11404 fixed when inserting empty Tablet and flush, some empty 
TsFileResource generated. However, after inserting empty Tablet, killing and 
restarting DataNode, the empty TsFileResource will still be generated.
   
   To fix it, we need to add the deletion logic of #11404 to the position of 
resource recovered from WAL. 
   
   
   ## How to reproduce
   
   1. start 1C1D iotdb and execute the following code.
   ```java
   
     public static void main(String[] args)
         throws IoTDBConnectionException, StatementExecutionException {
       session =
           new Session.Builder()
               .host(LOCAL_HOST)
               .port(6667)
               .username("root")
               .password("root")
               .version(Version.V_1_0)
               .build();
       session.open(false);
       insertTablet();
       session.close();
     }
   
   
     private static void insertTablet() throws IoTDBConnectionException, 
StatementExecutionException {
       // The schema of measurements of one device
       // only measurementId and data type in MeasurementSchema take effects in 
Tablet
       List<MeasurementSchema> schemaList = new ArrayList<>();
       schemaList.add(new MeasurementSchema("s1", TSDataType.INT64));
       schemaList.add(new MeasurementSchema("s2", TSDataType.INT64));
       schemaList.add(new MeasurementSchema("s3", TSDataType.INT64));
   
       Tablet tablet = new Tablet(ROOT_SG1_D1, schemaList, 100);
   
       // Method 1 to add tablet data
       long timestamp = System.currentTimeMillis();
   
       for (long row = 0; row < 100; row++) {
         int rowIndex = tablet.rowSize++;
         tablet.addTimestamp(rowIndex, timestamp);
         for (int s = 0; s < 3; s++) {
           tablet.addValue(schemaList.get(s).getMeasurementId(), rowIndex, 
null);
         }
         if (tablet.rowSize == tablet.getMaxRowNumber()) {
           session.insertTablet(tablet, true);
           tablet.reset();
         }
         timestamp++;
       }
   
       if (tablet.rowSize != 0) {
         session.insertTablet(tablet);
         tablet.reset();
       }
     }
   ```
   2. kill datanode by `kill -9 <pid>`
   3. restart datanode, then print the TsFileResource. You will see the 
TsFileResource doesn't contains any devices.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to