powsybl / powsybl-core

A framework to build power system oriented software
https://www.powsybl.org
Mozilla Public License 2.0
122 stars 40 forks source link

Default NetworkCacheService should not cache Networks (multithreading issues) #679

Closed sylvlecl closed 11 months ago

sylvlecl commented 5 years ago

Feature.

Currently AFS uses by default a NetworkCacheService implementation which actually caches networks, but causes issues in multithreaded environement. Users are usually not aware of the existence of that cache, which is hidden in the implementation of "getNework" methods of ProjectCase. In particular they do not know that they will be using the same Network instance in different threads.

To reproduce the multithreading issue linked to the default behaviour, try accessing a state variable of a Network from the same ImportedCase in 2 different threads, after having set the "allowMultiThreadVariant" flag.

The default behaviour should instead to have a dummy implementation which reads from the underlying storage for each call, and does not cache anything.

The current behaviour is not documented and causes unexpected and hard to debug issues in a multithreaded environement (any server typically).

geofjamg commented 11 months ago

AFS is not part anymore of powsybl core.