From a46e61a603bb5bb01d5e7c07e84695cbe596b0c6 Mon Sep 17 00:00:00 2001 From: Facundo Medica Date: Sun, 25 Sep 2022 01:05:15 -0300 Subject: [PATCH] docs: add iavl concurrent use warning --- docs/spec/store/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/spec/store/README.md b/docs/spec/store/README.md index cd9d23fc454d..4ca5775a2e53 100644 --- a/docs/spec/store/README.md +++ b/docs/spec/store/README.md @@ -96,6 +96,22 @@ the typical abstraction layer in order is defined as follows: iavl.Store <- cachekv.Store <- gaskv.Store <- cachemulti.Store <- rootmulti.Store ``` +### Concurrent use of IAVL store + +The tree under `iavl.Store` is not safe for concurrent use. It is the +responsibility of the caller to ensure that concurrent access to the store is +not performed. + +The main issue with concurrent use is when data is written at the same time as +it's being iterated over. Doing so will cause a irrecoverable fatal error because +of concurrent reads and writes to an internal map. + +Although it's not recommended, you can iterate through values while writing to +it by disabling "FastNode" **without guarantees that the values being written will +be returned during the iteration** (if you need this, you might want to reconsider +the design of your application). This is done by setting `iavl-disable-fastnode` +to `true` in the config TOML file. + ### `cachekv.Store` The `cachekv.Store` store wraps an underlying `KVStore`, typically a `iavl.Store`