VR command aggregation drops commands and fails with NPE when two jobs aggregate on the same router

オープン
#14,639 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@bhouse-nexthop がすでに取り組んでいます。

2026年11月9日 から。

  • #14640 @bhouse-nexthop による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java

調査の方向性

Start with core/.../agent/resource/virtualnetwork/VirtualRoutingResource.java and trace how AggregationControlCommand Start and Finish access the per-router queue, _vrLockMap, and aggregation map. Check the agent request threading and related tests before changing these shared maps. Done means concurrent aggregation for one router does not replace or misapply queued commands, create inconsistent locks, or fail when Finish finds no queue; add coverage for those cases.

索引モデルが issue の本文から書いたものです。

説明

problem

Command aggregation on a virtual router isn't safe when two jobs aggregate commands for the same router at the same time. Parallel tier deploys in one VPC do this. Commands get dropped, and jobs fail with a NullPointerException.

VirtualRoutingResource (core/.../agent/resource/virtualnetwork/VirtualRoutingResource.java) keeps one aggregation queue per router name in a HashMap:

  • AggregationControlCommand Start puts a new queue for the router. A second Start while one exists replaces it, so the commands the first job has queued so far are never applied. Their answers were already successful, because a queued command is answered with success at once.
  • Every other NetworkElementCommand for that router goes into whichever queue is current.
  • Finish applies the current queue and removes it. The first job's Finish applies the second job's queue, and the second job's Finish then finds no queue. The loop and then queue.clear() in the finally block throw java.lang.NullPointerException: Cannot invoke "java.util.Queue.clear()" because "queue" is null.

The result is that one job fails, and another reports success although some of its configuration never reached the router.

The per-router lock map (_vrLockMap) and the aggregation map are also plain HashMaps changed from parallel agent request threads. The lock is created with a check-then-put, so two threads can get different locks for the same router.

This may be one cause of #11710: with redundant routers, the two routers of a VPC can end up with different configurations.

versions

4.22 (the code is the same on main and 4.20).

The steps to reproduce the bug
  1. Create a VPC with redundant routers on KVM.
  2. Create several tiers and deploy VMs into them in parallel, for example 24 deploys across the tiers at once.
  3. Some deploys fail. The management server logs Failed to re-program the network as a part of network ... implement due to aggregated commands execution failure!, and the router's host agent answers an AggregationControlCommand Finish with java.lang.NullPointerException: Cannot invoke "java.util.Queue.clear()" because "queue" is null.
  4. In our lab run, 12 of 24 parallel tier deploys failed. In two of three rounds, the two routers ended up with different keepalived VIP sets, and both were PRIMARY.
What to do about it?
  • On the agent:
    • do not replace an existing queue on Start;
    • do not fail with an NPE on a Finish whose queue was already applied;
    • make the maps thread-safe.
  • A complete fix would serialise aggregated applies per router on the management server, or tag each aggregation with an id. That is a larger change.
主要言語
Java
スター
3.1k
フォーク
1.4k
平均マージ
7日 16時間
マージ済み PR(30日)
15

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/cloudstack のほかの issue

apache/cloudstack の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。