oracledb_cdc: set user_name as metadata - #4674
Conversation
| OldValues map[string]any | ||
| Timestamp time.Time | ||
| TransactionID TransactionID | ||
| UserName string |
There was a problem hiding this comment.
DMLEvent.UserName is not carried through the cache-resource transaction buffer, so user_name metadata is silently dropped whenever logminer.transaction_cache is configured.
When the transaction buffer is backed by a cache resource, events are round-tripped through serializedDMLEvent in cache_resource.go#L432-L494. That struct — and both marshalEvent/unmarshalEvent — enumerate fields explicitly and have no UserName, so every event read back via GetTransaction has UserName == "" and batcher.Publish skips the MetaSet("user_name", ...).
The result is inconsistent behaviour between the two buffering modes for the same pipeline, contradicting the new docs claim that the field is absent only on snapshot messages or when Oracle reports a NULL/empty username. The existing integration subtest "With cache_resource transaction buffer" (integration_test.go#L762-L829) calls the same mustAssertMetadata helper you extended, so it should fail on the new require.Truef(..., "message %d missing 'user_name' metadata") assertion.
Fix: add a UserName field (e.g. json:"user_name") to serializedDMLEvent and populate it in both marshalEvent and unmarshalEvent. A unit test that round-trips a DMLEvent through marshalEvent/unmarshalEvent and asserts field parity would catch this class of drift (CONTRIBUTING.md §1.3.2, §3.1.4 "implementation is complete and correct").
| Timestamp: dml.Timestamp, | ||
| TransactionID: dml.TransactionID.String(), | ||
| CommitTimestamp: commitTimestamp, | ||
| UserName: dml.UserName, |
There was a problem hiding this comment.
Synthesized LOB UPDATE events never populate UserName, so those change messages will be missing user_name.
When lob.enabled is set and a LOB accumulator has no matching DML event, a sqlredo.DMLEvent is constructed by hand at logminer.go#L500-L509 with Operation, Schema, Table, Data, OldValues, TransactionID and Timestamp — but no UserName. Those events flow through this toMessageEvent call, so dml.UserName is "" and batcher.Publish omits the metadata key.
This contradicts the documentation added in this PR, which states user_name is absent only on snapshot (read) messages or when Oracle reports a NULL/empty username. Since the synthesized event already copies TransactionID and Timestamp from the COMMIT redoEvent, setting UserName: redoEvent.UserName.String there would keep the new metadata consistent across all emitted change messages (CONTRIBUTING.md §3.1.4).
No description provided.