Open
Conversation
Add schema metadata to mongodb_cdc messages using a two-tier strategy: Tier 1 queries $jsonSchema validators at startup for accurate type info, Tier 2 infers schema from document structure as a fallback. Both tiers use key-set fingerprinting for lightweight schema change detection. Schema is attached as immutable "schema" metadata in benthos Common Schema format, enabling downstream processors like parquet_encode to automatically determine column types. The "database_schema" metadata field is also added with the database name. Key design decisions: - Fields are always sorted alphabetically for deterministic ordering - Partial updates and documentKey-only deletes use cached schema - Schema cache is reset on reconnect
|
Commits Review
|
- Inject _id into Tier 1 ($jsonSchema) schemas so the key-set fingerprint matches real documents and the validator's required/optional classification is preserved - Remove unused keysFromSchema function - Fix TOCTOU race in getOrInferCollectionSchema by using a single Lock - Move schema pre-fetch from background goroutine into Connect() so the change stream is not delayed - Use gerund form in error wrap prefixes per project conventions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
875997a to
2266396
Compare
|
Commits Review LGTM |
mmatczuk
approved these changes
Mar 12, 2026
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.
Add schema metadata to mongodb_cdc messages using a two-tier strategy: Tier 1 queries $jsonSchema validators at startup for accurate type info, Tier 2 infers schema from document structure as a fallback. Both tiers use key-set fingerprinting for lightweight schema change detection.
Schema is attached as immutable "schema" metadata in benthos Common Schema format, enabling downstream processors like parquet_encode to automatically determine column types. The "database_schema" metadata field is also added with the database name.
Key design decisions: