XX-net/XX-Net · warning
get %d from size:%d fail.
Error message
get %d from size:%d fail.
What it means
While scanning the ordered waiters list to insert a lock by wait_order, an index/iteration exception occurred at position i. The loop logs and continues from the next index.
Source
Thrown at code/default/x_tunnel/local/base_container.py:191
def wait(self, wait_order):
with self.lock:
lock = threading.Lock()
lock.acquire()
if len(self.waiters) == 0:
self.waiters.append((wait_order, lock))
else:
is_max = True
for i in range(0, len(self.waiters)):
try:
i_wait_order, ilock = self.waiters[i]
if i_wait_order > wait_order:
is_max = False
break
except Exception as e:
if i >= len(self.waiters):
break
xlog.warn("get %d from size:%d fail.", i, len(self.waiters))
continue
if is_max:
self.waiters.append((wait_order, lock))
else:
self.waiters.insert(i, (wait_order, lock))
lock.acquire()
def status(self):
out_string = "waiters[%d]:\n" % len(self.waiters)
for i in range(0, len(self.waiters)):
end_time, lock = self.waiters[i]
out_string += "%d\r\n" % (end_time)
return out_string
View on GitHub (pinned to cfa5bc17b6)
Solutions
- Review locking around waiters mutation to guarantee the scan is atomic
- Recompute len(self.waiters) and validate i inside the except before continue
- Consider a heap/sorted structure with proper mutex instead of manual index scanning
- Reproduce under concurrency stress to confirm the race
Example fix
# before
except Exception as e:
if i >= len(self.waiters):
break
xlog.warn("get %d from size:%d fail.", i, len(self.waiters))
continue
# after
except Exception:
with self.mutex:
i = min(i, len(self.waiters)) # resync under lock and retry scan Defensive patterns
Strategy: retry
Try / catch
On scan failure, resync index under the mutex and retry the scan once.
Prevention
- Hold the same lock for scan and mutation of waiters
- Use a heap keyed by wait_order to avoid manual index scanning
When it happens
Trigger: The waiters list is mutated concurrently (another waiter inserted/removed) during iteration, causing an IndexError or comparison error on stale i; only happens when i < len(self.waiters).
Common situations: High-concurrency wait paths racing on the waiters list; a lock removed by its owner while another thread scans; logic changes breaking the sorted invariant.
Related errors
- ConnectionPipe remove sock e:%r
- url in downloading, %s
- add_sock_event %s conn:%d e:%r
- session try to run but is running.
- remove conn:%d except:%r
AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27).
Data as JSON: /api/errors/f7c353d5f3310973.
Report an issue: GitHub.