Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 915e56e

Browse files
committed
Merge branch 'hotfixes-v0.11.0-r1'
2 parents 8bae98b + fbb76a4 commit 915e56e

File tree

7 files changed

+49
-8
lines changed

7 files changed

+49
-8
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Changes in synapse v0.11.0-r1 (2015-11-18)
2+
==========================================
3+
4+
* Retry and fail federation requests more aggressively for requests that block
5+
client side requests (PR #384)
6+
17
Changes in synapse v0.11.0 (2015-11-17)
28
=======================================
39

synapse/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
""" This is a reference implementation of a Matrix home server.
1717
"""
1818

19-
__version__ = "0.11.0"
19+
__version__ = "0.11.0-r1"

synapse/federation/transport/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def send_transaction(self, transaction, json_data_callback=None):
136136
path=PREFIX + "/send/%s/" % transaction.transaction_id,
137137
data=json_data,
138138
json_data_callback=json_data_callback,
139+
long_retries=True,
139140
)
140141

141142
logger.debug(

synapse/http/matrixfederationclient.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
)
5757

5858

59-
MAX_RETRIES = 10
59+
MAX_LONG_RETRIES = 10
60+
MAX_SHORT_RETRIES = 3
6061

6162

6263
class MatrixFederationEndpointFactory(object):
@@ -103,7 +104,7 @@ def _create_url(self, destination, path_bytes, param_bytes, query_bytes):
103104
def _create_request(self, destination, method, path_bytes,
104105
body_callback, headers_dict={}, param_bytes=b"",
105106
query_bytes=b"", retry_on_dns_fail=True,
106-
timeout=None):
107+
timeout=None, long_retries=False):
107108
""" Creates and sends a request to the given url
108109
"""
109110
headers_dict[b"User-Agent"] = [self.version_string]
@@ -123,7 +124,10 @@ def _create_request(self, destination, method, path_bytes,
123124

124125
# XXX: Would be much nicer to retry only at the transaction-layer
125126
# (once we have reliable transactions in place)
126-
retries_left = MAX_RETRIES
127+
if long_retries:
128+
retries_left = MAX_LONG_RETRIES
129+
else:
130+
retries_left = MAX_SHORT_RETRIES
127131

128132
http_url_bytes = urlparse.urlunparse(
129133
("", "", path_bytes, param_bytes, query_bytes, "")
@@ -184,9 +188,15 @@ def send_request():
184188
)
185189

186190
if retries_left and not timeout:
187-
delay = 4 ** (MAX_RETRIES + 1 - retries_left)
188-
delay = max(delay, 60)
189-
delay *= random.uniform(0.8, 1.4)
191+
if long_retries:
192+
delay = 4 ** (MAX_LONG_RETRIES + 1 - retries_left)
193+
delay = max(delay, 60)
194+
delay *= random.uniform(0.8, 1.4)
195+
else:
196+
delay = 0.5 * 2 ** (MAX_SHORT_RETRIES - retries_left)
197+
delay = max(delay, 2)
198+
delay *= random.uniform(0.8, 1.4)
199+
190200
yield sleep(delay)
191201
retries_left -= 1
192202
else:
@@ -237,7 +247,8 @@ def sign_request(self, destination, method, url_bytes, headers_dict,
237247
headers_dict[b"Authorization"] = auth_headers
238248

239249
@defer.inlineCallbacks
240-
def put_json(self, destination, path, data={}, json_data_callback=None):
250+
def put_json(self, destination, path, data={}, json_data_callback=None,
251+
long_retries=False):
241252
""" Sends the specifed json data using PUT
242253
243254
Args:
@@ -248,6 +259,8 @@ def put_json(self, destination, path, data={}, json_data_callback=None):
248259
the request body. This will be encoded as JSON.
249260
json_data_callback (callable): A callable returning the dict to
250261
use as the request body.
262+
long_retries (bool): A boolean that indicates whether we should
263+
retry for a short or long time.
251264
252265
Returns:
253266
Deferred: Succeeds when we get a 2xx HTTP response. The result
@@ -273,6 +286,7 @@ def body_callback(method, url_bytes, headers_dict):
273286
path.encode("ascii"),
274287
body_callback=body_callback,
275288
headers_dict={"Content-Type": ["application/json"]},
289+
long_retries=long_retries,
276290
)
277291

278292
if 200 <= response.code < 300:
@@ -491,6 +505,9 @@ def pauseProducing(self):
491505
def stopProducing(self):
492506
pass
493507

508+
def resumeProducing(self):
509+
pass
510+
494511

495512
def _flatten_response_never_received(e):
496513
if hasattr(e, "reasons"):

tests/federation/test_federation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def test_send_pdu(self):
197197
'pdu_failures': [],
198198
},
199199
json_data_callback=ANY,
200+
long_retries=True,
200201
)
201202

202203
@defer.inlineCallbacks
@@ -228,6 +229,7 @@ def test_send_edu(self):
228229
'pdu_failures': [],
229230
},
230231
json_data_callback=ANY,
232+
long_retries=True,
231233
)
232234

233235
@defer.inlineCallbacks

tests/handlers/test_presence.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ def test_invite_remote(self):
409409
}
410410
),
411411
json_data_callback=ANY,
412+
long_retries=True,
412413
),
413414
defer.succeed((200, "OK"))
414415
)
@@ -443,6 +444,7 @@ def test_accept_remote(self):
443444
}
444445
),
445446
json_data_callback=ANY,
447+
long_retries=True,
446448
),
447449
defer.succeed((200, "OK"))
448450
)
@@ -483,6 +485,7 @@ def test_invited_remote_nonexistant(self):
483485
}
484486
),
485487
json_data_callback=ANY,
488+
long_retries=True,
486489
),
487490
defer.succeed((200, "OK"))
488491
)
@@ -827,6 +830,7 @@ def test_push_remote(self):
827830
}
828831
),
829832
json_data_callback=ANY,
833+
long_retries=True,
830834
),
831835
defer.succeed((200, "OK"))
832836
)
@@ -843,6 +847,7 @@ def test_push_remote(self):
843847
}
844848
),
845849
json_data_callback=ANY,
850+
long_retries=True,
846851
),
847852
defer.succeed((200, "OK"))
848853
)
@@ -1033,6 +1038,7 @@ def test_join_room_remote(self):
10331038
}
10341039
),
10351040
json_data_callback=ANY,
1041+
long_retries=True,
10361042
),
10371043
defer.succeed((200, "OK"))
10381044
)
@@ -1048,6 +1054,7 @@ def test_join_room_remote(self):
10481054
}
10491055
),
10501056
json_data_callback=ANY,
1057+
long_retries=True,
10511058
),
10521059
defer.succeed((200, "OK"))
10531060
)
@@ -1078,6 +1085,7 @@ def test_join_room_remote(self):
10781085
}
10791086
),
10801087
json_data_callback=ANY,
1088+
long_retries=True,
10811089
),
10821090
defer.succeed((200, "OK"))
10831091
)
@@ -1184,6 +1192,7 @@ def test_remote_poll_send(self):
11841192
},
11851193
),
11861194
json_data_callback=ANY,
1195+
long_retries=True,
11871196
),
11881197
defer.succeed((200, "OK"))
11891198
)
@@ -1200,6 +1209,7 @@ def test_remote_poll_send(self):
12001209
},
12011210
),
12021211
json_data_callback=ANY,
1212+
long_retries=True,
12031213
),
12041214
defer.succeed((200, "OK"))
12051215
)
@@ -1232,6 +1242,7 @@ def test_remote_poll_send(self):
12321242
},
12331243
),
12341244
json_data_callback=ANY,
1245+
long_retries=True,
12351246
),
12361247
defer.succeed((200, "OK"))
12371248
)
@@ -1265,6 +1276,7 @@ def test_remote_poll_send(self):
12651276
},
12661277
),
12671278
json_data_callback=ANY,
1279+
long_retries=True,
12681280
),
12691281
defer.succeed((200, "OK"))
12701282
)
@@ -1297,6 +1309,7 @@ def test_remote_poll_receive(self):
12971309
},
12981310
),
12991311
json_data_callback=ANY,
1312+
long_retries=True,
13001313
),
13011314
defer.succeed((200, "OK"))
13021315
)

tests/handlers/test_typing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ def test_started_typing_remote_send(self):
218218
}
219219
),
220220
json_data_callback=ANY,
221+
long_retries=True,
221222
),
222223
defer.succeed((200, "OK"))
223224
)
@@ -284,6 +285,7 @@ def test_stopped_typing(self):
284285
}
285286
),
286287
json_data_callback=ANY,
288+
long_retries=True,
287289
),
288290
defer.succeed((200, "OK"))
289291
)

0 commit comments

Comments
 (0)