XX-net/XX-Net · warning

get from size: 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.

Solutions

  1. Review locking around waiters mutation to guarantee the scan is atomic
  2. Recompute len(self.waiters) and validate i inside the except before continue
  3. Consider a heap/sorted structure with proper mutex instead of manual index scanning
  4. 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

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


AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27). Data as JSON: /api/errors/f7c353d5f3310973. Report an issue: GitHub.

Appendix: 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)