matrix-org / dendrite

Dendrite is a second-generation Matrix homeserver written in Go!
https://matrix-org.github.io/dendrite/
Apache License 2.0
5.67k stars 664 forks source link

panic on startup: "could not save account data" #1745

Closed zephryn closed 3 years ago

zephryn commented 3 years ago

Background information

Description

after starting my dendrite service, it panics with the following log:

time=(time of log) level=panic msg="could not save account data" func="onMessage\n\t" file=" [github.com/matrix-org/dendrite/syncapi/consumers/clientapi.go:97]" error="UNIQUE constraint failed: syncapi_account_data_type.id" room_id=(matrix room id) type=m.fully_read
panic: (*logrus.Entry) 0xc000189b90
goroutine 93 [running]:
github.com/sirupsen/logrus.Entry.log(0xc0000dac40, 0xc0003c78c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/sirupsen/logrus@v1.7.0/entry.go:255 +0x325
github.com/sirupsen/logrus.(*Entry).Log(0xc000189b20, 0x0, 0xc000377b08, 0x1, 0x1)
        github.com/sirupsen/logrus@v1.7.0/entry.go:283 +0xf0
github.com/sirupsen/logrus.(*Entry).Logf(0xc000189b20, 0xc000000000, 0x561249435606, 0x1b, 0x0, 0x0, 0x0)
        github.com/sirupsen/logrus@v1.7.0/entry.go:329 +0xe5
github.com/sirupsen/logrus.(*Entry).Panicf(...)
        github.com/sirupsen/logrus@v1.7.0/entry.go:367
github.com/matrix-org/dendrite/syncapi/consumers.(*OutputClientDataConsumer).onMessage(0xc0002c47e0, 0xc000321400, 0x1, 0x101)
        github.com/matrix-org/dendrite/syncapi/consumers/clientapi.go:97 +0x725
github.com/matrix-org/dendrite/internal.(*ContinualConsumer).consumePartition(0xc0001946c0, 0x56124983e360, 0xc00017af20)
        github.com/matrix-org/dendrite/internal/consumers.go:126 +0xe2
created by github.com/matrix-org/dendrite/internal.(*ContinualConsumer).StartOffsets
        github.com/matrix-org/dendrite/internal/consumers.go:107 +0x545

unfortunately i don't have much in terms of steps for reproducing this from a clean db, but i hope this is enough to help.

neilalexander commented 3 years ago

@Kegsay Can you think of any reason why we shouldn't just do an ON CONFLICT handle here and update it gracefully?

Edit: It appears we should do this already, let me dig into what's going on.