Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
464e5da7
Unverified
Commit
464e5da7
authored
4 years ago
by
Richard van der Hoff
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add logging for redis connection setup (#9590)
parent
e55bd0e1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/9590.misc
+1
-0
1 addition, 0 deletions
changelog.d/9590.misc
stubs/txredisapi.pyi
+3
-1
3 additions, 1 deletion
stubs/txredisapi.pyi
synapse/replication/tcp/redis.py
+35
-0
35 additions, 0 deletions
synapse/replication/tcp/redis.py
with
39 additions
and
1 deletion
changelog.d/9590.misc
0 → 100644
+
1
−
0
View file @
464e5da7
Add logging for redis connection setup.
This diff is collapsed.
Click to expand it.
stubs/txredisapi.pyi
+
3
−
1
View file @
464e5da7
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
"""
"""
from
typing
import
Any
,
List
,
Optional
,
Type
,
Union
from
typing
import
Any
,
List
,
Optional
,
Type
,
Union
from
twisted.internet
import
protocol
class
RedisProtocol
:
class
RedisProtocol
:
def
publish
(
self
,
channel
:
str
,
message
:
bytes
):
...
def
publish
(
self
,
channel
:
str
,
message
:
bytes
):
...
async
def
ping
(
self
)
->
None
:
...
async
def
ping
(
self
)
->
None
:
...
...
@@ -52,7 +54,7 @@ def lazyConnection(
...
@@ -52,7 +54,7 @@ def lazyConnection(
class
ConnectionHandler
:
...
class
ConnectionHandler
:
...
class
RedisFactory
:
class
RedisFactory
(
protocol
.
ReconnectingClientFactory
)
:
continueTrying
:
bool
continueTrying
:
bool
handler
:
RedisProtocol
handler
:
RedisProtocol
pool
:
List
[
RedisProtocol
]
pool
:
List
[
RedisProtocol
]
...
...
This diff is collapsed.
Click to expand it.
synapse/replication/tcp/redis.py
+
35
−
0
View file @
464e5da7
...
@@ -20,6 +20,10 @@ from typing import TYPE_CHECKING, Generic, Optional, Type, TypeVar, cast
...
@@ -20,6 +20,10 @@ from typing import TYPE_CHECKING, Generic, Optional, Type, TypeVar, cast
import
attr
import
attr
import
txredisapi
import
txredisapi
from
twisted.internet.address
import
IPv4Address
,
IPv6Address
from
twisted.internet.interfaces
import
IAddress
,
IConnector
from
twisted.python.failure
import
Failure
from
synapse.logging.context
import
PreserveLoggingContext
,
make_deferred_yieldable
from
synapse.logging.context
import
PreserveLoggingContext
,
make_deferred_yieldable
from
synapse.metrics.background_process_metrics
import
(
from
synapse.metrics.background_process_metrics
import
(
BackgroundProcessLoggingContext
,
BackgroundProcessLoggingContext
,
...
@@ -253,6 +257,37 @@ class SynapseRedisFactory(txredisapi.RedisFactory):
...
@@ -253,6 +257,37 @@ class SynapseRedisFactory(txredisapi.RedisFactory):
except
Exception
:
except
Exception
:
logger
.
warning
(
"
Failed to send ping to a redis connection
"
)
logger
.
warning
(
"
Failed to send ping to a redis connection
"
)
# ReconnectingClientFactory has some logging (if you enable `self.noisy`), but
# it's rubbish. We add our own here.
def
startedConnecting
(
self
,
connector
:
IConnector
):
logger
.
info
(
"
Connecting to redis server %s
"
,
format_address
(
connector
.
getDestination
())
)
super
().
startedConnecting
(
connector
)
def
clientConnectionFailed
(
self
,
connector
:
IConnector
,
reason
:
Failure
):
logger
.
info
(
"
Connection to redis server %s failed: %s
"
,
format_address
(
connector
.
getDestination
()),
reason
.
value
,
)
super
().
clientConnectionFailed
(
connector
,
reason
)
def
clientConnectionLost
(
self
,
connector
:
IConnector
,
reason
:
Failure
):
logger
.
info
(
"
Connection to redis server %s lost: %s
"
,
format_address
(
connector
.
getDestination
()),
reason
.
value
,
)
super
().
clientConnectionLost
(
connector
,
reason
)
def
format_address
(
address
:
IAddress
)
->
str
:
if
isinstance
(
address
,
(
IPv4Address
,
IPv6Address
)):
return
"
%s:%i
"
%
(
address
.
host
,
address
.
port
)
return
str
(
address
)
class
RedisDirectTcpReplicationClientFactory
(
SynapseRedisFactory
):
class
RedisDirectTcpReplicationClientFactory
(
SynapseRedisFactory
):
"""
This is a reconnecting factory that connects to redis and immediately
"""
This is a reconnecting factory that connects to redis and immediately
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment