Skip to content

feat(server family): impl ROLE command #660

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

Merged
merged 5 commits into from
Jan 12, 2023
Merged

feat(server family): impl ROLE command #660

merged 5 commits into from
Jan 12, 2023

Conversation

adiholden
Copy link
Contributor

Signed-off-by: adi_holden adi@dragonflydb.io

Signed-off-by: adi_holden <adi@dragonflydb.io>
@adiholden adiholden requested a review from romange January 9, 2023 12:48
struct ReplicaData {
ReplicaData(std::string address, std::string port, SyncState sync_state)
: address(address), port(port) {
switch (sync_state) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pls move the impl to cc. I would even keep SyncState as is and render its string inside servet_family

Context cntx;

std::vector<FlowInfo> flows;
::boost::fibers::mutex mu; // See top of header for locking levels.
};
struct ReplicaData {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we already have ReplicaInfo, ReplicaData is a bit confusing. Maybe ReplicaRoleInfo?

std::string Connection::RemoteEndpointIp() const {
LinuxSocketBase* lsb = static_cast<LinuxSocketBase*>(socket_.get());
auto re = lsb->RemoteEndpoint();
// TODO: roman port is this the right property of re? I get wrong values
Copy link
Collaborator

Choose a reason for hiding this comment

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

I did not understand the question. It's a remote port of the client connection. I.e it's never 6380. What redis shows here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh you are right I got confused. So I am not sure what is the meaning of port in this flow. We are opening several connections in the sync

Copy link
Collaborator

Choose a reason for hiding this comment

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

True. Lets send an empty string for now and see later what it breaks :)

Signed-off-by: adi_holden <adi@dragonflydb.io>
@adiholden adiholden requested a review from romange January 9, 2023 13:36
Signed-off-by: adi_holden <adi@dragonflydb.io>
@adiholden
Copy link
Contributor Author

@romange can you please review again

std::vector<ReplicaRoleInfo> vec;
unique_lock lk(mu_);
for (const auto& info : replica_infos_) {
vec.emplace_back(info.second->address, info.second->state);
Copy link
Contributor

Choose a reason for hiding this comment

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

The ReplicaInfo fields are not guarded by the global mutex itself. While address is nowhere accessed, the state is on all operations.

Reading from the state (and even reading an old value) has no consequences at all here, but doing this is technically undefined behavior, so we should probably make this field atomic

Signed-off-by: adi_holden <adi@dragonflydb.io>
@adiholden adiholden requested a review from dranikpg January 11, 2023 10:34
Signed-off-by: adi_holden <adi@dragonflydb.io>
@@ -403,7 +423,8 @@ void DflyCmd::FullSyncFb(FlowInfo* flow, Context* cntx) {
}
}

uint32_t DflyCmd::CreateSyncSession() {
uint32_t DflyCmd::CreateSyncSession(ConnectionContext* cntx) {
;
Copy link
Collaborator

Choose a reason for hiding this comment

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

weird ;

@adiholden adiholden merged commit ec1b118 into main Jan 12, 2023
@romange romange deleted the role_command_impl branch January 12, 2023 11:27
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.

3 participants