@Test public void testAddColumnRepairFail2() throws Exception { class X extends FilesFacadeImpl { int counter = 2; @Override public long openRO(LPSZ name) { if (Chars.endsWith(name, TableUtils.META_FILE_NAME) && --counter == 0) { return -1L; } return super.openRO(name); } @Override public boolean rename(LPSZ from, LPSZ to) { return !Chars.endsWith(from, TableUtils.META_PREV_FILE_NAME) && super.rename(from, to); } } testAddColumnErrorFollowedByRepairFail(new X()); }
private int rename(int retries) { try { int index = 0; other.concat(META_PREV_FILE_NAME).$(); path.concat(META_FILE_NAME).$(); int l = other.length(); do { if (index > 0) { other.trimTo(l); other.put('.').put(index); other.$(); } if (ff.exists(other) && !ff.remove(other)) { LOG.info().$("cannot remove target of rename '").$(path).$("' to '").$(other).$(" [errno=").$(ff.errno()).$(']').$(); index++; continue; } if (!ff.rename(path, other)) { LOG.info().$("cannot rename '").$(path).$("' to '").$(other).$(" [errno=").$(ff.errno()).$(']').$(); index++; continue; } return index; } while (index < retries); throw CairoException.instance(0).put("Cannot rename ").put(path).put(". Max number of attempts reached [").put(index).put("]. Last target was: ").put(other); } finally { path.trimTo(rootLen); other.trimTo(rootLen); } }
TableWriter implements Closeable { private int rename(int retries) { try { int index = 0; other.concat(META_PREV_FILE_NAME).$(); path.concat(META_FILE_NAME).$(); int l = other.length(); do { if (index > 0) { other.trimTo(l); other.put('.').put(index); other.$(); } if (ff.exists(other) && !ff.remove(other)) { LOG.info().$("cannot remove target of rename '").$(path).$("' to '").$(other).$(" [errno=").$(ff.errno()).$(']').$(); index++; continue; } if (!ff.rename(path, other)) { LOG.info().$("cannot rename '").$(path).$("' to '").$(other).$(" [errno=").$(ff.errno()).$(']').$(); index++; continue; } return index; } while (index < retries); throw CairoException.instance(0).put("Cannot rename ").put(path).put(". Max number of attempts reached [").put(index).put("]. Last target was: ").put(other); } finally { path.trimTo(rootLen); other.trimTo(rootLen); } } }
TableWriter implements Closeable { private int rename(int retries) { try { int index = 0; other.concat(META_PREV_FILE_NAME).$(); path.concat(META_FILE_NAME).$(); int l = other.length(); do { if (index > 0) { other.trimTo(l); other.put('.').put(index); other.$(); } if (ff.exists(other) && !ff.remove(other)) { LOG.info().$("cannot remove target of rename '").$(path).$("' to '").$(other).$(" [errno=").$(ff.errno()).$(']').$(); index++; continue; } if (!ff.rename(path, other)) { LOG.info().$("cannot rename '").$(path).$("' to '").$(other).$(" [errno=").$(ff.errno()).$(']').$(); index++; continue; } return index; } while (index < retries); throw CairoException.instance(0).put("Cannot rename ").put(path).put(". Max number of attempts reached [").put(index).put("]. Last target was: ").put(other); } finally { path.trimTo(rootLen); other.trimTo(rootLen); } } TableWriter(CairoConfiguration configuration, CharSequence name);  TableWriter(CairoConfiguration configuration, CharSequence name, MessageBus messageBus);  TableWriter(
            CairoConfiguration configuration,
            CharSequence name,
            @Nullable MessageBus messageBus,
            boolean lock,
            LifecycleManager lifecycleManager
    );  TableWriter(
            CairoConfiguration configuration,
            CharSequence name,
            @Nullable MessageBus messageBus,
            boolean lock,
            LifecycleManager lifecycleManager,
            CharSequence root
    ); }
