Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor client info manager #1700

Merged
merged 2 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added test
  • Loading branch information
scudette committed Apr 5, 2022
commit d996b64d36e003fabb487b9c0346320e8929fcfe
2 changes: 2 additions & 0 deletions config/proto/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,8 @@ message FrontendResourceControl {
// client info from cache too frequently can result in a lot more
// IO. Default size of this cache is the expected_clients above.
uint64 client_info_lru_ttl = 27;

// How often to sync client info records (ms)
uint64 client_info_sync_time = 29;

// The journal files are used to queue messages between event
Expand Down
4 changes: 1 addition & 3 deletions services/client_info/client_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ package client_info
import (
"context"
"errors"
"fmt"
"sync"
"time"

Expand Down Expand Up @@ -201,7 +200,6 @@ func (self *CachedInfo) Flush() error {
return err
}

fmt.Printf("Writing client info for %v\n", client_id)
// A blind write will eventually hit the disk.
client_path_manager := paths.NewClientPathManager(client_id)
db.SetSubjectWithCompletion(
Expand Down Expand Up @@ -307,7 +305,7 @@ func (self *ClientInfoManager) MutationSync(
sync_time := time.Duration(10) * time.Second
if config_obj.Frontend != nil && config_obj.Frontend.Resources != nil &&
config_obj.Frontend.Resources.ClientInfoSyncTime > 0 {
sync_time = time.Duration(config_obj.Frontend.Resources.ClientInfoSyncTime) * time.Second
sync_time = time.Duration(config_obj.Frontend.Resources.ClientInfoSyncTime) * time.Millisecond
}

journal, err := services.GetJournal()
Expand Down
18 changes: 18 additions & 0 deletions services/client_info/client_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ type ClientInfoTestSuite struct {
}

func (self *ClientInfoTestSuite) SetupTest() {
self.ConfigObj = self.TestSuite.LoadConfig()
self.ConfigObj.Frontend.Resources.ClientInfoSyncTime = 1

self.TestSuite.SetupTest()

// Create a client in the datastore
Expand Down Expand Up @@ -125,6 +128,21 @@ func (self *ClientInfoTestSuite) TestMasterMinion() {
assert.NoError(self.T(), err)
return client_info.IpAddress == "127.0.0.1"
})

// Make sure we actually write the result in the datastore.
client_path_manager := paths.NewClientPathManager(self.client_id)

// Read the main client record
db, err := datastore.GetDB(self.ConfigObj)
assert.NoError(self.T(), err)

vtesting.WaitUntil(2*time.Second, self.T(), func() bool {
ping_info := &services.ClientInfo{}
db.GetSubject(self.ConfigObj, client_path_manager.Ping(),
ping_info)
utils.Debug(ping_info)
return ping_info.IpAddress == "127.0.0.1"
})
}

func TestClientInfoService(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions services/journal/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,9 @@ func (self *ReplicationService) watchOnce(
subctx, cancel := context.WithCancel(ctx)

stream, err := self.api_client.WatchEvent(subctx, &api_proto.EventRequest{
Queue: queue,
WatcherName: watcher_name,
Queue: queue,
WatcherName: watcher_name + "_" +
services.GetNodeName(self.config_obj.Frontend),
})
if err != nil {
close(output_chan)
Expand Down