enhancement: use continue instead of break in nats fetch message loop #4943
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.
Description
I found a memory leak issue in mage nats streaming pipeline, after I implemented it in production with more than 10 triggers of nats streaming pipeline.
I have fixed the memory issue by using "continue" instead of "break" in the NATS fetch message loop and updating the NATS close client method to wait for the result.
Before
Start the dev server
Turn on the trigger, 10 nats push subscriber
Test publish 10.000 messages
The mage-ai-app-1 was killed due to insufficient resources
The memory continues to grow, leading to the termination of mage-ai-server-1 due to insufficient resources.
After
Start the dev server
Turn on the trigger, 10 nats push subscriber
Test publish 10.000 messages
Memory usage is not as high as before
Need Help
Based on the data I've collected, I've noticed a significant spike in CPU usage during message processing, and I'm not sure why this is happening and need your help to investigate the cause of the high CPU usage.
How Has This Been Tested?
Checklist
cc: