Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.14.0, 1.12.4, 1.13.3
Description
For example, in RocksdbStateBackend , if we worked in VoidNamespace , and And use the ValueState like below .
// insert record for (int i = 0; i < 3; ++i) { keyedStateBackend.setCurrentKey(i); testValueState.update(String.valueOf(i)); }
Then we get all the keysAndNamespace according the method RocksDBKeyedStateBackend#getKeysAndNamespaces().The result of the traversal is
<1,VoidNamespace>,<2,VoidNamespace>,<3,VoidNamespace> ,which is as expected.
Thus,if we use MapState , and update the MapState with different user key, the getKeysAndNamespaces would return duplicate data with same keyAndNamespace.
// insert record for (int i = 0; i < 3; ++i) { keyedStateBackend.setCurrentKey(i); mapState.put("userKeyA_" + i, "userValue"); mapState.put("userKeyB_" + i, "userValue"); }
The result of the traversal is
<1,VoidNamespace>,<1,VoidNamespace>,<2,VoidNamespace>,<2,VoidNamespace>,<3,VoidNamespace>,<3,VoidNamespace>.
By reading the code, I found that the main reason for this problem is in the implementation of RocksStateKeysAndNamespaceIterator.
In the hasNext method, when a new keyAndNamespace is created, there is no comparison with the previousKeyAndNamespace. So we can refer to RocksStateKeysIterator to implement the same logic should solve this problem.
Attachments
Attachments
Issue Links
- links to