-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[metadata-store] Fix metadata cache inconsistency on doing refresh #14283
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
Merged
lhotari
merged 1 commit into
apache:master
from
Demogorgon314:fix/make-metadata-cache-refresh-async
Feb 15, 2022
Merged
[metadata-store] Fix metadata cache inconsistency on doing refresh #14283
lhotari
merged 1 commit into
apache:master
from
Demogorgon314:fix/make-metadata-cache-refresh-async
Feb 15, 2022
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
merlimat
reviewed
Feb 15, 2022
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/api/MetadataStoreConfig.java
Outdated
Show resolved
Hide resolved
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/api/MetadataStore.java
Outdated
Show resolved
Hide resolved
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/api/Notifiable.java
Outdated
Show resolved
Hide resolved
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/cache/impl/MetadataCacheImpl.java
Outdated
Show resolved
Hide resolved
ben-manes
reviewed
Feb 15, 2022
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/cache/impl/MetadataCacheImpl.java
Outdated
Show resolved
Hide resolved
a71692d to
ab6ef2b
Compare
codelipenghui
approved these changes
Feb 15, 2022
hangc0276
approved these changes
Feb 15, 2022
eolivelli
approved these changes
Feb 15, 2022
lhotari
approved these changes
Feb 15, 2022
Contributor
|
@Demogorgon314 I still get test error: https://github.com/apache/pulsar/runs/5231565908?check_suite_focus=true |
Member
Author
I'll push a PR to fix it. |
Member
Author
|
@gaozhangmin PTAL #14354 : ) |
Nicklee007
pushed a commit
to Nicklee007/pulsar
that referenced
this pull request
Apr 20, 2022
This was referenced Apr 20, 2022
Open
congbobo184
pushed a commit
to congbobo184/pulsar
that referenced
this pull request
Nov 9, 2022
(cherry picked from commit 2e16b43)
congbobo184
pushed a commit
that referenced
this pull request
Nov 9, 2022
(cherry picked from commit 2e16b43)
congbobo184
pushed a commit
that referenced
this pull request
Nov 26, 2022
(cherry picked from commit 2e16b43)
15 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
cherry-picked/branch-2.9
Archived: 2.9 is end of life
doc-not-needed
Your PR changes do not impact docs
release/blocker
Indicate the PR or issue that should block the release until it gets resolved
release/2.9.4
type/bug
The PR fixed a bug or issue reported a bug
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.
Fixes #14110 #14096 #14219
Motivation
Currently, the metadata cache refresh has race condition.
The main reason is
MetadataCacheImpl#refreshis not atomic operations.I added some log in MetadataCacheImpl in order to observe:
Cache inconsistency, you can see the async load for objCache complete in mid of refresh :
2022-02-15T08:33:06,669+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@272 - 1. Refresh path /key-33552641536875 {} 2022-02-15T08:33:06,669+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@279 - 0. Skip Refresh path /key-33552641536875 {} 2022-02-15T08:33:06,669+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@80 - Async load for objCache /key-33552641536875 {} 2022-02-15T08:33:06,669+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@84 - Async load for objCache complete /key-33552641536875 - CacheGetResult(value=MetadataCacheTest.MyClass(a=a, b=1), stat=Stat(path=/key-33552641536875, version=0, creationTimestamp=1644885186668, modificationTimestamp=1644885186668, ephemeral=false, createdBySelf=true)) {} 2022-02-15T08:33:06,669+0800 INFO [metadata-store-2437-1] o.a.p.m.c.i.MetadataCacheImpl@272 - 1. Refresh path /key-33552641536875 {} 2022-02-15T08:33:06,669+0800 INFO [metadata-store-2437-1] o.a.p.m.c.i.MetadataCacheImpl@80 - Async load for objCache /key-33552641536875 {} 2022-02-15T08:33:06,670+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@272 - 1. Refresh path /key-33552641536875 {} 2022-02-15T08:33:06,670+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@279 - 0. Skip Refresh path /key-33552641536875 {} 2022-02-15T08:33:06,670+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@272 - 1. Refresh path /key-33552641536875 {} 2022-02-15T08:33:06,670+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@279 - 0. Skip Refresh path /key-33552641536875 {} 2022-02-15T08:33:06,671+0800 INFO [metadata-store-2437-1] o.a.p.m.c.i.MetadataCacheImpl@84 - Async load for objCache complete /key-33552641536875 - CacheGetResult(value=MetadataCacheTest.MyClass(a=a, b=1), stat=Stat(path=/key-33552641536875, version=0, creationTimestamp=1644885186668, modificationTimestamp=1644885186668, ephemeral=false, createdBySelf=true)) {} 2022-02-15T08:33:06,671+0800 INFO [metadata-store-2437-1] o.a.p.m.c.i.MetadataCacheImpl@277 - 2. Refresh path complete /key-33552641536875:MetadataCacheTest.MyClass(a=a, b=1) {} 2022-02-15T08:33:06,671+0800 INFO [metadata-store-2437-1] o.a.p.m.c.i.MetadataCacheImpl@272 - 1. Refresh path /key-33552641536875 {} 2022-02-15T08:33:06,671+0800 INFO [metadata-store-2437-1] o.a.p.m.c.i.MetadataCacheImpl@80 - Async load for objCache /key-33552641536875 {} 2022-02-15T08:33:06,671+0800 INFO [metadata-store-2437-1] o.a.p.m.c.i.MetadataCacheImpl@84 - Async load for objCache complete /key-33552641536875 - CacheGetResult(value=MetadataCacheTest.MyClass(a=a, b=2), stat=Stat(path=/key-33552641536875, version=1, creationTimestamp=1644885186668, modificationTimestamp=1644885186669, ephemeral=false, createdBySelf=true)) {} 2022-02-15T08:33:06,671+0800 INFO [metadata-store-2437-1] o.a.p.m.c.i.MetadataCacheImpl@277 - 2. Refresh path complete /key-33552641536875:MetadataCacheTest.MyClass(a=a, b=2) {}Correct log:
2022-02-15T08:33:06,659+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@272 - 1. Refresh path /key-33552632155000 {} 2022-02-15T08:33:06,659+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@279 - 0. Skip Refresh path /key-33552632155000 {} 2022-02-15T08:33:06,659+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@80 - Async load for objCache /key-33552632155000 {} 2022-02-15T08:33:06,659+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@84 - Async load for objCache complete /key-33552632155000 - CacheGetResult(value=MetadataCacheTest.MyClass(a=a, b=1), stat=Stat(path=/key-33552632155000, version=0, creationTimestamp=1644885186659, modificationTimestamp=1644885186659, ephemeral=false, createdBySelf=true)) {} 2022-02-15T08:33:06,661+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@272 - 1. Refresh path /key-33552632155000 {} 2022-02-15T08:33:06,661+0800 INFO [metadata-store-2436-1] o.a.p.m.c.i.MetadataCacheImpl@272 - 1. Refresh path /key-33552632155000 {} 2022-02-15T08:33:06,661+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@80 - Async load for objCache /key-33552632155000 {} 2022-02-15T08:33:06,661+0800 INFO [metadata-store-2436-1] o.a.p.m.c.i.MetadataCacheImpl@279 - 0. Skip Refresh path /key-33552632155000 {} 2022-02-15T08:33:06,661+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@84 - Async load for objCache complete /key-33552632155000 - CacheGetResult(value=MetadataCacheTest.MyClass(a=a, b=2), stat=Stat(path=/key-33552632155000, version=1, creationTimestamp=1644885186659, modificationTimestamp=1644885186659, ephemeral=false, createdBySelf=true)) {} 2022-02-15T08:33:06,661+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@277 - 2. Refresh path complete /key-33552632155000:MetadataCacheTest.MyClass(a=a, b=2) {} 2022-02-15T08:33:06,661+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@272 - 1. Refresh path /key-33552632155000 {} 2022-02-15T08:33:06,661+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@80 - Async load for objCache /key-33552632155000 {} 2022-02-15T08:33:06,661+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@84 - Async load for objCache complete /key-33552632155000 - CacheGetResult(value=MetadataCacheTest.MyClass(a=a, b=2), stat=Stat(path=/key-33552632155000, version=1, creationTimestamp=1644885186659, modificationTimestamp=1644885186659, ephemeral=false, createdBySelf=true)) {} 2022-02-15T08:33:06,661+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@277 - 2. Refresh path complete /key-33552632155000:MetadataCacheTest.MyClass(a=a, b=2) {} 2022-02-15T08:33:06,662+0800 INFO [main] o.a.p.m.c.i.MetadataCacheImpl@80 - Async load for objCache /key-33552635148375 {}Modifications
Make metadata cache refresh method atomic.
Verifying this change
Documentation
Need to update docs?
no-need-doc