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: change leader election semantics. #238

Merged
merged 14 commits into from
Mar 17, 2022
Merged

refactor: change leader election semantics. #238

merged 14 commits into from
Mar 17, 2022

Conversation

Reasno
Copy link
Member

@Reasno Reasno commented Mar 10, 2022

Now leader election campaign will not return when the node beomes leader, instead it will block until the leader election session exits, updating status proactively. This change will make leader election status more accurate.

Now leader election campaign will not return when the node beomes leader, instead it will block until the leader election session exists, updating status proactively. This change will make leader election status more accurate.
@Reasno Reasno requested a review from GGXXLL March 10, 2022 03:05
@codecov
Copy link

codecov bot commented Mar 14, 2022

Codecov Report

Merging #238 (65cba73) into v0.13.x (d70e444) will decrease coverage by 0.30%.
The diff coverage is 63.01%.

@@             Coverage Diff             @@
##           v0.13.x     #238      +/-   ##
===========================================
- Coverage    82.88%   82.57%   -0.31%     
===========================================
  Files           94       96       +2     
  Lines         3751     3840      +89     
===========================================
+ Hits          3109     3171      +62     
- Misses         475      492      +17     
- Partials       167      177      +10     
Impacted Files Coverage Δ
leader/dependency.go 86.66% <ø> (-0.18%) ⬇️
leader/election.go 63.15% <42.85%> (-9.07%) ⬇️
cron/options.go 80.64% <54.34%> (-15.51%) ⬇️
leader/leaderredis/redis.go 84.00% <87.50%> (-2.67%) ⬇️
leader/leaderetcd/etcd.go 71.42% <100.00%> (+4.76%) ⬆️
serve.go 85.31% <0.00%> (-1.40%) ⬇️
dag/vertex_options.go
dag/graph.go
dag/vertex.go
dag/dag.go
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d70e444...65cba73. Read the comment docs.

@@ -2,12 +2,17 @@ package cron

import (
"context"
_ "embed"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a blank import should be only in a main or test package, or have a comment justifying it

@@ -22,7 +22,16 @@ func TestElection(t *testing.T) {
return
}
addrs := strings.Split(os.Getenv("ETCD_ADDR"), ",")
dispatcher := &events.Event[*Status]{}
dispatcher := Dispatcher(&events.Event[*Status]{})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing ',' in argument list (and 10 more errors)

@@ -20,36 +23,41 @@ func TestNewEtcdDriver(t *testing.T) {
}
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
dispatcher := &events.Event[*leader.Status]{}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected ';', found '{'

@Reasno Reasno merged commit 3805594 into v0.13.x Mar 17, 2022
@Reasno Reasno deleted the v0.13.x-leader branch March 17, 2022 08:04
GGXXLL added a commit that referenced this pull request May 19, 2022
* fix(factory): on reload, close the connection right away.

graceful shutdown logic should be implemented in the close function, not in the factory.

* fix(cron): test flakes

* feat: add eventv2

* wip: prototyping generics api

* wip: prototyping generics api

* wip: prototyping generics api

* feat: ctxmeta support generic

* fix: asyncContext.Value interface to any

* wip: generics

* wip: add once to event

* refactor: remove text package

* feat: interface{} to any

* refactor: remove deprecated cron

* test: workflow go-version 1.18beta2

* test: setup-go stable false

* test: fix workflow go-version

* doc: add listener comment

* feat: simplify run group

* fix: remove deprecatedcron test

* fix: missing StatusChanged

* fix: some test

* feat: simplify run group

* fix: some import style

* fix: remove config module dispatcher

* fix(otgorm): hooks (#236)

* fix(otgorm): hooks

* fix: remove debug prints

(cherry picked from commit 1afb3d7)

* refactor(control): add pool

* fix(pool): data race

* fix(pool): data race

* fix(pool): go vet "call to (*T).Fatalf from a non-test goroutine"

* refactor: change leader election semantics. (#238)

* refactor: change leader election semantics.

Now leader election campaign will not return when the node beomes leader, instead it will block until the leader election session exists, updating status proactively. This change will make leader election status more accurate.

* fix(leader): mock driver for test

* fix: return if renew fails

* test: increase test duration

* docs: add jetbrains thanks

* fix(cron): example flakes

* fix(leader): TestElection block test

* fix(leader): missing dispatch when leader status on

* fix(leader): test data race

* fix(leader): test key conflict

* test(ots3): test container of minio

* feat: add a simple way to ensure cron jobs to run at least once for each schedule.

* doc: add comment

* fix(leaderredis): data race

Co-authored-by: Trock <g_trock@163.com>

* fix: server.go merge conflict

* feat(test): upgrade github actions

* fix: otredis TestModule_ProvideCommand

* fix: workflow lint add setup-go

* fix: workflow lint add setup-go

* fix: pool.Run need start before call Go method when use async mode.

* feat: add pool.Counter to observe the status of pool.

Co-authored-by: Trock <g_trock@163.com>
Co-authored-by: Trock <35254251+GGXXLL@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants