apache / apache/bookkeeper

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

Open
#4,094 0 comments 0 reactions 0 assignees View on GitHub
type/bug
Dominant language
Java
Stars
2k
Forks
976
Avg merge
6d 15h
Merged PRs (30d)
7

Description

**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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.