Codebase list matrix-synapse / upstream/0.11.0-r2
Imported Upstream version 0.11.0-r2 Erik Johnston 8 years ago
10 changed file(s) with 134 addition(s) and 38 deletion(s). Raw diff Collapse all Expand all
0 Changes in synapse v0.11.0-r2 (2015-11-19)
1 ==========================================
2
3 * Fix bug in database port script (PR #387)
4
5 Changes in synapse v0.11.0-r1 (2015-11-18)
6 ==========================================
7
8 * Retry and fail federation requests more aggressively for requests that block
9 client side requests (PR #384)
10
011 Changes in synapse v0.11.0 (2015-11-17)
112 =======================================
213
132132 Alternatively, Silvio Fricke has contributed a Dockerfile to automate the
133133 above in Docker at https://registry.hub.docker.com/u/silviof/docker-matrix/.
134134
135 Another alternative is to install via apt from http://matrix.org/packages/debian/.
136 Note that these packages do not include a client - choose one from
137 https://matrix.org/blog/try-matrix-now/ (or build your own with
138 https://github.com/matrix-org/matrix-js-sdk/).
139
135140 To set up your homeserver, run (in your virtualenv, as before)::
136141
137142 cd ~/.synapse
6767 "state_groups_state",
6868 "event_to_state_groups",
6969 "rejections",
70 "event_search",
7071 ]
7172
7273
228229 if rows:
229230 next_chunk = rows[-1][0] + 1
230231
231 self._convert_rows(table, headers, rows)
232
233 def insert(txn):
234 self.postgres_store.insert_many_txn(
235 txn, table, headers[1:], rows
236 )
237
238 self.postgres_store._simple_update_one_txn(
239 txn,
240 table="port_from_sqlite3",
241 keyvalues={"table_name": table},
242 updatevalues={"rowid": next_chunk},
243 )
232 if table == "event_search":
233 # We have to treat event_search differently since it has a
234 # different structure in the two different databases.
235 def insert(txn):
236 sql = (
237 "INSERT INTO event_search (event_id, room_id, key, sender, vector)"
238 " VALUES (?,?,?,?,to_tsvector('english', ?))"
239 )
240
241 rows_dict = [
242 dict(zip(headers, row))
243 for row in rows
244 ]
245
246 txn.executemany(sql, [
247 (
248 row["event_id"],
249 row["room_id"],
250 row["key"],
251 row["sender"],
252 row["value"],
253 )
254 for row in rows_dict
255 ])
256
257 self.postgres_store._simple_update_one_txn(
258 txn,
259 table="port_from_sqlite3",
260 keyvalues={"table_name": table},
261 updatevalues={"rowid": next_chunk},
262 )
263 else:
264 self._convert_rows(table, headers, rows)
265
266 def insert(txn):
267 self.postgres_store.insert_many_txn(
268 txn, table, headers[1:], rows
269 )
270
271 self.postgres_store._simple_update_one_txn(
272 txn,
273 table="port_from_sqlite3",
274 keyvalues={"table_name": table},
275 updatevalues={"rowid": next_chunk},
276 )
244277
245278 yield self.postgres_store.execute(insert)
246279
1515 """ This is a reference implementation of a Matrix home server.
1616 """
1717
18 __version__ = "0.11.0"
18 __version__ = "0.11.0-r2"
2424 pass
2525
2626
27 # We split these messages out to allow packages to override with package
28 # specific instructions.
29 MISSING_REPORT_STATS_CONFIG_INSTRUCTIONS = """\
30 Please opt in or out of reporting anonymized homeserver usage statistics, by
31 setting the `report_stats` key in your config file to either True or False.
32 """
33
34 MISSING_REPORT_STATS_SPIEL = """\
35 We would really appreciate it if you could help our project out by reporting
36 anonymized usage statistics from your homeserver. Only very basic aggregate
37 data (e.g. number of users) will be reported, but it helps us to track the
38 growth of the Matrix community, and helps us to make Matrix a success, as well
39 as to convince other networks that they should peer with us.
40
41 Thank you.
42 """
43
44 MISSING_SERVER_NAME = """\
45 Missing mandatory `server_name` config option.
46 """
47
48
2749 class Config(object):
28
29 stats_reporting_begging_spiel = (
30 "We would really appreciate it if you could help our project out by"
31 " reporting anonymized usage statistics from your homeserver. Only very"
32 " basic aggregate data (e.g. number of users) will be reported, but it"
33 " helps us to track the growth of the Matrix community, and helps us to"
34 " make Matrix a success, as well as to convince other networks that they"
35 " should peer with us."
36 "\nThank you."
37 )
38
3950 @staticmethod
4051 def parse_size(value):
4152 if isinstance(value, int) or isinstance(value, long):
214225 if config_args.report_stats is None:
215226 config_parser.error(
216227 "Please specify either --report-stats=yes or --report-stats=no\n\n" +
217 cls.stats_reporting_begging_spiel
228 MISSING_REPORT_STATS_SPIEL
218229 )
219230 if not config_files:
220231 config_parser.error(
289300 yaml_config = cls.read_config_file(config_file)
290301 specified_config.update(yaml_config)
291302
303 if "server_name" not in specified_config:
304 sys.stderr.write("\n" + MISSING_SERVER_NAME + "\n")
305 sys.exit(1)
306
292307 server_name = specified_config["server_name"]
293308 _, config = obj.generate_config(
294309 config_dir_path=config_dir_path,
298313 config.update(specified_config)
299314 if "report_stats" not in config:
300315 sys.stderr.write(
301 "Please opt in or out of reporting anonymized homeserver usage "
302 "statistics, by setting the report_stats key in your config file "
303 " ( " + config_path + " ) " +
304 "to either True or False.\n\n" +
305 Config.stats_reporting_begging_spiel + "\n")
316 "\n" + MISSING_REPORT_STATS_CONFIG_INSTRUCTIONS + "\n" +
317 MISSING_REPORT_STATS_SPIEL + "\n")
306318 sys.exit(1)
307319
308320 if generate_keys:
135135 path=PREFIX + "/send/%s/" % transaction.transaction_id,
136136 data=json_data,
137137 json_data_callback=json_data_callback,
138 long_retries=True,
138139 )
139140
140141 logger.debug(
5555 )
5656
5757
58 MAX_RETRIES = 10
58 MAX_LONG_RETRIES = 10
59 MAX_SHORT_RETRIES = 3
5960
6061
6162 class MatrixFederationEndpointFactory(object):
102103 def _create_request(self, destination, method, path_bytes,
103104 body_callback, headers_dict={}, param_bytes=b"",
104105 query_bytes=b"", retry_on_dns_fail=True,
105 timeout=None):
106 timeout=None, long_retries=False):
106107 """ Creates and sends a request to the given url
107108 """
108109 headers_dict[b"User-Agent"] = [self.version_string]
122123
123124 # XXX: Would be much nicer to retry only at the transaction-layer
124125 # (once we have reliable transactions in place)
125 retries_left = MAX_RETRIES
126 if long_retries:
127 retries_left = MAX_LONG_RETRIES
128 else:
129 retries_left = MAX_SHORT_RETRIES
126130
127131 http_url_bytes = urlparse.urlunparse(
128132 ("", "", path_bytes, param_bytes, query_bytes, "")
183187 )
184188
185189 if retries_left and not timeout:
186 delay = 4 ** (MAX_RETRIES + 1 - retries_left)
187 delay = max(delay, 60)
188 delay *= random.uniform(0.8, 1.4)
190 if long_retries:
191 delay = 4 ** (MAX_LONG_RETRIES + 1 - retries_left)
192 delay = max(delay, 60)
193 delay *= random.uniform(0.8, 1.4)
194 else:
195 delay = 0.5 * 2 ** (MAX_SHORT_RETRIES - retries_left)
196 delay = max(delay, 2)
197 delay *= random.uniform(0.8, 1.4)
198
189199 yield sleep(delay)
190200 retries_left -= 1
191201 else:
236246 headers_dict[b"Authorization"] = auth_headers
237247
238248 @defer.inlineCallbacks
239 def put_json(self, destination, path, data={}, json_data_callback=None):
249 def put_json(self, destination, path, data={}, json_data_callback=None,
250 long_retries=False):
240251 """ Sends the specifed json data using PUT
241252
242253 Args:
247258 the request body. This will be encoded as JSON.
248259 json_data_callback (callable): A callable returning the dict to
249260 use as the request body.
261 long_retries (bool): A boolean that indicates whether we should
262 retry for a short or long time.
250263
251264 Returns:
252265 Deferred: Succeeds when we get a 2xx HTTP response. The result
272285 path.encode("ascii"),
273286 body_callback=body_callback,
274287 headers_dict={"Content-Type": ["application/json"]},
288 long_retries=long_retries,
275289 )
276290
277291 if 200 <= response.code < 300:
490504 def stopProducing(self):
491505 pass
492506
507 def resumeProducing(self):
508 pass
509
493510
494511 def _flatten_response_never_received(e):
495512 if hasattr(e, "reasons"):
196196 'pdu_failures': [],
197197 },
198198 json_data_callback=ANY,
199 long_retries=True,
199200 )
200201
201202 @defer.inlineCallbacks
227228 'pdu_failures': [],
228229 },
229230 json_data_callback=ANY,
231 long_retries=True,
230232 )
231233
232234 @defer.inlineCallbacks
408408 }
409409 ),
410410 json_data_callback=ANY,
411 long_retries=True,
411412 ),
412413 defer.succeed((200, "OK"))
413414 )
442443 }
443444 ),
444445 json_data_callback=ANY,
446 long_retries=True,
445447 ),
446448 defer.succeed((200, "OK"))
447449 )
482484 }
483485 ),
484486 json_data_callback=ANY,
487 long_retries=True,
485488 ),
486489 defer.succeed((200, "OK"))
487490 )
826829 }
827830 ),
828831 json_data_callback=ANY,
832 long_retries=True,
829833 ),
830834 defer.succeed((200, "OK"))
831835 )
842846 }
843847 ),
844848 json_data_callback=ANY,
849 long_retries=True,
845850 ),
846851 defer.succeed((200, "OK"))
847852 )
10321037 }
10331038 ),
10341039 json_data_callback=ANY,
1040 long_retries=True,
10351041 ),
10361042 defer.succeed((200, "OK"))
10371043 )
10471053 }
10481054 ),
10491055 json_data_callback=ANY,
1056 long_retries=True,
10501057 ),
10511058 defer.succeed((200, "OK"))
10521059 )
10771084 }
10781085 ),
10791086 json_data_callback=ANY,
1087 long_retries=True,
10801088 ),
10811089 defer.succeed((200, "OK"))
10821090 )
11831191 },
11841192 ),
11851193 json_data_callback=ANY,
1194 long_retries=True,
11861195 ),
11871196 defer.succeed((200, "OK"))
11881197 )
11991208 },
12001209 ),
12011210 json_data_callback=ANY,
1211 long_retries=True,
12021212 ),
12031213 defer.succeed((200, "OK"))
12041214 )
12311241 },
12321242 ),
12331243 json_data_callback=ANY,
1244 long_retries=True,
12341245 ),
12351246 defer.succeed((200, "OK"))
12361247 )
12641275 },
12651276 ),
12661277 json_data_callback=ANY,
1278 long_retries=True,
12671279 ),
12681280 defer.succeed((200, "OK"))
12691281 )
12961308 },
12971309 ),
12981310 json_data_callback=ANY,
1311 long_retries=True,
12991312 ),
13001313 defer.succeed((200, "OK"))
13011314 )
217217 }
218218 ),
219219 json_data_callback=ANY,
220 long_retries=True,
220221 ),
221222 defer.succeed((200, "OK"))
222223 )
283284 }
284285 ),
285286 json_data_callback=ANY,
287 long_retries=True,
286288 ),
287289 defer.succeed((200, "OK"))
288290 )