Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

unordered_map::at (std::out_of_range) planning EXPLAIN of a packed filtered count when the modulo-sum predicate uses a computed expression (e.g. offset(id(b)))

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

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

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
74/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp
領域
database

調査の方向性

Start in src/processor/map/map_aggregate.cpp at tryMapPackedFilteredCount(), then trace Schema::getExpressionPos() and the packed child schema lookups for the group key and predicate inputs. Reproduce the EXPLAIN query with enable_packed_path_extend=true and verify that computed predicate expressions no longer cause unordered_map::at; the plan should map or fall back gracefully while direct execution remains unchanged.

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

説明

What happens?

Planning the following query with EXPLAIN crashes with Error: unordered_map::at (a std::out_of_range escaping as an error, not a segfault). The same query without EXPLAIN executes fine, so the failure is in plan mapping on the EXPLAIN path.

The throw originates in Schema::getGroupPos(name) (unordered_map::at) reached via:

#2 lbug::planner::Schema::getGroupPos(std::string const&) const
#3 lbug::planner::Schema::getGroupPos(lbug::binder::Expression const&) const
#4 lbug::planner::Schema::getExpressionPos(lbug::binder::Expression const&) const
#5 lbug::processor::PlanMapper::mapAggregate(lbug::planner::LogicalOperator const*)

i.e. tryMapPackedFilteredCount() (src/processor/map/map_aggregate.cpp) calls packedChildSchema->getExpressionPos(...) on the group key and on the two predicate inputs of the (lhs + rhs) % k = 0 filter. When a predicate input is a plain property (b.id) the lookup succeeds; when it is a computed expression over the nbr internal ID (offset(id(b))) the expression is not found in the packed child schema by unique name and .at() throws.

Repro
-- any database with a two-column int64 PK node table and a rel table; e.g.:
CREATE NODE TABLE MPerson(id INT64, PRIMARY KEY(id));
CREATE REL TABLE MKnows(FROM MPerson TO MPerson);
-- (populate some edges)

CALL enable_packed_path_extend=true;
EXPLAIN MATCH (a:MPerson)-[e:MKnows]->(b:MPerson)
WHERE (a.id + offset(id(b))) % 10 = 0
RETURN a.id, COUNT(*);
Error: unordered_map::at

Observed on the current main build (pre-existing; found while testing #867, which only touches this code path's gating and does not change the crash).

Conditions (verified on a 3000-node / 6750-edge MPerson/MKnows database)
# config query shape result
A enable_packed_path_extend=true + EXPLAIN keyed COUNT(*), predicate (a.id + offset(id(b))) % 10 = 0 crash (unordered_map::at)
B enable_packed_path_extend=false + EXPLAIN same OK
C enable_packed_path_extend=true + EXPLAIN same, but predicate (a.id + b.id) % 10 = 0 (plain property) OK
D enable_packed_path_extend=true + EXPLAIN global COUNT(*) (no group key), offset predicate OK
— enable_packed_path_extend=true, no EXPLAIN same as A OK (executes and returns correct rows)

So all three ingredients are required: the packed-filtered-count mapping pattern (keyed count(*) over a single modulo-sum filter above a packed extend), a predicate input that is a computed expression rather than a property, and the EXPLAIN statement (non-EXPLAIN execution of the same query does not hit the throwing lookup).

Expected

Either the plan maps (the schema should contain, or the mapper should resolve, the mapped form of the predicate input expressions), or tryMapPackedFilteredCount should bail out gracefully (return nullptr) when the key/predicate-input expressions cannot be located in packedChildSchema, falling back to the regular aggregate plan.

Suggested fix direction

In tryMapPackedFilteredCount, the lookups packedChildSchema->getExpressionPos(*key) / getExpressionPos(*predicateInputs->first|second) assume the binder expressions appear verbatim in the packed child schema. For computed expressions (e.g. offset(id(b))) the planned schema holds a different expression object for the same unique name, or holds nothing at all. Guard these lookups (e.g. Schema::containsExpression(...)-style check, or try/catch around getGroupPos) and fall back to the standard aggregate mapping when they fail. It may also be worth checking why the EXPLAIN path differs from direct execution for the same query.

主要言語
C++
スター
1.8k
フォーク
148
平均マージ
14時間 57分
マージ済み PR(30日)
124

環境構築

はじめの一歩

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

LadybugDB/ladybug のほかの issue

LadybugDB/ladybug の issue をすべて見る

似ている issue

C++ の issue をもっと見る

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

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