Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pulsar-sql]Using pulsar SQL query messages will appear `NoSuchLedger… #9910

Merged
merged 5 commits into from
Mar 24, 2021

Conversation

sakurafly123
Copy link
Contributor

@sakurafly123 sakurafly123 commented Mar 16, 2021

…` when zk root directory changed #9847

Fixes #9847

Motivation

When zookeeper ledgers root path is changed, using pulsar-sql to query messages will cause BKNoSuchLedgerExistsException.

Modifications

To use new DefaultBkFactory(clientConfiguration),so that zk will be null in Bookeeper constructor;(Bookeeper.java row 113)
when metadataDriver will be initialized(Bookeeper.java row 167),zookeeper conection is null; we can jump to another branch.If we have done the above steps,
finally, zkServers will be localhost:2181 rather than localhost:2181/pulsar in row 168(ZKMetadataDriverBase.java); the path that we use to get ledger is localhost:2181/pulsar/ledger/00/0000/L0001 rather than localhost:2181/pulsar/pulsar/ledger/00/0000/L0001;

…` when zk root directory changed (apache#2258)

Fixes apache#2258

*Motivation*

When zookeeper ledgers root path is changed, using pulsar-sql to query messages will cause `BKNoSuchLedgerExistsException`.

*Modifications*

To use new DefaultBkFactory(clientConfiguration),so that zk will be null in Bookeeper constructor;(Bookeeper.java row 113)
when metadataDriver will be initialized(Bookeeper.java row 167),zookeeper conection is null; we can jump to another  branch.If we have done the above steps,
finally, zkServers will be localhost:2181 rather than localhost:2181/pulsar in row 168(ZKMetadataDriverBase.java); the path that we use to get ledger is localhost:2181/pulsar/ledger/00/0000/L0001 rather than localhost:2181/pulsar/pulsar/ledger/00/0000/L0001;
Copy link
Contributor

@codelipenghui codelipenghui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please help add a test to cover this change?

And, I think it needs to rebase to the current master branch to get CI works.

919364728@qq.com added 4 commits March 16, 2021 10:42
…` when zk root directory changed (apache#2258)

Fixes apache#2258

*Motivation*

When zookeeper ledgers root path is changed, using pulsar-sql to query messages will cause `BKNoSuchLedgerExistsException`.

*Modifications*

To use new DefaultBkFactory(clientConfiguration),so that zk will be null in Bookeeper constructor;(Bookeeper.java row 113)
when metadataDriver will be initialized(Bookeeper.java row 167),zookeeper conection is null; we can jump to another  branch.If we have done the above steps,
finally, zkServers will be localhost:2181 rather than localhost:2181/pulsar in row 168(ZKMetadataDriverBase.java); the path that we use to get ledger is localhost:2181/pulsar/ledger/00/0000/L0001 rather than localhost:2181/pulsar/pulsar/ledger/00/0000/L0001;
…` when zk root directory changed (apache#2258)

Fixes apache#2258

*Motivation*

When zookeeper ledgers root path is changed, using pulsar-sql to query messages will cause `BKNoSuchLedgerExistsException`.

*Modifications*

To use new DefaultBkFactory(clientConfiguration),so that zk will be null in Bookeeper constructor;(Bookeeper.java row 113)
when metadataDriver will be initialized(Bookeeper.java row 167),zookeeper conection is null; we can jump to another  branch.If we have done the above steps,
finally, zkServers will be localhost:2181 rather than localhost:2181/pulsar in row 168(ZKMetadataDriverBase.java); the path that we use to get ledger is localhost:2181/pulsar/ledger/00/0000/L0001 rather than localhost:2181/pulsar/pulsar/ledger/00/0000/L0001;
@jiazhai
Copy link
Member

jiazhai commented Mar 16, 2021

@gaoran10 Would you please also help review this PR?

@@ -145,7 +145,7 @@ private ManagedLedgerFactoryImpl(ZooKeeper zkc, ClientConfiguration bkClientConf
zkc, config, NullStatsLogger.INSTANCE);
}

private ManagedLedgerFactoryImpl(ClientConfiguration clientConfiguration, String zkConnection, ManagedLedgerFactoryConfig config) throws Exception {
public ManagedLedgerFactoryImpl(ClientConfiguration clientConfiguration, String zkConnection, ManagedLedgerFactoryConfig config) throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add support for creating ManagerLedgerFactoryImpl with a Builder?
It is a code smell to add new public constructors.

WDYT?
Cc @codelipenghui

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can create a builder for the ManagerLedgerFactoryImpl, we can do that in a separate PR I think.

Copy link
Contributor

@gaoran10 gaoran10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

Add some context, the PR #5001 fixed this problem, but the PR #5702 introduce the problem again.

@@ -112,7 +112,7 @@ private static ManagedLedgerFactory initManagedLedgerFactory(PulsarConnectorConf
pulsarConnectorConfig.getManagedLedgerNumWorkerThreads());
managedLedgerFactoryConfig.setNumManagedLedgerSchedulerThreads(
pulsarConnectorConfig.getManagedLedgerNumSchedulerThreads());
return new ManagedLedgerFactoryImpl(bkClientConfiguration, managedLedgerFactoryConfig);
return new ManagedLedgerFactoryImpl(bkClientConfiguration, pulsarConnectorConfig.getZookeeperUri(),managedLedgerFactoryConfig);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code .setZkServers(pulsarConnectorConfig.getZookeeperUri()) could be removed in line 97.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code .setZkServers(pulsarConnectorConfig.getZookeeperUri()) could be removed in line 97.

please don't remove it; it 's very essentia for us to get manage-ledger info(/managed-ledger/) or get cursor info because it need zk root path(); Only when we create bookkeeper, we don't need ZK root path;ZK root path will be auto created in bookeeper by metadataServiceUri(project bookkeeper AbstractZkLedgerManager.java row 169)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setZKServers is diffrent from setMetadataServiceUri,we need both

Copy link
Contributor

@gaoran10 gaoran10 Mar 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ClientConfiguration bkClientConfiguration is used to generate the bookkeeper, the MetadataServiceUri is enough, we don't need to set the ZkServers and the method setZkServers is deprecated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes,you are right.;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before i revise it,it is neccessary to create metadatastore(ManagedLedgerFacoryImpl.java row 199);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ClientConfiguration bkClientConfiguration is used to generate the bookkeeper, the MetadataServiceUri is enough, we don't need to set the ZkServers and the method setZkServers is deprecated.

today,i found it's neccessay to setZkServers .when broker's zk Path is diffrent from bookies's zk Path.

@315157973
Copy link
Contributor

/pulsarbot run-failure-checks

@@ -145,7 +145,7 @@ private ManagedLedgerFactoryImpl(ZooKeeper zkc, ClientConfiguration bkClientConf
zkc, config, NullStatsLogger.INSTANCE);
}

private ManagedLedgerFactoryImpl(ClientConfiguration clientConfiguration, String zkConnection, ManagedLedgerFactoryConfig config) throws Exception {
public ManagedLedgerFactoryImpl(ClientConfiguration clientConfiguration, String zkConnection, ManagedLedgerFactoryConfig config) throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can create a builder for the ManagerLedgerFactoryImpl, we can do that in a separate PR I think.

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@eolivelli eolivelli merged commit b1ba8e5 into apache:master Mar 24, 2021
@codelipenghui codelipenghui added the cherry-picked/branch-2.7 Archived: 2.7 is end of life label Mar 30, 2021
codelipenghui pushed a commit that referenced this pull request Mar 30, 2021
#9910)

* [Pulsar-sql]Using pulsar SQL query messages will appear `NoSuchLedger` when zk root directory changed (#2258)

Fixes #2258

*Motivation*

When zookeeper ledgers root path is changed, using pulsar-sql to query messages will cause `BKNoSuchLedgerExistsException`.

*Modifications*

To use new DefaultBkFactory(clientConfiguration),so that zk will be null in Bookeeper constructor;(Bookeeper.java row 113)
when metadataDriver will be initialized(Bookeeper.java row 167),zookeeper conection is null; we can jump to another  branch.If we have done the above steps,
finally, zkServers will be localhost:2181 rather than localhost:2181/pulsar in row 168(ZKMetadataDriverBase.java); the path that we use to get ledger is localhost:2181/pulsar/ledger/00/0000/L0001 rather than localhost:2181/pulsar/pulsar/ledger/00/0000/L0001;

* [Pulsar-sql]Using pulsar SQL query messages will appear `NoSuchLedger` when zk root directory changed (#2258)

Fixes #2258

*Motivation*

When zookeeper ledgers root path is changed, using pulsar-sql to query messages will cause `BKNoSuchLedgerExistsException`.

*Modifications*

To use new DefaultBkFactory(clientConfiguration),so that zk will be null in Bookeeper constructor;(Bookeeper.java row 113)
when metadataDriver will be initialized(Bookeeper.java row 167),zookeeper conection is null; we can jump to another  branch.If we have done the above steps,
finally, zkServers will be localhost:2181 rather than localhost:2181/pulsar in row 168(ZKMetadataDriverBase.java); the path that we use to get ledger is localhost:2181/pulsar/ledger/00/0000/L0001 rather than localhost:2181/pulsar/pulsar/ledger/00/0000/L0001;

* [Pulsar-sql]Using pulsar SQL query messages will appear `NoSuchLedger` when zk root directory changed (#2258)

Fixes #2258

*Motivation*

When zookeeper ledgers root path is changed, using pulsar-sql to query messages will cause `BKNoSuchLedgerExistsException`.

*Modifications*

To use new DefaultBkFactory(clientConfiguration),so that zk will be null in Bookeeper constructor;(Bookeeper.java row 113)
when metadataDriver will be initialized(Bookeeper.java row 167),zookeeper conection is null; we can jump to another  branch.If we have done the above steps,
finally, zkServers will be localhost:2181 rather than localhost:2181/pulsar in row 168(ZKMetadataDriverBase.java); the path that we use to get ledger is localhost:2181/pulsar/ledger/00/0000/L0001 rather than localhost:2181/pulsar/pulsar/ledger/00/0000/L0001;

Co-authored-by: 919364728@qq.com <1314520Ljq-->
(cherry picked from commit b1ba8e5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sql Pulsar SQL related features cherry-picked/branch-2.7 Archived: 2.7 is end of life release/2.7.2
Projects
None yet
6 participants