Repository navigation
fix(xtcp2): nsid_assigned — tell the kernel's first nsid (0) apart from none - #322
Merged
Merged
Conversation
nsid 0 reads the same whether the kernel assigned id 0 or no id at all, so the golden diff has to treat nsid as volatile. These tests pin the fix (a nsid_assigned presence column) before it lands: - TestApplyEnrichmentNsid (+ an allocation guard and a benchmark): stamping sets nsid_assigned with the id, 0 included, and a recycled record does not carry it to the next socket. - TestClickHouseDDLMatchesProto: the Kafka table and _v2 have a column for every proto field. Green today; it turns red when the proto gains nsid_assigned without the DDL. - TestNormalizeNsid and TestCheck's companion rows: goldenrec numbers an assigned nsid (0 included) through an Assigned-class companion column and writes "-" when unassigned. - golden-capture.sh: ROW checks against each container veth's link-netnsid. Red: pkg/xtcp and pkg/goldenrec do not build (NsidAssigned, Assigned undefined). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rom none nsid 0 meant three things: the kernel's first id, no id for the namespace, and -populateNsid off. Docker veths take ids 0,1,2… in creation order, so one container in every capture had the ambiguous 0, and the golden diff had to drop nsid as volatile. - proto: bool nsid_assigned = 33, the free slot in the namespace block (no epoch bump). nsid is unchanged; read it only when nsid_assigned. - applyEnrichment sets nsid_assigned with nsid; recycleRecord's Reset clears both. - Parquet row and ClickHouse: the column in _v0 (so _v1), _v2 and the Kafka table; sql/migrations/nsid-assigned.sql adds it to existing deployments, idempotent, with the Kafka and MV blocks spliced verbatim from initdb.d. - goldenrec: an Assigned class, a bool <ordinal>_assigned column. nsid is an Ordinal again, numbered when assigned (0 included) and "-" when not; Check validates the pairing; Diff reads "-" as unset. - parquetColumnCount 181 -> 182. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…0.5 TODO Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two back-to-back captures differed on these alone. busy_time is counted in jiffies, so a send shorter than a tick reads 0 or one tick, and rcv_rtt is measured only once a receive window of data arrives: on the fixture's one-exchange connections both are 0 or not by chance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two captures diff empty; every nsid check in the capture passes, including the one namespace the kernel gave id 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The kernel's first nsid is 0, and
nsidalso read 0 when a namespace had no id (or-populateNsidwas off), so the two couldn't be told apart. This adds a presence column. Done test-first.Fix
bool nsid_assigned = 33(a free slot, schema epoch stays 2), set wherevernsidis stamped;recycleRecordclears it_v0/_v2/Kafka DDL, and an idempotent migrationsql/migrations/nsid-assigned.sql(applied twice on clickhouse-local)nsid(CHANGELOG)Assignedclass.nsidmoves from Volatile to Ordinal, numbered whennsid_assignedis true (0 included) and-when false;Checkvalidates the pairingtcp_info_busy_timeandtcp_info_rcv_rttare now Volatile. Back-to-back captures differed on these alone:busy_timeis in jiffies (tcp_get_info_chrono_stats), andrcv_rttneeds a window of received data, so on one-exchange connections both are 0 or not by chancepkg/xtcp/testdata/golden/7_3_1recapturedTests
TestApplyEnrichmentNsid(+ 0-alloc guard, benchmark),TestNormalizeNsid,TestDiffNsid,TestCheckassigned rowsTestClickHouseDDLMatchesProto: every proto field has a column in the Kafka table and_v2. Nothing checked this before (the AccECN columns went missing that way)link-netnsidof each container's veth): all PASS, with one container on id 0xtcp2-golden diffexit 0Red (tests commit, before the fix)
Green
go test ./...and the nix checks (gofmt, go-vet, nix-fmt, lint-baseline, golangci ×3, redteam-lint, golden-records, test-fuzz-all) pass.🤖 Generated with Claude Code