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

Election under high latency #92

Merged
merged 15 commits into from Dec 10, 2023
Merged

Conversation

mateusfreira
Copy link
Owner

@mateusfreira mateusfreira commented Oct 22, 2023

  • Only send an acknowledgment message back from the source of the message
  • Improve the code in

Election back and forth of messages

sequenceDiagram
    rect rgb(200, 133, 0)
        note right of Primary: Election
        Primary->>+Secondary: rp 1702205635066387000 election candidate 1702205629496 127.0.0.1:3017 to localhost:3018
        Secondary->>+Primary: set-secoundary localhost:3018
        Secondary->>+Primary: replicate-since localhost:3018 0
        Secondary->>+Primary: ack 1702205635066387000 localhost:3018
        Secondary->>+Primary: join localhost:3018
        Primary->>+Secondary: rp 1702205635180069000 set-primary 127.0.0.1:3017 to localhost:3018
        Secondary->>+Primary: ack 1702205635180069000 localhost:3018
    end
    rect rgb(120, 120, 120)
        note right of Primary: Data exchange
        Primary->>+Secondary: rp 1702205652409931000 create-db sample sample-pwd none to localhost:3018
        Primary->>+Secondary: rp 1702205652410161000 replicate-snapshot sample false to localhost:3018
        Secondary->>+Primary: ack 1702205652409931000 localhost:3018
        Secondary->>+Primary: ack 1702205652410161000 localhost:3018
    end
graph TD

subgraph Cluster
  toxiproxy[Toxiproxy]
  nun-db-primary[Nun-DB Primary]
  nun-db-secondary-1[Nun-DB Secondary 1]
  nun-db-secondary-2[Nun-DB Secondary 2]
end

subgraph Clients
  Nun-DB-Client[Nun-DB Client]
end

toxiproxy -->|"Exposes"| Nun-DB-Client
nun-db-primary <-->|"TCP Traffic, Latency: 500ms"| toxiproxy
toxiproxy <-->|"TCP Traffic, Latency: 500ms"| nun-db-secondary-1
toxiproxy <-->|"TCP Traffic, Latency: 500ms"| nun-db-secondary-2

@mateusfreira mateusfreira merged commit 3411a24 into master Dec 10, 2023
1 check passed
@mateusfreira mateusfreira deleted the election-under-higth-latency branch December 10, 2023 15:50
@mateusfreira mateusfreira changed the title [WIP] Election under high latency Election under high latency Dec 10, 2023
return;
}
start_time = 0;
while opp.is_some() && !opp.unwrap().is_full_acknowledged() {
Copy link
Owner Author

Choose a reason for hiding this comment

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

Improve this

log::info!("No longer eligible to be primary, will stop election");
return;
}
thread::sleep(time::Duration::from_millis(2));
Copy link
Owner Author

Choose a reason for hiding this comment

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

Do I need this sleep?

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.

None yet

1 participant