GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — [fix][broker] Don't let the leader's bundle-data write recreate the data of a bundle it just removed by merlimat · Pull Request #27521 · apache/pulsar Conversation
Contributor
Motivation
The second assertion is the one that fails. The split bundle is gone from the leader's With
public void writeBundleDataOnZooKeeper() { ... updateBundleData(); ... synchronized (bundleArr) { int updateBundleCount = selectTopKBundle(); // collects the bundles from loadData.getBundleData() for (Map.Entry<String, ? extends Comparable> entry : bundleArr.subList(0, updateBundleCount)) { ... futures.add(pulsarResources.getLoadBalanceResources().getBundleDataResources().updateBundleData( entry.getKey(), (BundleData) entry.getValue())); } } ... FutureUtil.waitForAll(futures).join(); } private void updateBundleData() { ... // Remove not active bundle from loadData for (String bundle : bundleData.keySet()) { if (!activeBundles.contains(bundle)){ bundleData.remove(bundle); if (isLeader()) { deleteBundleDataFromMetadataStore(bundle); } } } } Suppose a write collects a bundle before the leader learns that the bundle is gone. If The test splits a bundle. Then, one right after the other, it writes the new load report and calls pulsar.getNamespaceService().splitAndOwnBundle(oldBundle, false, NamespaceBundleSplitAlgorithm.RANGE_EQUALLY_DIVIDE_ALGO, null).get(); // update broker bundle report to zk pulsar.getBrokerService().updateRates(); loadManager.writeLoadReportOnZookeeper(); // -> notification -> updateAll() on pulsar-modular-load-manager loadManager.writeResourceQuotasToZooKeeper(); // -> writeBundleDataOnZooKeeper() on the test thread The same race exists in a running broker, between the leader's A local variant of the test forces this order. It spies Modifications
// Serializes the removals of bundles from loadData, with the deletions of their data from the metadata store, and // writeBundleDataOnZooKeeper(). Otherwise a write that collected a bundle before its removal can recreate the // bundle's data after the deletion, and nothing deletes it again. private final Object bundleDataLock = new Object(); public void updateAll() { ... updateAllBrokerData(); synchronized (bundleDataLock) { updateBundleData(); } ... } public void writeBundleDataOnZooKeeper() { if (!isLeader()) { return; } // Hold the lock until the writes complete, so that the bundles removed meanwhile are deleted after them synchronized (bundleDataLock) { updateBundleData(); ... // unchanged: collect, write, wait for the writes } }
The test is unchanged. Verifying this change
Does this pull request potentially affect one of the following parts:If the box was checked, please highlight the changes
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions…ata of a bundle it just removed With ModularLoadManagerImpl, updateAll() (on the load manager's executor, after each load report change) and writeBundleDataOnZooKeeper() (on the load manager executor, from LoadResourceQuotaUpdaterTask) both change the leader's bundle data without synchronization. When a write collects a bundle before the leader learns it's gone, and updateAll() removes it from loadData and deletes its data before the write lands, the write recreates the bundle-data node. The bundle is no longer in loadData, so nothing deletes the node again. The auto-split in checkNamespaceBundleSplit() removes and deletes the split bundle the same way. This made NamespaceServiceTest.testModularLoadManagerRemoveInactiveBundleFromLoadData flaky: it writes the post-split load report and then the bundle data right after. Serialize the removals of bundles from loadData, with the deletions of their data, and writeBundleDataOnZooKeeper(), which holds the lock until its writes complete. …nactive-bundle-flake
codelipenghui
approved these changes
Uh oh!
There was an error while loading. Please reload this page.
poorbarcode
pushed a commit
to poorbarcode/pulsar
that referenced
this pull request
…ata of a bundle it just removed (apache#27521) (cherry picked from commit 8063b6a)
poorbarcode
pushed a commit
to poorbarcode/pulsar
that referenced
this pull request
…ata of a bundle it just removed (apache#27521) (cherry picked from commit 8063b6a)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabelsProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. 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. |