-
Notifications
You must be signed in to change notification settings - Fork 105
Unbounded queue in ThresholdBundler.closedBundles #157
Comments
So the bundling system will propagate service success results and service failures (as exceptions), but it doesn't propagate failures to initiate the service call. If that was propagated to the caller, then the caller wouldn't keep providing more and more messages with no feedback on the failures. |
Do you mean the caller of e.g. com.google.cloud.pubsub.PubSub? This would seem to require the application developer to develop some sort of "should I publish?" state and logic, whereas the ability to set a maximum limit on the number of items stored by the bundling system seems like it could prevent unbounded memory usage at a more foundational level. Of course, these aren't mutually exclusive though. |
Here is the scenario I'm describing:
Basically, any terminal state on an attempt to publish a bundle should clear out the bundle from |
@pongad could you make sure this gets addressed for pubsub? |
I think both issues are solved in the new implementation.
|
@pongad do you mean "now asynchronous"? |
@mattnworb Yes I did! |
We now have flow control in |
Correct, (1) is resolved by flow control, and (2) is resolved by converting to a pushing bundler, which gets rid of dedicated threads and uses an executor instead. |
Copying over some possible issues found in googleapis/google-cloud-java#1432:
com.google.api.gax.bundling.ThresholdBundler has an unbounded queue for closedBundles that will fill endlessly if an application is publishing faster than the queue can be drained, or if draining/publishing can't occur at all for some reason. We've seen on a few instances (3-5 applications out of 1000s) that this eventually leads to a OutOfMemoryError as the heap space fills up.
It seems like if the thread that ThresholdBundlingForwarder starts dies for any reason, it won't be restarted, and the messages accumulating in the Bundler will not be processed at all (eventually leading to the OOM above).
I am only familiar with the bundling behavior as it is used in google-cloud-pubsub, but for the first issue I think it may make sense for the Bundler to allow for specifying a maximum number of bundles/items that it will hold onto, and then either reject new items from being added or drop the oldest bundles/items when this limit is hit.
The text was updated successfully, but these errors were encountered: