From d370bf278067a7eeae1428da87bfcd690ec2e0e8 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 30 Sep 2022 10:32:31 +0100 Subject: [PATCH] Commit transaction for `/messages` --- syncapi/routing/messages.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/syncapi/routing/messages.go b/syncapi/routing/messages.go index a59b3bcc5..bc43146b4 100644 --- a/syncapi/routing/messages.go +++ b/syncapi/routing/messages.go @@ -27,6 +27,7 @@ import ( "github.com/matrix-org/dendrite/clientapi/jsonerror" "github.com/matrix-org/dendrite/internal/caching" + "github.com/matrix-org/dendrite/internal/sqlutil" "github.com/matrix-org/dendrite/roomserver/api" "github.com/matrix-org/dendrite/setup/config" "github.com/matrix-org/dendrite/syncapi/internal" @@ -75,7 +76,8 @@ func OnIncomingMessagesRequest( if err != nil { return jsonerror.InternalServerError() } - defer snapshot.Rollback() // nolint:errcheck + var succeeded bool + defer sqlutil.EndTransaction(snapshot, &succeeded) // check if the user has already forgotten about this room isForgotten, roomExists, err := checkIsRoomForgotten(req.Context(), roomID, device.UserID, rsAPI) @@ -237,6 +239,7 @@ func OnIncomingMessagesRequest( } // Respond with the events. + succeeded = true return util.JSONResponse{ Code: http.StatusOK, JSON: res,