[-] handle pg sink being down gracefully, fixes #1426#1429
Open
0xgouda wants to merge 3 commits into
Open
Conversation
20a1e76 to
7e6eead
Compare
Coverage Report for CI Build 26842545543Coverage increased (+0.2%) to 86.102%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
d38deb2 to
495c410
Compare
pashagolub
reviewed
Jun 2, 2026
Comment on lines
+441
to
447
| if _, ok := err.(*pgconn.ConnectError); ok { | ||
| logger.Errorf("Sink DB not reachable, dropping %d cached measurements", len(msgs)) | ||
| break | ||
| } | ||
| if PgError, ok := err.(*pgconn.PgError); ok { | ||
| pgw.forceRecreatePartitions = PgError.Code == "23514" | ||
| } |
Collaborator
There was a problem hiding this comment.
Should we use switch+errors.Is() here?
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.
CopyFrom()fails due to a connection error, assume that the sink DB is down and break from the write loop without writing the metrics.New behaviour:
Now, pgwatch will issue a retry connection and possibly complain with a connection error once per flush.
Also, I chose to drop the to-be-written metrics from the pg sink cache so the system doesn't get slow as the measurements accumulate which will then trigger a
highLoadTimeOutdelay (i.e. 5 seconds) for every new measurement added!!!, which won't be good if other sinks are expecting the data (e.g, Prometheus or an additional pg sink).Closes #1426