bookkeeper icon indicating copy to clipboard operation
bookkeeper copied to clipboard

[Bug] LedgerManagerFactory Info storing in LAYOUT znode is not correct

Open Reidddddd opened this issue 2 years ago • 0 comments

BUG REPORT

Describe the bug

I configured the serviceURL with zk+longhierarchical which means using LongHierarchicalLedgerManager.

But after executing shell metaformat, in the LAYOUT znode is HierarchicalLedgerManager in fact.

To Reproduce

Here is a UT to reproduce:

    @Test
    public void testFormat() throws Exception {
        File tmpDir = tmpDirs.createNew("bookie", "test");
        final String zkRoot = "/ledgers3";

        final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
            .setJournalDirName(tmpDir.getPath())
            .setLedgerDirNames(new String[] { tmpDir.getPath() })
            .setMetadataServiceUri(zkUtil.getMetadataServiceUri(zkRoot, "longhierarchical"))
            .setZkTimeout(5000);

        BookKeeperAdmin.format(conf, false, false);
        BookKeeperAdmin.format(conf, false, true); // need to set force true
    }

The second time will fail with exception:

Caused by: java.io.IOException: Configured layout org.apache.bookkeeper.meta.LongHierarchicalLedgerManagerFactory does not match existing layout org.apache.bookkeeper.meta.HierarchicalLedgerManagerFactory
	at org.apache.bookkeeper.meta.AbstractZkLedgerManagerFactory.newLedgerManagerFactory(AbstractZkLedgerManagerFactory.java:220)
	at org.apache.bookkeeper.meta.zk.ZKMetadataDriverBase.getLedgerManagerFactory(ZKMetadataDriverBase.java:263)
	... 21 more

Expected behavior

LedgerManagerFactory Info storing in the LAYOUT node should be exactly the same as configuration

And no matter how many time format execution, all should be successful with same configuration

Screenshots

N/A

Additional context

N/A

Reidddddd avatar Oct 03 '23 07:10 Reidddddd