-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Heartbeat writer can always generate on-demand leased heartbeats, even if not at all configured #16014
Heartbeat writer can always generate on-demand leased heartbeats, even if not at all configured #16014
Changes from 15 commits
79a37f4
f89eeb0
2d29eda
1116f80
02ca773
ad8950a
58be5f2
1fd2b41
0ba8682
236f074
63ab624
a8673c1
2d0fb4a
8d39664
875a2d6
73046cf
81b9d53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,8 +52,7 @@ var ( | |
|
||
// ReplTracker tracks replication lag. | ||
type ReplTracker struct { | ||
mode string | ||
forceHeartbeat bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, so in effect the old Along with the new relevant defaults being:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that is correct! |
||
mode string | ||
|
||
mu sync.Mutex | ||
isPrimary bool | ||
|
@@ -66,11 +65,10 @@ type ReplTracker struct { | |
// NewReplTracker creates a new ReplTracker. | ||
func NewReplTracker(env tabletenv.Env, alias *topodatapb.TabletAlias) *ReplTracker { | ||
return &ReplTracker{ | ||
mode: env.Config().ReplicationTracker.Mode, | ||
forceHeartbeat: env.Config().ReplicationTracker.HeartbeatOnDemand > 0, | ||
hw: newHeartbeatWriter(env, alias), | ||
hr: newHeartbeatReader(env), | ||
poller: &poller{}, | ||
mode: env.Config().ReplicationTracker.Mode, | ||
hw: newHeartbeatWriter(env, alias), | ||
hr: newHeartbeatReader(env), | ||
poller: &poller{}, | ||
} | ||
} | ||
|
||
|
@@ -97,9 +95,7 @@ func (rt *ReplTracker) MakePrimary() { | |
rt.hr.Close() | ||
rt.hw.Open() | ||
} | ||
if rt.forceHeartbeat { | ||
rt.hw.Open() | ||
} | ||
rt.hw.Open() | ||
} | ||
|
||
// MakeNonPrimary must be called if the tablet type becomes non-PRIMARY. | ||
|
@@ -117,9 +113,7 @@ func (rt *ReplTracker) MakeNonPrimary() { | |
// Run the status once to pre-initialize values. | ||
rt.poller.Status() | ||
} | ||
if rt.forceHeartbeat { | ||
rt.hw.Close() | ||
} | ||
rt.hw.Close() | ||
} | ||
|
||
// Close closes ReplTracker. | ||
|
@@ -147,5 +141,9 @@ func (rt *ReplTracker) Status() (time.Duration, error) { | |
// EnableHeartbeat enables or disables writes of heartbeat. This functionality | ||
// is only used by tests. | ||
func (rt *ReplTracker) EnableHeartbeat(enable bool) { | ||
rt.hw.enableWrites(enable) | ||
if enable { | ||
rt.hw.enableWrites() | ||
} else { | ||
rt.hw.disableWrites() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always nice to see a new unit test for a new function :)