fix(sql): attribute a duplicated key to its own tags; key-value cap gets 2x headroom (R06:S-1 review I-1, m-3)
One stray duplicate row used to fail every tag in a key-value group or none of them, depending on whether an unrelated key was absent. Duplicated keys are now refused per key: only that key's tags publish BadConfigurationError and the rest of the group reads normally. The key-value cap reads up to 2x the distinct keys (+1 to detect excess), so a few stray duplicates are attributed per key and only a gross excess (history/events table) fails the whole group. Duplicated-key refusals count as answered refusals for health. The row-cap, duplicate-key and multi-row warnings now use the per-plan limiter (m-3); the reader-wide limiter is removed. Unit tests pin both the all-keys-present and absent-key cases with Good controls; live SQL Server gate added (23/23). Refs #744 Claude-Session: https://claude.ai/code/session_01Ub9hGmYLQvn9XETzw7CMsT
This commit is contained in:
@@ -230,10 +230,12 @@ public static class SqlGroupPlanner
|
||||
values.Add(keyValue);
|
||||
}
|
||||
|
||||
// Row cap (R06:S-1): one row per distinct key is all this plan can use, so it asks for ONE more — enough
|
||||
// to see a source breaking the one-row-per-key contract, never enough to pull a history table's every
|
||||
// matching row into memory on every poll.
|
||||
var rowCap = values.Count;
|
||||
// Row cap (R06:S-1): one row per distinct key is all this plan can use. It reads up to TWICE that, so a
|
||||
// handful of stray duplicates stays inside the cap and is attributed PER KEY by the reader (only the
|
||||
// duplicated key's tags go BadConfigurationError) — and asks for one row more than that, so only a
|
||||
// gross excess (a history/events table, unattributable by construction because the rest is unread)
|
||||
// fails the whole group. Memory stays O(keys) either way.
|
||||
var rowCap = values.Count * 2;
|
||||
var sql = new StringBuilder("SELECT ")
|
||||
.Append(dialect.RowLimitPrefix(rowCap + 1))
|
||||
.Append(QuoteList(selected, dialect))
|
||||
|
||||
Reference in New Issue
Block a user