[-] fix serialization of errors in db logger#744
Merged
pashagolub merged 2 commits intocybertec-postgresql:masterfrom Mar 9, 2026
Merged
[-] fix serialization of errors in db logger#744pashagolub merged 2 commits intocybertec-postgresql:masterfrom
pashagolub merged 2 commits intocybertec-postgresql:masterfrom
Conversation
fd46ae1 to
e23fc65
Compare
Pull Request Test Coverage Report for Build 22749875293Details
💛 - Coveralls |
e23fc65 to
ec3a479
Compare
|
@MaxaiZer I tried to reproduce the 3 cases you are describing using a pg_timetable instance built from master and I can't see them. I get all outputs for the # no parameters, doesn't contain a pgconn.PgError struct
{"chain":39,"error":"ERROR: there is no parameter $1 (SQLSTATE 42P02)","level":"error","msg":"Task execution failed","task":39,"time":"2026-03-06T08:33:53+02:00","vxid":17179871472}
# 1 invalid parameter, doesn't contain struct with no actual error message
{"chain":11,"error":"json: cannot unmarshal string into Go value of type []interface {}","level":"error","msg":"Task execution failed","task":11,"time":"2026-03-06T08:12:29+02:00","vxid":17179870230}
# 2 parameters (1 correct and 1 incorrect), doesn't return empty error
{"chain":36,"error":"ERROR: invalid input syntax for type boolean: \"7\" (SQLSTATE 22P02)","level":"error","msg":"Task execution failed","task":36,"time":"2026-03-06T08:25:12+02:00","vxid":17179871259}Am I missing something? can you add reproduction steps? but I can still see the value of the below block that you added: if parseErr := json.Unmarshal([]byte(val), ¶ms); parseErr != nil {
err = errors.Join(err, fmt.Errorf("failed to parse parameter %s: %w", val, parseErr)) |
Contributor
Author
|
@0xgouda Oh, I should have clarified: this is related to db logging (timetable.log table) |
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.
Task errors are currently serialized inconsistently. If ExecuteSQLCommand fails during this block:
message_data.errorin the "Task execution failed" log entry (in thetimetable.logtable) will contain a full pgconn.PgError struct:{"task": 1, "vxid": 1, "chain": 1, "error": {"Code": "42P02", "File": "parse_expr.c", "Hint": "", "Line": 901, "Where": "", "Detail": "", "Message": "there is no parameter $1", "Routine": "transformParamRef", "Position": 175, "Severity": "ERROR", "TableName": "", "ColumnName": "", "SchemaName": "", "DataTypeName": "", "InternalQuery": "", "ConstraintName": "", "InternalPosition": 0, "SeverityUnlocalized": "ERROR"}}If it fails during parameter parsing:
message_data.errorwill contain struct with no actual error message:{"task": 1, "vxid": 1, "chain": 1, "error": {"Type": {}, "Field": "", "Value": "string", "Offset": 9, "Struct": ""}}And if ExecuteSQLCommand returns joined errors,
message_data.errorbecomes empty:{"task": 1, "vxid": 1, "chain": 1, "error": {}}After fix examples:
{"task": 1, "vxid": 1, "chain": 1, "error": "ERROR: there is no parameter $1 (SQLSTATE 42P02)"}{"task": 1, "vxid": 1, "chain": 1, "error": "failed to parse parameter \"1 month\": json: cannot unmarshal string into Go value of type []interface {}"}{"task": 1, "vxid": 1, "chain": 1, "error": "ERROR: procedure F_CreatePartitions(date, date) does not exist (SQLSTATE 42883)\nfailed to parse parameter \"1 month\": json: cannot unmarshal string into Go value of type []interface {}"}