TableWriter implements Closeable { private int rename(int retries) { try { int index = 0; other.concat(META_PREV_FILE_NAME).$(); path.concat(META_FILE_NAME).$(); int l = other.length(); do { if (index > 0) { other.trimTo(l); other.put('.').put(index); other.$(); } if (ff.exists(other) && !ff.remove(other)) { LOG.info().$("cannot remove target of rename '").$(path).$("' to '").$(other).$(" [errno=").$(ff.errno()).$(']').$(); index++; continue; } if (!ff.rename(path, other)) { LOG.info().$("cannot rename '").$(path).$("' to '").$(other).$(" [errno=").$(ff.errno()).$(']').$(); index++; continue; } return index; } while (index < retries); throw CairoException.instance(0).put("Cannot rename ").put(path).put(". Max number of attempts reached [").put(index).put("]. Last target was: ").put(other); } finally { path.trimTo(rootLen); other.trimTo(rootLen); } } TableWriter(CairoConfiguration configuration, CharSequence name);  TableWriter(CairoConfiguration configuration, CharSequence name, MessageBus messageBus);  TableWriter(
            CairoConfiguration configuration,
            CharSequence name,
            @Nullable MessageBus messageBus,
            boolean lock,
            LifecycleManager lifecycleManager
    );  TableWriter(
            CairoConfiguration configuration,
            CharSequence name,
            @Nullable MessageBus messageBus,
            boolean lock,
            LifecycleManager lifecycleManager,
            CharSequence root
    ); static TimestampFormat selectPartitionDirFmt(int partitionBy); void addColumn(CharSequence name, int type); void addColumn(
            CharSequence name,
            int type,
            int symbolCapacity,
            boolean symbolCacheFlag,
            boolean isIndexed,
            int indexValueBlockCapacity,
            boolean isSequential
    ); void addIndex(CharSequence columnName, int indexValueBlockSize); void changeCacheFlag(int columnIndex, boolean cache); @Override void close(); void commit(); void commit(int commitMode); int getColumnIndex(CharSequence name); long getMaxTimestamp(); RecordMetadata getMetadata(); CharSequence getName(); int getPartitionBy(); long getStructureVersion(); boolean inTransaction(); boolean isOpen(); Row newRow(long timestamp); Row newRow(); long partitionNameToTimestamp(CharSequence partitionName); void removeColumn(CharSequence name); void renameColumn(CharSequence currentName, CharSequence newName); boolean removePartition(long timestamp); void rollback(); void setLifecycleManager(LifecycleManager lifecycleManager); long size(); @Override String toString(); void transferLock(long lockFd); final void truncate(); void updateMetadataVersion(); void warmUp(); }
TableWriter implements Closeable { private int rename(int retries) { try { int index = 0; other.concat(META_PREV_FILE_NAME).$(); path.concat(META_FILE_NAME).$(); int l = other.length(); do { if (index > 0) { other.trimTo(l); other.put('.').put(index); other.$(); } if (ff.exists(other) && !ff.remove(other)) { LOG.info().$("cannot remove target of rename '").$(path).$("' to '").$(other).$(" [errno=").$(ff.errno()).$(']').$(); index++; continue; } if (!ff.rename(path, other)) { LOG.info().$("cannot rename '").$(path).$("' to '").$(other).$(" [errno=").$(ff.errno()).$(']').$(); index++; continue; } return index; } while (index < retries); throw CairoException.instance(0).put("Cannot rename ").put(path).put(". Max number of attempts reached [").put(index).put("]. Last target was: ").put(other); } finally { path.trimTo(rootLen); other.trimTo(rootLen); } } TableWriter(CairoConfiguration configuration, CharSequence name);  TableWriter(CairoConfiguration configuration, CharSequence name, MessageBus messageBus);  TableWriter(
            CairoConfiguration configuration,
            CharSequence name,
            @Nullable MessageBus messageBus,
            boolean lock,
            LifecycleManager lifecycleManager
    );  TableWriter(
            CairoConfiguration configuration,
            CharSequence name,
            @Nullable MessageBus messageBus,
            boolean lock,
            LifecycleManager lifecycleManager,
            CharSequence root
    ); static TimestampFormat selectPartitionDirFmt(int partitionBy); void addColumn(CharSequence name, int type); void addColumn(
            CharSequence name,
            int type,
            int symbolCapacity,
            boolean symbolCacheFlag,
            boolean isIndexed,
            int indexValueBlockCapacity,
            boolean isSequential
    ); void addIndex(CharSequence columnName, int indexValueBlockSize); void changeCacheFlag(int columnIndex, boolean cache); @Override void close(); void commit(); void commit(int commitMode); int getColumnIndex(CharSequence name); long getMaxTimestamp(); RecordMetadata getMetadata(); CharSequence getName(); int getPartitionBy(); long getStructureVersion(); boolean inTransaction(); boolean isOpen(); Row newRow(long timestamp); Row newRow(); long partitionNameToTimestamp(CharSequence partitionName); void removeColumn(CharSequence name); void renameColumn(CharSequence currentName, CharSequence newName); boolean removePartition(long timestamp); void rollback(); void setLifecycleManager(LifecycleManager lifecycleManager); long size(); @Override String toString(); void transferLock(long lockFd); final void truncate(); void updateMetadataVersion(); void warmUp();  }