Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Handoff and load balance are transparent to users.

Design Details

query node在逻辑上分historical和streaming两部分分别管理sealed segments和growing segments,如下图所示,G3表示growing segment 3, S8表示sealed segment 8

Image Removed

Image Removed

...

Query node logically manages the sealed segments and the growing segments in two parts, historical and streaming. As shown in the following figure, G3 represents the growing segment 3, and S8 represents the sealed segment 8.

Image Added


Image Added

Based on the diagram above, it can be concluded that the handoff and load balance process consists of two main steps:

  1.  Load the sealed segment onto a query node
  2. Remove the corresponding sealed segment or growing segment from a query node

However, there are several scenarios to consider in the implementation:

  1. What if some query node associated with the handoff or load balance process is suddenly down
  2. If there is a sudden downtime on query coord, how to properly resume the handoff and load balance tasks after the restart
  3. If the same sealed segment exists on different query nodes at the same time, whether it will have an impact on the final query results
  4. Different query nodes may not process query messages at the same speed, and how to ensure that different query nodes have the same global sealed segmentIDs when processing the same query message. If not handled well, it may cause the query to time out

Based on the above considerations, we propose the following designs:

Prerequisite: The cache meta of querycoord records which sealed segment, growing segment, and dmchannels are on each querynode. These metas will be stored in etcd synchronously.

1.First of all, querycoord automatically generates handoff tasks and load balance tasks and writes them into etcd, and then clears them from etcd until the task is completed, ensuring that querycoord can accurately restore the task after restarting.

2. Next, query coord uses its own allocation strategy to determine which querynode the sealed segment of balance or handoff should be allocated to. The allocation strategy considers whether the total size of segments on each query node is balanced, and whether the segments of each collection are evenly distributed across all querynode

3.Querycoord directly loads the allocated sealed segments to the corresponding query node, and then the same segment will exist on different querynodes. We de-duplicate the query result based on the primary key during local reduce and global reduce to avoid affecting the query result.

4.After query coord successfully loads sealed segments on querynode, update the sealed segments list of each querynode in cache meta. For example, after balancing sealed segment 8 from node 1 node 2, the meta of node1 changes from {S6, S7,S8} to { S6, S7}, node2's meta is changed from {S5} to {S5, S8}. If the query node suddenly goes down, directly follow the meta records of the coord to recover the query node. While querycoord updates the meta, it broadcasts a change info of sealed segments to querychannel.