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

Add 'slave_repl_offset' to the INFO replication command output #752

Merged
merged 1 commit into from
Sep 6, 2024

Conversation

Kilowhisky
Copy link
Contributor

@Kilowhisky Kilowhisky commented Sep 3, 2024

This adds support for slave_repl_offset to the INFO REPLICATION command.

I just grabbed the int(s.faofsz) from here (output of the ROLE command). Can you confirm this would be the right stat to grab? I don't really see where this gets updated. I guess i could have just used the s.aofsz which does get updated...

For my purposes, i guess as long as its not 0 it should fix my problem.

} else {
role = "slave"
host = s.config.followHost()
port = s.config.followPort()
offset = int(s.faofsz)
state = "connected"
}

This fixes #750

@shakefu
Copy link

shakefu commented Sep 3, 2024

@tidwall Any chance we can get this reviewed for upstream acceptance?

@iwpnd
Copy link
Contributor

iwpnd commented Sep 4, 2024

@tidwall Any chance we can get this reviewed for upstream acceptance?

🥴

@Kilowhisky
Copy link
Contributor Author

Kilowhisky commented Sep 4, 2024

I just tested this PR against an active master as a new follower and it behaved as expected. So it looks like i got the right property.

info replication
# Replication
role:slave
master_host:10.134.72.107
master_port:9851
slave_repl_offset:1352875844
connected_slaves:0

info replication
# Replication
role:slave
master_host:10.134.72.107
master_port:9851
slave_repl_offset:1374752031
connected_slaves:0

output JSON
{"ok":true,"elapsed":"1.31  s"}

info replication
{"ok":true,"info":{"connected_slaves":0,"master_host":"10.134.72.107","master_port":9851,"role":"slave","slave_repl_offset":1297572539},"elapsed":"44.621  s"}

As seen above, the offset is increasing as expected.

@tidwall tidwall merged commit 2b080f4 into tidwall:master Sep 6, 2024
1 check passed
@tidwall
Copy link
Owner

tidwall commented Sep 6, 2024

LGTM.

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.

Tile38 is not publishing its db stats to redis sentinel which causes sentinel to pick wrong master
4 participants