def METHOD_NAME(pool):
    key = pool.keys()[0]
    buffers = set()
    count = 0
    while True:
        if key in buffers:
            break
        buffers.add(key)
        key = pool[key]['nx']
        count += 1
    if count != pool['size']:
        raise Exception("Buffer pool integrity is bad.")