Looking at Hazelcast Map Persistence article and wondering: why MapStore methods are declared with synchronized keyword? Is there a chance that this method would be called concurrently for same record key?
Especially in case of write-through map store, when storage methods are called synchronously with IMap methods.
Yes it is possible that the MapStore
implementation is called concurrently from different partitions. That said it means there'll never be a concurrent call for the same key but different keys.
In the example there is only a single database (SQL) connection and therefore all methods need to share the same mutex (which is enforced using the synchronized block). If you have, on the other side, a multi-threaded (thread-safe) database access / client or a connection pool you'll be fine to not synchronize access to the methods.