GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PIP-135: Added Etcd MetadataStore implementation by merlimat · Pull Request #13225 · apache/pulsar

Conversation

@merlimat

@merlimat merlimat commented Dec 10, 2021

Copy link
Copy Markdown
Contributor

Motivation

Added a new MetadataStore implementation based on Etcd client.

The new implementation has all the feature as the ZK based backend:

  • Batching of read/write requests
  • Session watcher
  • Lease manager

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@merlimat
Added Etcd MetadataStore implementation
ec2796a
@merlimat merlimat added the type/feature The PR added a new feature or issue requested a new feature label Dec 10, 2021
@merlimat merlimat added this to the 2.10.0 milestone Dec 10, 2021
@merlimat
merlimat requested review from cckellogg, codelipenghui, hangc0276, jerrypeng, lhotari and rdhabalia December 10, 2021 02:48
@merlimat merlimat self-assigned this Dec 10, 2021
@github-actions github-actions Bot added the doc-label-missing label Dec 10, 2021
@merlimat merlimat added doc-required Your PR changes impact docs and you will update later. and removed doc-label-missing labels Dec 10, 2021
@apache apache deleted a comment from github-actions Bot Dec 10, 2021
Jason918
Jason918 reviewed Dec 10, 2021
View reviewed changes
Comment thread pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/EtcdMetadataStore.java
@Slf4j
public class EtcdMetadataStore extends AbstractBatchedMetadataStore {

static final String ETCD_SCHEME_IDENTIFIER = "etcd:";

@Jason918 Jason918 Dec 10, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Should it be "etcd://" to be consistent with other implementations ?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Dec 10, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I was considering that, though it kind of gets weird with url like etcd://http://my-service:2379. The current form of etcd:http://my-service:2379 seems a bit easier to see.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@codelipenghui codelipenghui Jan 19, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Shall we need to update the memory:// to "memory:" and "rocksdb://" to "rocksdb:"? It's better to make them consistent.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

merlimat reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/EtcdMetadataStore.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/EtcdMetadataStore.java
});

