Set max_age for roomserver input stream to avoid excessive interior deletes

This commit is contained in:
Neil Alexander 2023-07-07 17:03:12 +01:00 committed by Neil Twigg
parent c08c7405db
commit 781b52768c
No known key found for this signature in database
GPG key ID: 8993BAD6C5E51CD8
2 changed files with 10 additions and 8 deletions

View file

@ -125,15 +125,16 @@ func setupNATS(process *process.ProcessContext, cfg *config.JetStream, nc *natsc
// with the subject "Foo", "Foo.Bar" or "Foo.Bar.Baz" etc. // with the subject "Foo", "Foo.Bar" or "Foo.Bar.Baz" etc.
subjects = []string{name, name + ".>"} subjects = []string{name, name + ".>"}
} }
if info != nil { if info != nil && !reflect.DeepEqual(info.Config, stream) {
switch { // If the stream config doesn't match what we expect, try to update
case !reflect.DeepEqual(info.Config.Subjects, subjects): // it. If that doesn't work then try to blow it away and we'll then
fallthrough // recreate it in the next section.
case info.Config.Retention != stream.Retention: if info, err = s.UpdateStream(stream); err != nil {
fallthrough logrus.WithError(err).Warnf("Unable to update stream %q, recreating...", name)
case info.Config.Storage != stream.Storage: // We failed to update the stream, this is a last attempt to get
// things working but may result in data loss.
if err = s.DeleteStream(name); err != nil { if err = s.DeleteStream(name); err != nil {
logrus.WithError(err).Fatal("Unable to delete stream") logrus.WithError(err).Fatalf("Unable to delete stream %q", name)
} }
info = nil info = nil
} }

View file

@ -48,6 +48,7 @@ var streams = []*nats.StreamConfig{
Name: InputRoomEvent, Name: InputRoomEvent,
Retention: nats.InterestPolicy, Retention: nats.InterestPolicy,
Storage: nats.FileStorage, Storage: nats.FileStorage,
MaxAge: time.Hour * 24,
}, },
{ {
Name: InputDeviceListUpdate, Name: InputDeviceListUpdate,