Closed yuqi1129 closed 1 year ago
I suggest doing a whole refactoring work on this store part immediately. Currently the organization of code seems messy, which mixed several things together, like:
The patched fix seems just like a workaround, not a thorough fix. For example:
@yuqi1129 think carefully about the problems I mentioned above, and provide a whole refactoring design when ready. What I want is thorough design doc before any code change.
What would you like to be improved?
Bug description.
When we try to store an entity, we will use the following method to store entity value:
However, Id allocation in
entityKeyEncoder
requires this procedure should be in a transaction. then error occurs.Why existing UT can't detect this problem
UT
testCreateKvEntityStore
use transaction to store entity, see belowAnd entities added later do not trigger new Id allocation,
How should we improve?
Temporarily, we can start a transaction in function
put
and allow nested transactions ( if we want to start a new transaction and found that current thread is already in a transaction, we would not start a new one, see below)For long time, we should refactor the key encoding logic and get rid of dependence on transactions