mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
6dd37dd2a7
This commit adds two checks to the in-memory store to detect improper use of transactions: 1. Mark aborted/committed transactions as stale and error if an operation is attempted on a stale transaction. Previously callers could perform unsafe concurrent operations on stale transactions without noticiing. 2. Check that supplied transactions are from the underlying store and not another store. We could consider deprecating the store APIs and moving them onto the transaction to prevent this kind of mistake in the future. With these changes the store will panic on unregister and abort calls if any of these invariants are violated. Panicing is preferable to failing silently. Note, we still have the issue of recursive transactions resulting in deadlock. Our options there are to implement more sophisticated locking inside the in-memory store or modify the API so that the store can update the passed context.Context with a sentinel value. Fixes #1594 Signed-off-by: Torin Sandall <torinsandall@gmail.com>