Repository navigation
[CELEBORN-2577] Fix FsConfigServiceImpl#refreshCache publishing partially built dynamic config caches - #3984
HanShuhang wants to merge 2 commits into
Conversation
zaynt4606
left a comment
There was a problem hiding this comment.
Thanks for fixing the publication of partially built tenant maps. I reproduced two regressions in the filesystem refresh path, noted inline.
Could you also narrow the snapshot guarantee in the PR description? Each tenant map is fully built before publication, but the three references are swapped separately and TenantConfig still resolves its parent through the current cache. A user config obtained before a refresh can therefore inherit a value from the next refresh. This behavior also exists on the base commit and can be tracked separately.
Since the fix affects the production refresh path, could you link a Bug-type CELEBORN JIRA and use its key in place of [MINOR]?
| @Override | ||
| public synchronized void refreshCache() { | ||
| try (FileInputStream fileInputStream = new FileInputStream(getConfigFile(System.getenv()))) { | ||
| SystemConfig systemConfig = new SystemConfig(celebornConf); |
There was a problem hiding this comment.
[P2] Preserve safe tag lookup after a refresh that omits SYSTEM.tags.
When a file that previously defined tags is replaced by a valid SYSTEM entry with config only, the old code keeps the current tags. The new SystemConfig leaves getTags() null. TagsManager.getTagStore passes that value straight to JavaUtils.newConcurrentHashMap, so a request with a nonempty tag expression can now fail with NullPointerException. I reproduced the map copy succeeding on the base commit and failing after the same refresh on this revision.
Could we preserve the existing behavior for omitted tags? If omission is intended to clear tags, please make the lookup use an empty map and cover refresh from populated tags to no tags.
There was a problem hiding this comment.
I fixed it by keeping the previous tags when the SYSTEM record doesn't define tags, and by initializing the tag map in SystemConfig so getTags() can't return null. An explicit [] still clears tags to an empty map. Added a test thatrefreshes from a file with tags to one without and checks the tags are still there.
| tenantUserConfigAtomicReference.set(tenantUserConfigs); | ||
| } | ||
| // Publish only after every record has been parsed; readers must not see maps being built. | ||
| systemConfigAtomicReference.set(systemConfig); |
There was a problem hiding this comment.
[P2] Keep the previous system config when the input contains an unrecognized record.
A YAML record with a misspelled level: SYSETM and no tenantId parses successfully and is skipped by the loop. Publishing the new empty SystemConfig then discards the previous system settings and tags while the refresh reports success. On the base commit the system settings and tags survive the same input. The current failure test exercises a type error that throws, so it does not catch a record that is silently ignored.
Could we distinguish a deliberately empty list ([]) from an unrecognized record and reject the latter before publishing any of the new caches?
There was a problem hiding this comment.
You're right, that was a behavior change I introduced. The file is now validated before anything is published: an unknown level, or a TENANT record without tenantId, makes refresh throw and leaves the previous caches untouched. []is still how you clear everything.
…ally built dynamic config caches
a69b684 to
2e2112a
Compare
Thanks for the review. I reworded the description so it only claims that each map is complete before publication, not that the whole refresh is one atomic snapshot. I created CELEBORN-2577 (Bug) and retitled the PR. The two inline issues were real regressions. Both are fixed in the latest push. Details are in the threads. |
What changes were proposed in this pull request?
FsConfigServiceImpl#refreshCachewas settingtenantConfigAtomicReferenceandtenantUserConfigAtomicReferenceinside the parsing loop. Those are the sameHashMaps the loop is still filling, so another thread could read anempty or half-built tenant cache while the refresh was in progress. When that happened,DynamicConfig#getValuewould fall through to the system-level config or the staticCelebornConfdefault and return a different value thanwhat's indynamicConfig.yaml.Now the file is parsed and validated first, and the three caches are published once at the end. The three refs are still swapped separately and
TenantConfigstill resolves its parent through the live cache. That's pre-existing, so it's out of scope here.Two things I had to fix along the way:
SYSTEMrecord doesn't havetags, the newSystemConfigused to end up with a null tag map.TagsManager.getTagStorepasses that straight intoJavaUtils.newConcurrentHashMap, so tag lookup would NPE. It now keeps theprevious tags, andgetTags()never returns null.level: SYSETMused to be silently skipped, but the new snapshot would then wipe the previous system config and tags. The file is now validated before anything is published, so an unknown level or aTENANTrecordwithouttenantIdfails the refresh and leaves the old caches alone.[]is still the explicit way to clear everything.Why are the changes needed?
While
dynamicConfig.yamlis being reloaded, a master/worker thread can read an empty or partially built tenant cache and fall back to the system-level or static config, so it may end up loading the wrong config value.ConfigServiceSuiteJ#testFsConfigis flaky for the same reason.Does this PR resolve a correctness bug?
Does this PR introduce any user-facing change?
How was this patch tested?
mvn -pl service test -Dtest=ConfigServiceSuiteJmvn spotless:check