mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 13:22:46 +00:00
Fix broken /sync
due to transaction error
This commit is contained in:
parent
aa8ec1acbf
commit
ee40a29e55
15 changed files with 45 additions and 8 deletions
|
@ -25,6 +25,7 @@ import (
|
|||
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
"github.com/matrix-org/dendrite/internal/caching"
|
||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||
roomserver "github.com/matrix-org/dendrite/roomserver/api"
|
||||
"github.com/matrix-org/dendrite/syncapi/internal"
|
||||
"github.com/matrix-org/dendrite/syncapi/storage"
|
||||
|
@ -55,7 +56,8 @@ func Context(
|
|||
if err != nil {
|
||||
return jsonerror.InternalServerError()
|
||||
}
|
||||
defer snapshot.Rollback() // nolint:errcheck
|
||||
var succeeded bool
|
||||
defer sqlutil.EndTransactionWithCheck(snapshot, &succeeded, &err)
|
||||
|
||||
filter, err := parseRoomEventFilter(req)
|
||||
if err != nil {
|
||||
|
@ -184,6 +186,7 @@ func Context(
|
|||
response.End = end.String()
|
||||
response.Start = start.String()
|
||||
}
|
||||
succeeded = true
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
JSON: response,
|
||||
|
|
|
@ -31,6 +31,7 @@ import (
|
|||
"github.com/matrix-org/dendrite/clientapi/httputil"
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
"github.com/matrix-org/dendrite/internal/fulltext"
|
||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||
"github.com/matrix-org/dendrite/syncapi/storage"
|
||||
"github.com/matrix-org/dendrite/userapi/api"
|
||||
)
|
||||
|
@ -65,7 +66,8 @@ func Search(req *http.Request, device *api.Device, syncDB storage.Database, fts
|
|||
if err != nil {
|
||||
return jsonerror.InternalServerError()
|
||||
}
|
||||
defer snapshot.Rollback() // nolint:errcheck
|
||||
var succeeded bool
|
||||
defer sqlutil.EndTransactionWithCheck(snapshot, &succeeded, &err)
|
||||
|
||||
// only search rooms the user is actually joined to
|
||||
joinedRooms, err := snapshot.RoomIDsWithMembership(ctx, device.UserID, "join")
|
||||
|
@ -249,6 +251,7 @@ func Search(req *http.Request, device *api.Device, syncDB storage.Database, fts
|
|||
|
||||
logrus.Debugf("Full search request took %v", time.Since(start))
|
||||
|
||||
succeeded = true
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
JSON: res,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue