Move the missing state event check inside the SQL layer, comment on why the error message is unhelpful

This commit is contained in:
Mark Haines 2017-02-09 15:30:16 +00:00
parent 00e6b86ba7
commit 70645ea2c7
2 changed files with 10 additions and 6 deletions

View file

@ -1,7 +1,6 @@
package input
import (
"fmt"
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/roomserver/types"
"github.com/matrix-org/gomatrixserverlib"
@ -70,10 +69,6 @@ func checkAuthEvents(db RoomEventDatabase, event gomatrixserverlib.Event, authEv
if err != nil {
return nil, err
}
if len(authStateEntries) < len(authEventIDs) {
return nil, fmt.Errorf("input: Some of the auth event IDs were missing from the database")
}
// TODO: check for duplicate state keys here.
// Work out which of the state events we actually need.

View file

@ -2,6 +2,7 @@ package storage
import (
"database/sql"
"fmt"
"github.com/lib/pq"
"github.com/matrix-org/dendrite/roomserver/types"
)
@ -409,7 +410,15 @@ func (s *statements) bulkSelectStateEventByIDID(eventIDs []string) ([]types.Stat
return nil, err
}
}
return results[:i], err
if i < len(eventIDs) {
// If there are fewer rows returned than IDs then we were asked to lookup event IDs we don't have.
// We don't know which ones were missing because we don't return the string IDs in the query.
// However it should be possible debug this by replaying queries or entries from the input kafka logs.
// If this turns out to be impossible and we do need the debug information here, it would be better
// to do it as a separate query rather than slowing down/complicating the common case.
return nil, fmt.Errorf("storage: state event IDs missing from the database")
}
return results, err
}
func (s *statements) prepareEventJSON(db *sql.DB) (err error) {