Program: 30847
Project: 30847
Buggy source:
private void testReload(int partitionBy,int count,long inct,final int testPartitionSwitch) throws Exception {
  final long increment=inct * 1000;
  CairoTestUtils.createAllTable(configuration,partitionBy);
  TestUtils.assertMemoryLeak(() -> {
    Rnd rnd=new Rnd();
    long ts=DateFormatUtils.parseDateTime("String_Node_Str");
    long blob=allocBlob();
    try {
      try (TableReader reader=new TableReader(configuration,"String_Node_Str")){
        Assert.assertFalse(reader.reload());
        assertCursor(reader,ts,increment,blob,0,null);
      }
       try (TableReader reader=new TableReader(configuration,"String_Node_Str")){
        long nextTs=testAppend(rnd,configuration,ts,count,increment,blob,0,BATCH1_GENERATOR);
        Assert.assertTrue(reader.reload());
        assertCursor(reader,ts,increment,blob,count,BATCH1_ASSERTER);
        try (TableReader reader2=new TableReader(configuration,"String_Node_Str")){
          assertCursor(reader2,ts,increment,blob,count,BATCH1_ASSERTER);
        }
         Assert.assertFalse(reader.reload());
        nextTs=testAppend(rnd,configuration,nextTs,count,increment,blob,testPartitionSwitch,BATCH1_GENERATOR);
        assertCursor(reader,ts,increment,blob,count,BATCH1_ASSERTER);
        Assert.assertTrue(reader.reload());
        assertCursor(reader,ts,increment,blob,2 * count,BATCH1_ASSERTER);
        try (TableWriter writer=new TableWriter(configuration,"String_Node_Str")){
          assertCursor(reader,ts,increment,blob,2 * count,BATCH1_ASSERTER);
          Assert.assertFalse(reader.reload());
          assertCursor(reader,ts,increment,blob,2 * count,BATCH1_ASSERTER);
          nextTs=testAppend(writer,rnd,nextTs,count,increment,blob,0,BATCH1_GENERATOR);
          Assert.assertTrue(reader.reload());
          assertCursor(reader,ts,increment,blob,3 * count,BATCH1_ASSERTER);
          writer.addColumn("String_Node_Str",ColumnType.STRING);
          nextTs=testAppend(writer,rnd,nextTs,count,increment,blob,0,BATCH2_GENERATOR);
          Assert.assertTrue(reader.reload());
          assertBatch2(count,increment,ts,blob,reader);
          writer.addColumn("String_Node_Str",ColumnType.INT);
          nextTs=testAppend(writer,rnd,nextTs,count,increment,blob,0,BATCH3_GENERATOR);
          Assert.assertTrue(reader.reload());
          assertBatch3(count,increment,ts,blob,reader);
          writer.addColumn("String_Node_Str",ColumnType.SHORT);
          writer.addColumn("String_Node_Str",ColumnType.BOOLEAN);
          writer.addColumn("String_Node_Str",ColumnType.BYTE);
          writer.addColumn("String_Node_Str",ColumnType.FLOAT);
          writer.addColumn("String_Node_Str",ColumnType.DOUBLE);
          writer.addColumn("String_Node_Str",ColumnType.SYMBOL);
          writer.addColumn("String_Node_Str",ColumnType.LONG);
          writer.addColumn("String_Node_Str",ColumnType.DATE);
          writer.addColumn("String_Node_Str",ColumnType.BINARY);
          nextTs=testAppend(writer,rnd,nextTs,count,increment,blob,0,BATCH4_GENERATOR);
          Assert.assertTrue(reader.reload());
          assertBatch4(count,increment,ts,blob,reader);
          if (Os.type == Os.WINDOWS) {
            reader.closeColumn("String_Node_Str");
          }
          writer.removeColumn("String_Node_Str");
          Assert.assertTrue(reader.reload());
          assertBatch5(count,increment,ts,blob,reader,new Rnd());
          testAppend(writer,rnd,nextTs,count,increment,blob,0,BATCH6_GENERATOR);
          Assert.assertTrue(reader.reload());
          assertBatch6(count,increment,ts,blob,reader);
          if (Os.type == Os.WINDOWS) {
            reader.closeColumn("String_Node_Str");
          }
          writer.removeColumn("String_Node_Str");
          writer.addColumn("String_Node_Str",ColumnType.INT);
          Assert.assertTrue(reader.reload());
          assertBatch7(count,increment,ts,blob,reader);
          Assert.assertFalse(reader.reload());
        }
       }
     }
  finally {
      freeBlob(blob);
    }
  }
);
}

