Skip to content

Attempting to add Redis Sentinel support#1

Open
roeltm wants to merge 13 commits into
developfrom
add-redis-sentinel-support
Open

Attempting to add Redis Sentinel support#1
roeltm wants to merge 13 commits into
developfrom
add-redis-sentinel-support

Conversation

@roeltm
Copy link
Copy Markdown
Owner

@roeltm roeltm commented Jan 10, 2023

No description provided.

@roeltm roeltm self-assigned this Jan 10, 2023
Copy link
Copy Markdown
Collaborator

@yasinishyn yasinishyn left a comment

Choose a reason for hiding this comment

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

Really nicely done!

enabled: true
sentinel: true
service_name: service_name
servers:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It might be more "correct" to call these sentinels (as you have it in config_documentation.md)

Comment thread synapse/replication/tcp/redis.py Outdated

class SynapseSentinelConnectionFactory(txredisapi.SentinelConnectionFactory):

maxDelay = 5
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe you can store this in a constant or env. var or in homeserver.yaml?
Also, it might be beneficial to add a comment describing the unit of measure (assume it's seconds)

Copy link
Copy Markdown
Collaborator

@yasinishyn yasinishyn left a comment

Choose a reason for hiding this comment

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

Minor style issues (subjective).
Overall looks great!

sentinel: true
service_name: service_name
sentinels:
- host: redis1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can be minor, but "redis1" suggests that it is Redis, not Sentinel.

from synapse.server import HomeServer
from typing import Optional, cast, Type, TypeVar, Generic
import attr
import txredisapi
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Might be cleaner if you group all 'synapse.*' imports together.


def publish(self, channel, message): ...


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we add comments describing what T and V are for?

reconnect=True)


def get_replication_factory(hs: "HomeServer", connection: IRedisConnection, channel_names: List[str]) -> txredisapi.RedisFactory:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The multi line method params is used multiple times. Maybe we should apply the same approach to methods which have "long" definition?

if isinstance(connection, SentinelRedisConnection):
factory = RedisSentinelReplicationFactory(
hs, connection.sentinel, connection.service_name, True, connection, channel_names)
txredisapi.Sentinel._connect_factory_and_return_handler(factory, 1)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

"1" is a "magic number" should we save it in a constant?

hs.config.redis.redis_host,
hs.config.redis.redis_port,
factory,
timeout=30,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why 30?

Comment thread synapse/config/redis.py Outdated
self.sentinel_enabled = redis_config.get("sentinel", False)
self.service_name = redis_config.get("service_name")
self.sentinels = []
for sentinel in redis_config.get("sentinels", []):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Because sentinels is array, I have a feeling that this and bellow line could be done as a single-liner.

@roeltm roeltm force-pushed the add-redis-sentinel-support branch 2 times, most recently from 782fbfd to 7fc2d9c Compare February 21, 2023 09:00
@github-actions github-actions Bot deployed to PR Documentation Preview February 21, 2023 09:03 Active
@github-actions github-actions Bot deployed to PR Documentation Preview February 21, 2023 09:13 Active
@github-actions github-actions Bot deployed to PR Documentation Preview February 21, 2023 09:15 Active
@roeltm roeltm force-pushed the add-redis-sentinel-support branch from d5ffd0c to 311b4b5 Compare February 21, 2023 09:19
@github-actions github-actions Bot deployed to PR Documentation Preview February 21, 2023 09:20 Active
@github-actions github-actions Bot deployed to PR Documentation Preview February 21, 2023 13:34 Active
@github-actions github-actions Bot deployed to PR Documentation Preview February 21, 2023 13:46 Active
@github-actions github-actions Bot deployed to PR Documentation Preview February 23, 2023 10:57 Active
@github-actions github-actions Bot deployed to PR Documentation Preview February 24, 2023 08:48 Active
@github-actions github-actions Bot deployed to PR Documentation Preview March 1, 2023 12:34 Active
@github-actions github-actions Bot deployed to PR Documentation Preview March 1, 2023 12:35 Active
@github-actions github-actions Bot deployed to PR Documentation Preview March 10, 2023 08:48 Active
@github-actions github-actions Bot deployed to PR Documentation Preview March 10, 2023 12:37 Active
@github-actions github-actions Bot deployed to PR Documentation Preview March 10, 2023 14:27 Active
@github-actions github-actions Bot deployed to PR Documentation Preview March 21, 2023 11:16 Active
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