mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-22 11:41:38 +00:00
Wrap NewMembershipUpdater in a db writer (#1515)
This commit is contained in:
parent
73bc28b11f
commit
d7ea814fa8
@ -93,7 +93,7 @@ func trackGoID(query string) {
|
|||||||
if strings.HasPrefix(q, "SELECT") {
|
if strings.HasPrefix(q, "SELECT") {
|
||||||
return // SELECTs can go on other goroutines
|
return // SELECTs can go on other goroutines
|
||||||
}
|
}
|
||||||
logrus.Warnf("unsafe goid: SQL executed not on an ExclusiveWriter: %s", q)
|
logrus.Warnf("unsafe goid %d: SQL executed not on an ExclusiveWriter: %s", thisGoID, q)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open opens a database specified by its database driver name and a driver-specific data source name,
|
// Open opens a database specified by its database driver name and a driver-specific data source name,
|
||||||
|
@ -22,12 +22,21 @@ func NewMembershipUpdater(
|
|||||||
ctx context.Context, d *Database, txn *sql.Tx, roomID, targetUserID string,
|
ctx context.Context, d *Database, txn *sql.Tx, roomID, targetUserID string,
|
||||||
targetLocal bool, roomVersion gomatrixserverlib.RoomVersion,
|
targetLocal bool, roomVersion gomatrixserverlib.RoomVersion,
|
||||||
) (*MembershipUpdater, error) {
|
) (*MembershipUpdater, error) {
|
||||||
roomNID, err := d.assignRoomNID(ctx, txn, roomID, roomVersion)
|
var roomNID types.RoomNID
|
||||||
if err != nil {
|
var targetUserNID types.EventStateKeyNID
|
||||||
return nil, err
|
var err error
|
||||||
}
|
err = d.Writer.Do(d.DB, txn, func(txn *sql.Tx) error {
|
||||||
|
roomNID, err = d.assignRoomNID(ctx, txn, roomID, roomVersion)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
targetUserNID, err := d.assignStateKeyNID(ctx, txn, targetUserID)
|
targetUserNID, err = d.assignStateKeyNID(ctx, txn, targetUserID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user