@Calvin
You are probably right but it's always a nice thing to implement
things like that right and then forget about them.
@Bill,
Thanks for sharing your pastie! I looked at it and I might have found
a problem:
In Line 75 you increment your shards count - but you don't save the
Entity.
So this is incfremented only for the current thread - all other
threads running on the distributed system woun't know that the shard
count is already increased and you will get failed transaction due to
contentions after all.
But if you save it - you will run into the same issue I was talking
about in the first place:
A lot threads might be trying to increase and save the shard count -
which might again lead to a failed put().
This case is handled by the outer try/except block which ignores it.
Also I changed the code for increasing the number of shards to:
num_shards = int(num_shards * 0.1 + 1)
Which increases by 10%. The reason is that if you have already 300
shards running and despite that get failed transactions - adding only
a static number like 5 might be not enough.
Regards,
Constantin