if (retryOnFailure) {
future.exceptionally(ex -> {

@Jason918 Jason918 Dec 10, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Should we return the future that only completes when retried success ?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/EtcdMetadataStore.java
// Re-create the lease before notifying that we are reconnected
createLease(true)
.thenRun(() -> {
super.receivedSessionEvent(event);

@Jason918 Jason918 Dec 10, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

If createLease failed the first time, the receivedSessionEvent will not be called.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Dec 10, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yes, that is intended.

The code here can certainly be refactored to make it easier. The intention here is:

  • At startup, we create the lease. If we fail, we bubble up the exception (eg: broker fails to start)
  • If we lose the lease while running, depending on the configuration we either kill the broker or try to reconnect.
  • When we don't kill the broker, we re-establish a new lease and we keep trying doing that indefinitely

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Jason918 Jason918 Dec 11, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

  • When we don't kill the broker, we re-establish a new lease and we keep trying doing that indefinitely

My point is, in this case, if we finally re-establish the new lease (after some retries), is it ok that we don't call super.receivedSessionEvent(event)? Current CompletableFuture returned by createLease only tracks the first try.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Dec 11, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

After reconnection, the receivedSessionEvent() will be called through the session watcher class.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Jason918 Jason918 Dec 11, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I see, thx~

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
merlimat added 5 commits December 10, 2021 09:52
@merlimat
Fixed license file
059a0b8
@merlimat
Addressed comments
8a797b3
@merlimat
Fixed sql plugin license
de1cd4b
@merlimat
Fixed parent notification of children changes
4067743
@merlimat
Fixed sequenetial keys with no parent
716d314
@eolivelli

eolivelli commented Dec 11, 2021

Copy link
Copy Markdown
Contributor

do we need a PIP here ? it is a big feature

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@merlimat

merlimat commented Dec 11, 2021

Copy link
Copy Markdown
Contributor Author

do we need a PIP here ? it is a big feature

If you discount the license files, it's 1 single file containing an implementation which is not enabled by default and which does not affect anything else.

I can create one.. but I don't see many design choices here to describe.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Jason918
Jason918 reviewed Dec 11, 2021
View reviewed changes
Comment thread pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/EtcdSessionWatcher.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/EtcdSessionWatcher.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/EtcdSessionWatcher.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/EtcdSessionWatcher.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@merlimat merlimat added the release/note-required label Dec 15, 2021
liangyuanpeng
liangyuanpeng approved these changes Jan 2, 2022
View reviewed changes
eolivelli
eolivelli reviewed Jan 2, 2022
View reviewed changes

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I believe that this will be a new feature that should be advertised and discussed on dev@
This is why I am thinking about starting a PIP.

I am pretty sure that no one will object to committing this patch, but for the benefit of the many folks in the community that are not following the github pull requests flow it is better to advertise about this work.

I will do my review when I wil be back form vacation (no need to wait for me, for sure)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
merlimat added 2 commits January 11, 2022 14:53
@merlimat
Merge remote-tracking branch 'apache/master' into etcd
6660110
@merlimat
Fixed checkstyle
0ad737a
@merlimat merlimat mentioned this pull request Jan 12, 2022
PIP-135: Include MetadataStore backend for Etcd #13717
Closed
@merlimat merlimat changed the title Added Etcd MetadataStore implementation PIP-135: Added Etcd MetadataStore implementation Jan 12, 2022
@sijie sijie mentioned this pull request Jan 12, 2022
ISSUE-13717: PIP-135: Include MetadataStore backend for Etcd streamnative/pulsar-archived#3552
Closed
merlimat added 2 commits January 11, 2022 16:32
@merlimat
Fixed presto license
bb7017e
@merlimat
Addressed comments
ac45e33
@momo-jun momo-jun mentioned this pull request Jan 19, 2022
[Doc] Add information for RocksDB and ETCD #13830
Merged
1 task done
codelipenghui
codelipenghui reviewed Jan 19, 2022
View reviewed changes
Comment thread pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/EtcdMetadataStore.java
@Slf4j
public class EtcdMetadataStore extends AbstractBatchedMetadataStore {

static final String ETCD_SCHEME_IDENTIFIER = "etcd:";

@codelipenghui codelipenghui Jan 19, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Shall we need to update the memory:// to "memory:" and "rocksdb://" to "rocksdb:"? It's better to make them consistent.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

merlimat reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/EtcdMetadataStore.java
}
}

private synchronized CompletableFuture<Void> createLease(boolean retryOnFailure) {

@codelipenghui codelipenghui Jan 19, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Does retryOnFailure is to retry in the background but the caller will get an exception?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Jan 19, 2022

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

No, this is after we created the lease the first time, so that we can re-create it in background. If we fail, we notify the session listener to change the current state and we keep retrying in background.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
codelipenghui
codelipenghui reviewed Jan 19, 2022
View reviewed changes
Comment thread pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/EtcdMetadataStore.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

merlimat added 2 commits January 19, 2022 10:09
@merlimat
Merge remote-tracking branch 'apache/master' into etcd
7a093d2
@merlimat
Fixed etcd test dependency
5d38cd3
@merlimat

merlimat commented Jan 19, 2022

Copy link
Copy Markdown
Contributor Author

Shall we need to update the memory:// to "memory:" and "rocksdb://" to "rocksdb:"? It's better to make them consistent.

Good point, we should do that in a different PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@merlimat
Updated the prefix for get children
404d664
Jason918
Jason918 reviewed Jan 20, 2022
View reviewed changes
Comment thread pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/EtcdMetadataStore.java Outdated
@Override
protected CompletableFuture<Boolean> existsFromStore(String path) {
return kv.get(ByteSequence.from(path, StandardCharsets.UTF_8), EXISTS_GET_OPTION)
.thenApply(gr -> gr.getCount() == 1);

@Jason918 Jason918 Jan 20, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Do we need to ensure the async callback is executed in metadata-store thread.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Jan 20, 2022

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

👍 Fixed it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
merlimat added 2 commits January 20, 2022 07:05
@merlimat
Fixed triggering futures from executor
b9b083b
@merlimat
ExceptionallyAsync is only available in java12
d2c5254
codelipenghui
codelipenghui approved these changes Jan 21, 2022
View reviewed changes
Jason918
Jason918 approved these changes Jan 21, 2022
View reviewed changes
@merlimat
Merge branch 'master' into etcd
bb83166
@merlimat
merlimat merged commit 1ad6e5b into apache:master Jan 21, 2022
@merlimat
merlimat deleted the etcd branch January 21, 2022 22:01
@Anonymitaet Anonymitaet added doc-complete Your PR changes impact docs and the related docs have been already added. and removed doc-required Your PR changes impact docs and you will update later. labels Jan 24, 2022
@codelipenghui codelipenghui mentioned this pull request Jan 25, 2022
Using the consistent metadata store scheme name. #13937
Merged
1 of 3 tasks
codelipenghui added a commit that referenced this pull request Jan 27, 2022
@codelipenghui
Using the consistent metadata store scheme name. (#13937)
2762f2d
Using the consistent metadata store scheme name.

- RocksDB -> rocksdb:
- ZooKeeper -> zk:
- Memory -> memory:
- Ectd -> etcd:

Context: #13225 (comment)
@codelipenghui codelipenghui mentioned this pull request Feb 15, 2022
Adding Ectd integration tests #14295
Closed
@sijie sijie mentioned this pull request Feb 15, 2022
ISSUE-14295: Adding Ectd integration tests streamnative/pulsar-archived#3752
Open
Nicklee007 pushed a commit to Nicklee007/pulsar that referenced this pull request Apr 20, 2022
@codelipenghui nicklixinyang
Using the consistent metadata store scheme name. (apache#13937)
ae30eae
Using the consistent metadata store scheme name.

- RocksDB -> rocksdb:
- ZooKeeper -> zk:
- Memory -> memory:
- Ectd -> etcd:

Context: apache#13225 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@eolivelli eolivelli eolivelli left review comments
@Jason918 Jason918 Jason918 approved these changes
@codelipenghui codelipenghui codelipenghui approved these changes
@lhotari lhotari Awaiting requested review from lhotari
@cckellogg cckellogg Awaiting requested review from cckellogg
@rdhabalia rdhabalia Awaiting requested review from rdhabalia
@jerrypeng jerrypeng Awaiting requested review from jerrypeng
@hangc0276 hangc0276 Awaiting requested review from hangc0276
+1 more reviewer
@liangyuanpeng liangyuanpeng liangyuanpeng approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@merlimat merlimat

Labels

doc-complete Your PR changes impact docs and the related docs have been already added. type/feature The PR added a new feature or issue requested a new feature

Projects

None yet

Milestone

2.10.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@merlimat @eolivelli @Jason918 @codelipenghui @liangyuanpeng @Anonymitaet
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.