Skip to content

Commit

Permalink
Stable testBookieContinueWritingIfMultipleLedgersPresent test (apache…
Browse files Browse the repository at this point in the history
…#3421)

Fixes issue apache#2665

When the disk is full, `InterleavedLedgerStorage` creates a new entryLog and index file, copies and moves the old index (newFile) `FileInfo` to the new directory, and finally deletes the old index file.

The old file of `FileInfo` was `deleted`, but it was copied and moved a newFile to the new directory. Therefore, the delete status flag should be restored. If it is not set to false,`checkOpen` will throw `FileInfoDeletedException` when judging the fence status of `ledgerHandle` when adding an entry, causing the writing to fail. When the client changes the `ensemble`, it throws an exception because the test has only two bookie nodes and cannot satisfy the two writeSet: `Not enough non-faulty bookies available`.
```java
    public synchronized boolean isFenced() throws IOException {
        checkOpen(false);
        return (stateBits & STATE_FENCED_BIT) == STATE_FENCED_BIT;
    }

    private synchronized void checkOpen(boolean create, boolean openBeforeClose)
            throws IOException {
        if (deleted) {
            throw new FileInfoDeletedException();
        }
      .....
    }
```

When `FileInfo` moves to a new directory by `moveToNewLocation`,delete the old index file and restore the `delete` flag, because the new index file is ready.

Set the disk check interval to the `Integer.MAX_VALUE`, which is stable
`assertEquals("writable dirs should have one dir", 1, ledgerDirsManager
                .getWritableLedgerDirs().size());`
Because once the test thrashes, the disk check thread will restore the full disk to a writable state.
```java
newConf.setDiskCheckInterval(Integer.MAX_VALUE);
```

(cherry picked from commit 1908b7e)
(cherry picked from commit da532fc)
  • Loading branch information
wenbingshen authored and nicoloboschi committed Jan 11, 2023
1 parent e1744fc commit 22892a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ public synchronized void moveToNewLocation(File newFile, long size) throws IOExc
}
fc = new RandomAccessFile(newFile, mode).getChannel();
lf = newFile;
deleted = false;
}

public synchronized byte[] getMasterKey() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ private void startNewBookieWithMultipleLedgerDirs(int numOfLedgerDirs)
ServerConfiguration newConf = newServerConfiguration(
PortManager.nextFreePort(),
ledgerDirs[0], ledgerDirs);

newConf.setDiskCheckInterval(Integer.MAX_VALUE);
bsConfs.add(newConf);
bs.add(startBookie(newConf));
}
Expand Down

0 comments on commit 22892a3

Please sign in to comment.