tvalentyn commented on code in PR #29542:
URL: https://github.com/apache/beam/pull/29542#discussion_r1410158041
##########
sdks/python/apache_beam/ml/transforms/handlers.py:
##########
@@ -134,7 +137,11 @@ def process(self, element):
hash_object.update(str(list(value)).encode())
else: # assume value is a primitive that can be turned into str
hash_object.update(str(value).encode())
- yield (hash_object.hexdigest(), element)
+ unique_suffix = uuid.uuid4().hex
+ # over multpile docker containers, the uuid might generate
+ # same uuid. So we will add the process id to the hash key
+ # along with the unique suffix to avoid possible collisions.
+ yield (hash_object.digest() + str(os.getpid()) + unique_suffix, element)
Review Comment:
os.getpid() might make some sense in combination with uuid1 since with uuid1
is evaluated based on hostname info, which is likely the same in all processes;
with uuid4 it shouldn't add much additional entropy as in docker containers
from my observation process ids for sdk harness are usually the same.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]