From e35ade3e0587962c96a9f67466f586a27e4b0f14 Mon Sep 17 00:00:00 2001 From: Matvey Arye Date: Tue, 27 Sep 2022 14:18:15 -0400 Subject: [PATCH 1/2] Fix mxid bloat ON CONFLICT clauses can cause row locks, which uses multitransact mxids. Therefore, avoid using long transactions with ON CONFLICT. This patch forces all inserts with ON CONFLICT to commit metrics in separate transactions. --- pkg/pgmodel/ingestor/copier.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/pgmodel/ingestor/copier.go b/pkg/pgmodel/ingestor/copier.go index df3599d9d6..e6287462a2 100644 --- a/pkg/pgmodel/ingestor/copier.go +++ b/pkg/pgmodel/ingestor/copier.go @@ -205,14 +205,11 @@ func doInsertOrFallback(ctx context.Context, conn pgxconn.PgxConn, reqs ...copyR defer span.End() err, _ := insertSeries(ctx, conn, false, reqs...) if err != nil { - if isPGUniqueViolation(err) { - err, _ = insertSeries(ctx, conn, true, reqs...) - } - if err != nil { + if !isPGUniqueViolation(err) { log.Error("msg", err) - insertBatchErrorFallback(ctx, conn, reqs...) - return } + insertBatchErrorFallback(ctx, conn, reqs...) + return } for i := range reqs { @@ -350,6 +347,13 @@ func insertSeries(ctx context.Context, conn pgxconn.PgxConn, onConflict bool, re insertStart := time.Now() lowestEpoch := pgmodel.SeriesEpoch(math.MaxInt64) lowestMinTime := int64(math.MaxInt64) + + if onConflict && len(reqs) > 1 { + //holding on to long locks with ON CONFLICT considered harmful becase of mxid bloat + //no code path should use this. We leave this here to protect against this case in the future. + panic("should not try to insert to more than one metric per transaction with ON CONFLICT") + } + tx, err := conn.BeginTx(ctx) if err != nil { return fmt.Errorf("failed to start transaction for inserting metrics: %v", err), lowestMinTime From 5e3521b59e493a770217d2c9039acf7f81a2dd6e Mon Sep 17 00:00:00 2001 From: Matvey Arye Date: Tue, 27 Sep 2022 14:43:38 -0400 Subject: [PATCH 2/2] upload release assets --- .github/workflows/go-releaser.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/go-releaser.yml b/.github/workflows/go-releaser.yml index 2e36d1d2ad..b3aedab010 100644 --- a/.github/workflows/go-releaser.yml +++ b/.github/workflows/go-releaser.yml @@ -86,3 +86,11 @@ jobs: for distro in ${RHEL_DISTROS}; do package_cloud push "${repo}/${distro}" dist/*.rpm done + + - name: Upload assets + uses: actions/upload-artifact@v3 + with: + name: release-assets + path: | + dist/*.deb + dist/*.rpm \ No newline at end of file