Commit a59f2a6f authored by Sebastien Robin's avatar Sebastien Robin

fixed important problem in produceUid


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4433 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 568cba8c
...@@ -780,20 +780,23 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -780,20 +780,23 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
klass._local_clear_reserved_time = self._last_clear_reserved_time klass._local_clear_reserved_time = self._last_clear_reserved_time
elif not hasattr(self, '_v_uid_buffer'): elif not hasattr(self, '_v_uid_buffer'):
self._v_uid_buffer = UidBuffer() self._v_uid_buffer = UidBuffer()
LOG('producedUid, len(self._v_uid_buffer)',0,len(self._v_uid_buffer))
if len(self._v_uid_buffer) == 0: if len(self._v_uid_buffer) == 0:
method_id = self.sql_catalog_produce_reserved method_id = self.sql_catalog_produce_reserved
method = getattr(self, method_id) method = getattr(self, method_id)
instance_id = klass._instance_id
if instance_id is None:
# Generate an instance id randomly. Note that there is a small possibility that this # Generate an instance id randomly. Note that there is a small possibility that this
# would conflict with others. # would conflict with others.
# This is VERY Important to generate a new instance_id
# each time, because some uids might be assigned to
# some objects, but objects can be not indexed yet, so
# we can get assigned uids with a path equal to reserved.
# May be the name instance_id is not good any more
random_factor_list = [time.time(), os.getpid(), os.times()] random_factor_list = [time.time(), os.getpid(), os.times()]
try: try:
random_factor_list.append(os.getloadavg()) random_factor_list.append(os.getloadavg())
except (OSError, AttributeError): # AttributeError is required under cygwin except (OSError, AttributeError): # AttributeError is required under cygwin
pass pass
instance_id = md5.new(str(random_factor_list)).hexdigest()[:30] instance_id = md5.new(str(random_factor_list)).hexdigest()[:30]
klass._instance_id = instance_id
uid_list = [x.uid for x in method(count = UID_BUFFER_SIZE, instance_id = instance_id) if x.uid != 0] uid_list = [x.uid for x in method(count = UID_BUFFER_SIZE, instance_id = instance_id) if x.uid != 0]
self._v_uid_buffer.extend(uid_list) self._v_uid_buffer.extend(uid_list)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment