Skip to content

Find a way to reliably track semantic meaning at runtime across buffers/reboot #11416

Description

@JeanMertz

This issue is based on a discussion at #11344 (comment), and an async Zoom discussion between @fuchsnj and me.

This issue has to be resolved before we publicly release the event schema work

As work on internal schemas continues, there is a need to track at runtime which schema belongs to which event. This cannot be done at boot-time because a sink can accept events from multiple inputs, and for it to be able to fetch field values based on the "semantic meaning" attached to an event schema, it has to know per event where the field belonging to a given semantic meaning can be found.

In the current (not yet released) implementation, we store a u16 as a schema::Id type in the event metadata. There are two issues with this:

  1. Event metadata is not propagated through disk buffers (and thus also not across restarts).
  2. Even if it was, the schema IDs are pointers into a schema registry, that stores the actual schema definitions. This registry is also not persisted across reboots, and thus any events pulled from the disk buffer after a reboot would have their schema ID pointing to a non-existing entry in the registry.

A potential solution to (1) is to not use event metadata to store the event ID, but have it be stored directly on the event (but invisible to users, so not part of the external event payload). This is somewhat unfortunate, as event metadata is the appropriate location for this type of information, where it not for the fact that no event metadata survives across buffer boundaries. So, the most ideal solution here was for #7065 to be resolved independently.

Assuming (1) is solved, for (2), one potential solution to this problem is to remove the indirection of schema::Id and directly store schema::Definition on an event, but the reason we chose to store an ID is that it has no significant performance impact on Vector's runtime behaviour, whereas storing the definition would require more data to be serialized, which will have a higher (but unsure how high) impact on performance. We could minimize this overhead by storing only the subset of a schema::Definition that we need at runtime, namely the semantic meaning and the LookupBuf it points to inside an event, but either way, there will be an increase in overhead.

UPDATE another way to further reduce the serialized data size, as discussed with @fuchsnj, is to change our semantic meanings to an enum internally, and attach a "default field" with each meaning. For example, the Meaning::Message semantic meaning would by default point to our log_schema defaults (in this case message), which, if the default is used, means we don't need to serialize any data, and can reconstruct it when deserializing from that default value. This does mean changing the defaults of log_schema is a breaking change, but I believe we have never changed those in the past.

The alternative solution for (2) is to persist the schema::Registry separately from the persisted events with their schema::Id, so that that ID always points back to a known definition in the registry after boot. This does bring other complications with it, such as when to persist this data. There might be other as-of-yet undocumented complications here.

Lastly, regardless of the solutions taken, there is always the possibility that an event is read from a disk buffer, using a newer Vector version that introduced changes to the schema requirements of a sink, such that it can no longer process the events it receives from the buffer (e.g. it expects a new semantic meaning that isn't known to exist in that event), at which point there's no recourse for us, other than dropping the event and returning an error. We can mitigate this by making sure we keep our schema requirements as stable as possible, and/or change them in backward compatible ways, but there will always be a possibility for events to be dropped.

Metadata

Metadata

Assignees

Labels

domain: buffersAnything related to Vector's memory/disk buffersdomain: schemasAnything related to internal Vector event schemas

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions