hashgraph / hedera-services

Crypto, token, consensus, file, and smart contract services for the Hedera public ledger
Apache License 2.0
281 stars 124 forks source link

Disallow backpressure for direct schedulers #10870

Open poulok opened 8 months ago

poulok commented 8 months ago

It is currently possible to configure a direct (or direct static) task scheduler with an unhandled task capacity which enables back pressure. Back pressure does not make sense for direct schedulers because the task is executed immediately on the scheduling thread.

One solution is to add logic to TaskSchedulerBuilder.withType() to check if the type being set is direct and the unhandled capacity is already set, and logic to TaskSchedulerBuilder.withUnhandledTaskCapacity() that checks if the type is already set to direct. In each case, if the combination of type and unhandled task capacity are incompatible, throw an exception.

This check could also be done in the TaskSchedulerBuilder.build() method.

HarshSawarkar commented 1 month ago

Hi, I have linked a PR for fixing this issue.Could you review it?