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

Commit f9d9bd6

Browse files
committed
Merge branch 'hotfixes-v0.11.0-r2' of github.com:matrix-org/synapse
2 parents 2fcd981 + 5fcef78 commit f9d9bd6

File tree

4 files changed

+78
-28
lines changed

4 files changed

+78
-28
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Changes in synapse v0.11.0-r2 (2015-11-19)
2+
==========================================
3+
4+
* Fix bug in database port script (PR #387)
5+
16
Changes in synapse v0.11.0-r1 (2015-11-18)
27
==========================================
38

scripts/synapse_port_db

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ APPEND_ONLY_TABLES = [
6868
"state_groups_state",
6969
"event_to_state_groups",
7070
"rejections",
71+
"event_search",
7172
]
7273

7374

@@ -229,19 +230,51 @@ class Porter(object):
229230
if rows:
230231
next_chunk = rows[-1][0] + 1
231232

232-
self._convert_rows(table, headers, rows)
233+
if table == "event_search":
234+
# We have to treat event_search differently since it has a
235+
# different structure in the two different databases.
236+
def insert(txn):
237+
sql = (
238+
"INSERT INTO event_search (event_id, room_id, key, sender, vector)"
239+
" VALUES (?,?,?,?,to_tsvector('english', ?))"
240+
)
233241

234-
def insert(txn):
235-
self.postgres_store.insert_many_txn(
236-
txn, table, headers[1:], rows
237-
)
242+
rows_dict = [
243+
dict(zip(headers, row))
244+
for row in rows
245+
]
246+
247+
txn.executemany(sql, [
248+
(
249+
row["event_id"],
250+
row["room_id"],
251+
row["key"],
252+
row["sender"],
253+
row["value"],
254+
)
255+
for row in rows_dict
256+
])
257+
258+
self.postgres_store._simple_update_one_txn(
259+
txn,
260+
table="port_from_sqlite3",
261+
keyvalues={"table_name": table},
262+
updatevalues={"rowid": next_chunk},
263+
)
264+
else:
265+
self._convert_rows(table, headers, rows)
238266

239-
self.postgres_store._simple_update_one_txn(
240-
txn,
241-
table="port_from_sqlite3",
242-
keyvalues={"table_name": table},
243-
updatevalues={"rowid": next_chunk},
244-
)
267+
def insert(txn):
268+
self.postgres_store.insert_many_txn(
269+
txn, table, headers[1:], rows
270+
)
271+
272+
self.postgres_store._simple_update_one_txn(
273+
txn,
274+
table="port_from_sqlite3",
275+
keyvalues={"table_name": table},
276+
updatevalues={"rowid": next_chunk},
277+
)
245278

246279
yield self.postgres_store.execute(insert)
247280

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-r1"
19+
__version__ = "0.11.0-r2"

synapse/config/_base.py

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,29 @@ class ConfigError(Exception):
2525
pass
2626

2727

28-
class Config(object):
28+
# We split these messages out to allow packages to override with package
29+
# specific instructions.
30+
MISSING_REPORT_STATS_CONFIG_INSTRUCTIONS = """\
31+
Please opt in or out of reporting anonymized homeserver usage statistics, by
32+
setting the `report_stats` key in your config file to either True or False.
33+
"""
34+
35+
MISSING_REPORT_STATS_SPIEL = """\
36+
We would really appreciate it if you could help our project out by reporting
37+
anonymized usage statistics from your homeserver. Only very basic aggregate
38+
data (e.g. number of users) will be reported, but it helps us to track the
39+
growth of the Matrix community, and helps us to make Matrix a success, as well
40+
as to convince other networks that they should peer with us.
41+
42+
Thank you.
43+
"""
44+
45+
MISSING_SERVER_NAME = """\
46+
Missing mandatory `server_name` config option.
47+
"""
2948

30-
stats_reporting_begging_spiel = (
31-
"We would really appreciate it if you could help our project out by"
32-
" reporting anonymized usage statistics from your homeserver. Only very"
33-
" basic aggregate data (e.g. number of users) will be reported, but it"
34-
" helps us to track the growth of the Matrix community, and helps us to"
35-
" make Matrix a success, as well as to convince other networks that they"
36-
" should peer with us."
37-
"\nThank you."
38-
)
3949

50+
class Config(object):
4051
@staticmethod
4152
def parse_size(value):
4253
if isinstance(value, int) or isinstance(value, long):
@@ -215,7 +226,7 @@ def load_config(cls, description, argv, generate_section=None):
215226
if config_args.report_stats is None:
216227
config_parser.error(
217228
"Please specify either --report-stats=yes or --report-stats=no\n\n" +
218-
cls.stats_reporting_begging_spiel
229+
MISSING_REPORT_STATS_SPIEL
219230
)
220231
if not config_files:
221232
config_parser.error(
@@ -290,6 +301,10 @@ def load_config(cls, description, argv, generate_section=None):
290301
yaml_config = cls.read_config_file(config_file)
291302
specified_config.update(yaml_config)
292303

304+
if "server_name" not in specified_config:
305+
sys.stderr.write("\n" + MISSING_SERVER_NAME + "\n")
306+
sys.exit(1)
307+
293308
server_name = specified_config["server_name"]
294309
_, config = obj.generate_config(
295310
config_dir_path=config_dir_path,
@@ -299,11 +314,8 @@ def load_config(cls, description, argv, generate_section=None):
299314
config.update(specified_config)
300315
if "report_stats" not in config:
301316
sys.stderr.write(
302-
"Please opt in or out of reporting anonymized homeserver usage "
303-
"statistics, by setting the report_stats key in your config file "
304-
" ( " + config_path + " ) " +
305-
"to either True or False.\n\n" +
306-
Config.stats_reporting_begging_spiel + "\n")
317+
"\n" + MISSING_REPORT_STATS_CONFIG_INSTRUCTIONS + "\n" +
318+
MISSING_REPORT_STATS_SPIEL + "\n")
307319
sys.exit(1)
308320

309321
if generate_keys:

0 commit comments

Comments
 (0)