diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-08-19 15:38:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-19 15:38:27 +0100 |
commit | b24747b305a0770fdd746655e702aa1c1c049765 (patch) | |
tree | 88d94b762fafb4852421eb243313edbfc96ccfa9 /roomserver/state | |
parent | 775b04d776ddc06fdee5ece6a407008f00edb7f2 (diff) |
Transaction writer changes, move roomserver writers (#1285)
* Updated TransactionWriters, moved locks in roomserver, various other tweaks
* Fix redaction deadlocks
* Fix lint issue
* Rename SQLiteTransactionWriter to ExclusiveTransactionWriter
* Fix us not sending transactions through in latest events updater
Diffstat (limited to 'roomserver/state')
-rw-r--r-- | roomserver/state/state.go | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/roomserver/state/state.go b/roomserver/state/state.go index d5be4a90..b9ad4a50 100644 --- a/roomserver/state/state.go +++ b/roomserver/state/state.go @@ -558,7 +558,11 @@ func (v StateResolution) CalculateAndStoreStateAfterEvents( // 2) There weren't any prev_events for this event so the state is // empty. metrics.algorithm = "empty_state" - return metrics.stop(v.db.AddState(ctx, roomNID, nil, nil)) + stateNID, err := v.db.AddState(ctx, roomNID, nil, nil) + if err != nil { + err = fmt.Errorf("v.db.AddState: %w", err) + } + return metrics.stop(stateNID, err) } if len(prevStates) == 1 { @@ -578,22 +582,30 @@ func (v StateResolution) CalculateAndStoreStateAfterEvents( ) if err != nil { metrics.algorithm = "_load_state_blocks" - return metrics.stop(0, err) + return metrics.stop(0, fmt.Errorf("v.db.StateBlockNIDs: %w", err)) } stateBlockNIDs := stateBlockNIDLists[0].StateBlockNIDs if len(stateBlockNIDs) < maxStateBlockNIDs { // 4) The number of state data blocks is small enough that we can just // add the state event as a block of size one to the end of the blocks. metrics.algorithm = "single_delta" - return metrics.stop(v.db.AddState( + stateNID, err := v.db.AddState( ctx, roomNID, stateBlockNIDs, []types.StateEntry{prevState.StateEntry}, - )) + ) + if err != nil { + err = fmt.Errorf("v.db.AddState: %w", err) + } + return metrics.stop(stateNID, err) } // If there are too many deltas then we need to calculate the full state // So fall through to calculateAndStoreStateAfterManyEvents } - return v.calculateAndStoreStateAfterManyEvents(ctx, roomNID, prevStates, metrics) + stateNID, err := v.calculateAndStoreStateAfterManyEvents(ctx, roomNID, prevStates, metrics) + if err != nil { + return 0, fmt.Errorf("v.calculateAndStoreStateAfterManyEvents: %w", err) + } + return stateNID, nil } // maxStateBlockNIDs is the maximum number of state data blocks to use to encode a snapshot of room state. |