hsluoyz commented on issue #408: URL: https://github.com/apache/casbin-pycasbin/issues/408#issuecomment-5205413747
@feymanpaper Thanks for the detailed report — this is a real deadlock, and the lock-order analysis is exactly right. Fixed in [[4f42fb7](https://github.com/apache/casbin-pycasbin/commit/4f42fb759d32d3b9d64403546c2b014cb32266c2)](https://github.com/apache/casbin-pycasbin/commit/4f42fb759d32d3b9d64403546c2b014cb32266c2): `SyncedEnforcer` now queues watcher notifications raised inside a locked section and delivers them right after the lock is released, so it never holds the enforcer lock while asking for the watcher's mutex. The read lock is covered too, since `save_policy()` notifies the watcher as well. Notifications are only deferred, not made async — they're still delivered before `add_policy()` returns. Added a regression test that reproduces the original two-thread deadlock. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