Fixed version (ground truth):
private void testReload(int partitionBy,int count,long inct,final int testPartitionSwitch) throws Exception {
  final long increment=inct * 1000;
  CairoTestUtils.createAllTable(configuration,partitionBy);
  TestUtils.assertMemoryLeak(() -> {
    Rnd rnd=new Rnd();
    long ts=DateFormatUtils.parseDateTime("String_Node_Str");
    long blob=allocBlob();
    try {
      try (TableReader reader=new TableReader(configuration,"String_Node_Str")){
        Assert.assertFalse(reader.reload());
        assertCursor(reader,ts,increment,blob,0,null);
      }
       try (TableReader reader=new TableReader(configuration,"String_Node_Str")){
        Assert.assertFalse(reader.reload());
        assertCursor(reader,ts,increment,blob,0,null);
        Assert.assertFalse(reader.reload());
        long nextTs=testAppend(rnd,configuration,ts,count,increment,blob,0,BATCH1_GENERATOR);
        Assert.assertTrue(reader.reload());
        assertCursor(reader,ts,increment,blob,count,BATCH1_ASSERTER);
        try (TableReader reader2=new TableReader(configuration,"String_Node_Str")){
          assertCursor(reader2,ts,increment,blob,count,BATCH1_ASSERTER);
        }
         Assert.assertFalse(reader.reload());
        nextTs=testAppend(rnd,configuration,nextTs,count,increment,blob,testPartitionSwitch,BATCH1_GENERATOR);
        assertCursor(reader,ts,increment,blob,count,BATCH1_ASSERTER);
        Assert.assertTrue(reader.reload());
        assertCursor(reader,ts,increment,blob,2 * count,BATCH1_ASSERTER);
        try (TableWriter writer=new TableWriter(configuration,"String_Node_Str")){
          assertCursor(reader,ts,increment,blob,2 * count,BATCH1_ASSERTER);
          Assert.assertFalse(reader.reload());
          assertCursor(reader,ts,increment,blob,2 * count,BATCH1_ASSERTER);
          nextTs=testAppend(writer,rnd,nextTs,count,increment,blob,0,BATCH1_GENERATOR);
          Assert.assertTrue(reader.reload());
          assertCursor(reader,ts,increment,blob,3 * count,BATCH1_ASSERTER);
          writer.addColumn("String_Node_Str",ColumnType.STRING);
          nextTs=testAppend(writer,rnd,nextTs,count,increment,blob,0,BATCH2_GENERATOR);
          Assert.assertTrue(reader.reload());
          assertBatch2(count,increment,ts,blob,reader);
          writer.addColumn("String_Node_Str",ColumnType.INT);
          nextTs=testAppend(writer,rnd,nextTs,count,increment,blob,0,BATCH3_GENERATOR);
          Assert.assertTrue(reader.reload());
          assertBatch3(count,increment,ts,blob,reader);
          writer.addColumn("String_Node_Str",ColumnType.SHORT);
          writer.addColumn("String_Node_Str",ColumnType.BOOLEAN);
          writer.addColumn("String_Node_Str",ColumnType.BYTE);
          writer.addColumn("String_Node_Str",ColumnType.FLOAT);
          writer.addColumn("String_Node_Str",ColumnType.DOUBLE);
          writer.addColumn("String_Node_Str",ColumnType.SYMBOL);
          writer.addColumn("String_Node_Str",ColumnType.LONG);
          writer.addColumn("String_Node_Str",ColumnType.DATE);
          writer.addColumn("String_Node_Str",ColumnType.BINARY);
          nextTs=testAppend(writer,rnd,nextTs,count,increment,blob,0,BATCH4_GENERATOR);
          Assert.assertTrue(reader.reload());
          assertBatch4(count,increment,ts,blob,reader);
          if (Os.type == Os.WINDOWS) {
            reader.closeColumn("String_Node_Str");
          }
          writer.removeColumn("String_Node_Str");
          Assert.assertTrue(reader.reload());
          assertBatch5(count,increment,ts,blob,reader,new Rnd());
          testAppend(writer,rnd,nextTs,count,increment,blob,0,BATCH6_GENERATOR);
          Assert.assertTrue(reader.reload());
          assertBatch6(count,increment,ts,blob,reader);
          if (Os.type == Os.WINDOWS) {
            reader.closeColumn("String_Node_Str");
          }
          writer.removeColumn("String_Node_Str");
          writer.addColumn("String_Node_Str",ColumnType.INT);
          Assert.assertTrue(reader.reload());
          assertBatch7(count,increment,ts,blob,reader);
          Assert.assertFalse(reader.reload());
        }
       }
     }
  finally {
      freeBlob(blob);
    }
  }
);
}