[metadata-store] Fix metadata cache inconsistency on doing refresh - #14283
Merged
lhotari merged 1 commit intoFeb 15, 2022
Merged
Conversation
merlimat
reviewed
Feb 15, 2022
ben-manes
reviewed
Feb 15, 2022
Demogorgon314
force-pushed
the
fix/make-metadata-cache-refresh-async
branch
from
February 15, 2022 08:16
a71692d to
ab6ef2b
Compare
Demogorgon314
marked this pull request as ready for review
February 15, 2022 09:18
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
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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