aboutsummaryrefslogtreecommitdiff
path: root/roomserver
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2023-07-04 17:15:44 +0200
committerGitHub <noreply@github.com>2023-07-04 17:15:44 +0200
commit4c3a526e1b82b87be2e2640987736ba0ac8e1f4e (patch)
treea74f00e877793b666de1995b14db2dd2e6d2cd9f /roomserver
parent2ee03fd65721e6a95ad3c6b4f2da7cd8b762041a (diff)
Fix adding state events to the database (#3133)
When we're adding state to the database, we check which eventNIDs are already in a block, if we already have that eventNID, we remove it from the list. In its current form we would skip over eventNIDs in the case we already found a match (we're decrementing `i` twice) My theory is, that when we later get the state blocks, we are receiving "too many" eventNIDs (well, yea, we stored too many), which may or may not can result in state resets when comparing different state snapshots. (e.g. when adding state we stored a eventNID by accident because we skipped it, later we add more state and are not adding it because we don't skip it)
Diffstat (limited to 'roomserver')
-rw-r--r--roomserver/storage/shared/storage.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/roomserver/storage/shared/storage.go b/roomserver/storage/shared/storage.go
index fc3ace6a..3c8b69c3 100644
--- a/roomserver/storage/shared/storage.go
+++ b/roomserver/storage/shared/storage.go
@@ -282,17 +282,17 @@ func (d *Database) addState(
var found bool
for i := len(state) - 1; i >= 0; i-- {
found = false
+ blocksLoop:
for _, events := range blocks {
for _, event := range events {
if state[i].EventNID == event {
found = true
- break
+ break blocksLoop
}
}
}
if found {
state = append(state[:i], state[i+1:]...)
- i--
}
}
}