diff --git a/product/ZSQLCatalog/SQLCatalog.py b/product/ZSQLCatalog/SQLCatalog.py index 2ac4cf9ded97f2b3a9155957c6dfb4b68a43173c..5aa2cbf8261041fbd5c9bee9f5c76c35bb939202 100755 --- a/product/ZSQLCatalog/SQLCatalog.py +++ b/product/ZSQLCatalog/SQLCatalog.py @@ -780,20 +780,23 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): klass._local_clear_reserved_time = self._last_clear_reserved_time elif not hasattr(self, '_v_uid_buffer'): 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: method_id = self.sql_catalog_produce_reserved 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 - # would conflict with others. - random_factor_list = [time.time(), os.getpid(), os.times()] - try: - random_factor_list.append(os.getloadavg()) - except (OSError, AttributeError): # AttributeError is required under cygwin - pass - instance_id = md5.new(str(random_factor_list)).hexdigest()[:30] - klass._instance_id = instance_id + # Generate an instance id randomly. Note that there is a small possibility that this + # 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()] + try: + random_factor_list.append(os.getloadavg()) + except (OSError, AttributeError): # AttributeError is required under cygwin + pass + instance_id = md5.new(str(random_factor_list)).hexdigest()[:30] 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)