Fix potential connection leak (#3247)

We didn't rollback/commit after getting events, now we're rolling back
since we didn't change anything.
This commit is contained in:
Till 2023-11-08 14:22:20 +01:00 committed by GitHub
parent 5f872f4a82
commit ee73a90aea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -44,7 +44,7 @@ func GetEvent(
rsAPI api.SyncRoomserverAPI,
) util.JSONResponse {
ctx := req.Context()
db, err := syncDB.NewDatabaseTransaction(ctx)
db, err := syncDB.NewDatabaseSnapshot(ctx)
logger := util.GetLogger(ctx).WithFields(logrus.Fields{
"event_id": eventID,
"room_id": rawRoomID,
@ -56,6 +56,7 @@ func GetEvent(
JSON: spec.InternalServerError{},
}
}
defer db.Rollback() // nolint: errcheck
roomID, err := spec.NewRoomID(rawRoomID)
if err != nil {