fix: correct sendercompid/targetcompid for incoming messages in PostgreSQLLog#738
Open
MubasherMajeed wants to merge 1 commit into
Open
Conversation
…reSQLLog When logging incoming messages via onIncoming(), sendercompid and targetcompid columns were always populated from the local SessionID perspective, causing incoming messages to appear with incorrect sender/target values in the messages_log table. Fix: added isIncoming boolean parameter to insert(). When true, getSenderCompID() and getTargetCompID() are swapped to correctly reflect the actual message direction. Also fixed incorrect class comment: PostgreSQLLogFactory was documented as MySQL based implementation.
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.
Problem
When
PostgreSQLLoglogs incoming messages viaonIncoming(), thesendercompidandtargetcompidcolumns inmessages_logare alwayspopulated from the local
SessionIDobject perspective.This means if your session is
SENDER -> TARGET, an incoming messageFROM the counterparty appears in the database as:
When it should be:
This makes it impossible to distinguish incoming from outgoing messages
by querying sendercompid/targetcompid columns without parsing the raw
FIX text field.
Fix
Added
isIncomingboolean parameter (defaultfalse) toinsert().When
true(called fromonIncoming()),getSenderCompID()andgetTargetCompID()are swapped to correctly reflect actual messagedirection.
No breaking changes — existing behavior preserved for outgoing and
event logging.
Also Fixed
Header guard order:
#ifndef FIX_POSTGRESQLLOG_Hwas placedbefore the
HAVE_POSTGRESQLcheck. Restored correct order so theHAVE_POSTGRESQLerror fires before the include guard is evaluated.Incorrect class comment:
PostgreSQLLogFactorywas documentedas "MySQL based implementation" — corrected to "PostgreSQL".
Testing
Verified against a live FIX acceptor (FIXT.1.1) with multiple sessions.
After fix,
messages_logcorrectly shows: