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.
subjects = []string{name, name + ".>"}
}
if info != nil {
switch {
case !reflect.DeepEqual(info.Config.Subjects, subjects):
fallthrough
case info.Config.Retention != stream.Retention:
fallthrough
case info.Config.Storage != stream.Storage:
if info != nil && !reflect.DeepEqual(info.Config, stream) {
// If the stream config doesn't match what we expect, try to update
// it. If that doesn't work then try to blow it away and we'll then
// recreate it in the next section.
if info, err = s.UpdateStream(stream); err != nil {
logrus.WithError(err).Warnf("Unable to update stream %q, recreating...", name)
// 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 {
logrus.WithError(err).Fatal("Unable to delete stream")
logrus.WithError(err).Fatalf("Unable to delete stream %q", name)
}
info = nil
}

View file

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