Skip to content

Commit

Permalink
fix(notification): support notification retention configuration (#515)
Browse files Browse the repository at this point in the history
### Motivation

the PR #353 remove the default configuration of notification retention.
which causes unexpected behaviour when user uses oxia as metadata
service.

especially for distributed lock. the revalidate after session expired
will be never triggered.

the current value:

```
{"level":"info","time":"2024-09-18T07:11:48.692719842Z","config":{"PublicServiceAddr":"0.0.0.0:6648","InternalServiceAddr":"0.0.0.0:6649","PeerTLS":null,"ServerTLS":null,"InternalServerTLS":null,"MetricsServiceAddr":"0.0.0.0:8080","AuthOptions":{"ProviderName":"","ProviderParams":""},"DataDir":"/data/db","WalDir":"/data/wal","WalRetentionTime":3600000000000,"WalSyncData":true,"NotificationsRetentionTime":0,"DbBlockCacheMB":4096},"time":"2024-09-18T07:11:48.693399934Z","message":"Starting Oxia server"}
```

### Modification

- Add `NotificationsRetentionTime` back and the default time is 1 hour.

### Others


We might need consider filter some notification on the server when user
use oxia as some storage index service(high throughput of W/R) to avoid
dispatching too much messages that will impact performance.
  • Loading branch information
mattisonchao committed Sep 19, 2024
1 parent 1934d55 commit f21df14
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/server/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func init() {
Cmd.Flags().StringVar(&conf.DataDir, "data-dir", "./data/db", "Directory where to store data")
Cmd.Flags().StringVar(&conf.WalDir, "wal-dir", "./data/wal", "Directory for write-ahead-logs")
Cmd.Flags().DurationVar(&conf.WalRetentionTime, "wal-retention-time", 1*time.Hour, "Retention time for the entries in the write-ahead-log")
Cmd.Flags().DurationVar(&conf.NotificationsRetentionTime, "notifications-retention-time", 1*time.Hour, "Retention time for the db notifications to clients")

Cmd.Flags().BoolVar(&conf.WalSyncData, "wal-sync-data", true, "Whether to sync data in write-ahead-log")
Cmd.Flags().Int64Var(&conf.DbBlockCacheMB, "db-cache-size-mb", kv.DefaultFactoryOptions.CacheSizeMB,
"Max size of the shared DB cache")
Expand Down
56 changes: 56 additions & 0 deletions cmd/server/cmd_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2024 StreamNative, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package server

import (
"strings"
"testing"
"time"

"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"

"github.com/streamnative/oxia/server"
)

func TestServerCmd(t *testing.T) {
for _, test := range []struct {
args []string
expectedConf server.Config
isErr bool
}{
{[]string{}, server.Config{
PublicServiceAddr: "0.0.0.0:6648",
InternalServiceAddr: "0.0.0.0:6649",
MetricsServiceAddr: "0.0.0.0:8080",
DataDir: "./data/db",
WalDir: "./data/wal",
WalRetentionTime: 1 * time.Hour,
WalSyncData: true,
NotificationsRetentionTime: 1 * time.Hour,
DbBlockCacheMB: 100,
}, false},
} {
t.Run(strings.Join(test.args, "_"), func(t *testing.T) {
Cmd.SetArgs(test.args)
Cmd.RunE = func(cmd *cobra.Command, args []string) error {
return nil
}
err := Cmd.Execute()
assert.Equal(t, test.isErr, err != nil)
assert.Equal(t, test.expectedConf, conf)
})
}
}

0 comments on commit f21df14

Please sign in to comment.