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
Fix CPU 100% when deleting namespace #10337
Conversation
Policies policies = new Policies(); | ||
policies.deleted = true; | ||
persistentTopic.onPoliciesUpdate(policies); | ||
verify(persistentTopic, times(0)).checkReplicationAndRetryOnFailure(); |
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.
CN we add a positive test, that verifies that this method is called in case of non deleted Policies?
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.
Perfect
Thanks
@315157973 |
### Motivation When deleting the namespace, the namespace Policies will be marked as deleted. This will trigger topic's `onPoliciesUpdate` However, in onPoliciesUpdate, the data of the Policies node on zk will be read, such as: `checkReplicationAndRetryOnFailure` Due to the deletion of the namespace, the zk node may no longer exist at this time. Failure to read data will trigger infinite retries. https://github.com/apache/pulsar/blob/e970c2947aff9231202ab72bdbad047d85c55633/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java#L1175-L1193 If there are many topics, there will be a short-term CPU spike ![image](https://user-images.githubusercontent.com/9758905/115834541-ebc32480-a447-11eb-887a-95c4a3d1adf1.png) # Conflicts: # pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/PersistentTopicTest.java
When deleting the namespace, the namespace Policies will be marked as deleted. This will trigger topic's `onPoliciesUpdate` However, in onPoliciesUpdate, the data of the Policies node on zk will be read, such as: `checkReplicationAndRetryOnFailure` Due to the deletion of the namespace, the zk node may no longer exist at this time. Failure to read data will trigger infinite retries. https://github.com/apache/pulsar/blob/e970c2947aff9231202ab72bdbad047d85c55633/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java#L1175-L1193 If there are many topics, there will be a short-term CPU spike ![image](https://user-images.githubusercontent.com/9758905/115834541-ebc32480-a447-11eb-887a-95c4a3d1adf1.png)
When deleting the namespace, the namespace Policies will be marked as deleted. This will trigger topic's `onPoliciesUpdate` However, in onPoliciesUpdate, the data of the Policies node on zk will be read, such as: `checkReplicationAndRetryOnFailure` Due to the deletion of the namespace, the zk node may no longer exist at this time. Failure to read data will trigger infinite retries. https://github.com/apache/pulsar/blob/e970c2947aff9231202ab72bdbad047d85c55633/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java#L1175-L1193 If there are many topics, there will be a short-term CPU spike ![image](https://user-images.githubusercontent.com/9758905/115834541-ebc32480-a447-11eb-887a-95c4a3d1adf1.png)
When deleting the namespace, the namespace Policies will be marked as deleted. This will trigger topic's `onPoliciesUpdate` However, in onPoliciesUpdate, the data of the Policies node on zk will be read, such as: `checkReplicationAndRetryOnFailure` Due to the deletion of the namespace, the zk node may no longer exist at this time. Failure to read data will trigger infinite retries. https://github.com/apache/pulsar/blob/e970c2947aff9231202ab72bdbad047d85c55633/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java#L1175-L1193 If there are many topics, there will be a short-term CPU spike ![image](https://user-images.githubusercontent.com/9758905/115834541-ebc32480-a447-11eb-887a-95c4a3d1adf1.png)
@315157973 thank you for porting this patch to branch-2.7. |
Motivation
When deleting the namespace, the namespace Policies will be marked as deleted.
This will trigger topic's
onPoliciesUpdate
However, in onPoliciesUpdate, the data of the Policies node on zk will be read, such as:
checkReplicationAndRetryOnFailure
Due to the deletion of the namespace, the zk node may no longer exist at this time.
Failure to read data will trigger infinite retries.
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
Lines 1175 to 1193 in e970c29
If there are many topics, there will be a short-term CPU spike
Modifications
Verifying this change