NealSun96 opened a new issue #843: Fix writing race conditions in 
ZkMetadataStoreDirectory
URL: https://github.com/apache/helix/issues/843
 
 
   Among the writing operations of `ZkMetadataStoreDirectory`, we have 
validation logic set up to ensure that, for example, a sharding key insertion 
is valid. However, it is possible to bypass the validation logic: one simple 
reproducible method is to do `addShardingKey("realm1", "/a/b/c")` immediately 
followed by `addShardingKey("realm2", "/a/b/c")`. Since the validation logic 
relies on the in-memory copy of routing data, which is updated by data 
callback, if the second call fires before data callback, the validation logic 
will treat the second call as valid. This can cause the routing data to have 
one sharding key pointing to two realms, which is invalid. 
   Following this train of thought, we discovered that it is possible for two 
threads to do the two mentioned-above calls at the same time, which is even 
more difficult to guard. 
   To fix this issue, all writing operations will be wrapped in `synchronized 
(this)`, which ensures that only 1 writing operation of any kind will fire at a 
time. After any writing operation, we also manually refresh the in-memory 
routing data to reflect the changes. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to