Skip to content

fix(backend): add instance-scoped Kafka consumer group and client IDs#273

Merged
LuD1161 merged 2 commits intomainfrom
fix/kafka-instance-isolation
Feb 8, 2026
Merged

fix(backend): add instance-scoped Kafka consumer group and client IDs#273
LuD1161 merged 2 commits intomainfrom
fix/kafka-instance-isolation

Conversation

@LuD1161
Copy link
Contributor

@LuD1161 LuD1161 commented Feb 8, 2026

Summary

  • scope Kafka consumer group/client IDs by instance for agent trace ingest and node I/O ingest
  • preserve legacy default Kafka IDs when SHIPSEC_INSTANCE is unset to avoid offset resets/replays
  • keep explicit env vars (AGENT_TRACE_KAFKA_*, NODE_IO_KAFKA_*) as highest-priority overrides
  • add regression tests for unset/set/override cases

Why

This prevents cross-instance consumer collisions in multi-instance dev while avoiding breaking existing deployments that do not set SHIPSEC_INSTANCE.

Validation

  • bun --cwd=backend run lint
  • backend ingest regression tests added and passing
  • full pre-push checks passed locally (tsc/build + test suite)

Suffix Kafka consumer group IDs and client IDs with the SHIPSEC_INSTANCE
number for agent-trace and node-io ingest services. This prevents
consumer group conflicts when running multiple backend instances in
multi-instance dev mode.

Also updates pm2.config.cjs to pass the instance-scoped env vars and
updates documentation to reflect the change.

Signed-off-by: Aseem Shrey <LuD1161@users.noreply.github.com>
Signed-off-by: Aseem Shrey <LuD1161@users.noreply.github.com>
@LuD1161 LuD1161 merged commit e570903 into main Feb 8, 2026
3 checks passed
@LuD1161 LuD1161 deleted the fix/kafka-instance-isolation branch February 8, 2026 00:13
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: be4ed7523f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

NODE_IO_KAFKA_CLIENT_ID:
process.env.NODE_IO_KAFKA_CLIENT_ID || `shipsec-backend-node-io-${instanceNum}`,
NODE_IO_KAFKA_GROUP_ID:
process.env.NODE_IO_KAFKA_GROUP_ID || `shipsec-node-io-ingestor-${instanceNum}`,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve legacy Kafka group defaults when instance is unset

In the backend PM2 env block, this default always appends -${instanceNum} even when SHIPSEC_INSTANCE is not provided, because instanceNum falls back to '0' earlier in the file. That means PM2-launched backends without SHIPSEC_INSTANCE now get new group IDs (same pattern also exists for agent trace below), so the service-level “legacy fallback when unset” is bypassed and consumers can replay from the beginning (fromBeginning: true), duplicating ingest data for existing single-instance PM2 deployments.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant