File tree 3 files changed +13
-7
lines changed
3 files changed +13
-7
lines changed Original file line number Diff line number Diff line change
1
+ Change the `allow_unsafe_locale` config option to also apply when setting up new databases.
Original file line number Diff line number Diff line change @@ -242,12 +242,11 @@ host all all ::1/128 ident
242
242
243
243
### Fixing incorrect `COLLATE` or `CTYPE`
244
244
245
- Synapse will refuse to set up a new database if it has the wrong values of
246
- `COLLATE` and `CTYPE` set. Synapse will also refuse to start an existing database with incorrect values
247
- of `COLLATE` and `CTYPE` unless the config flag `allow_unsafe_locale`, found in the
248
- `database` section of the config, is set to true. Using different locales can cause issues if the locale library is updated from
249
- underneath the database, or if a different version of the locale is used on any
250
- replicas.
245
+ Synapse will refuse to start when using a database with incorrect values of
246
+ `COLLATE` and `CTYPE` unless the config flag `allow_unsafe_locale`, found in the
247
+ `database` section of the config, is set to true. Using different locales can
248
+ cause issues if the locale library is updated from underneath the database, or
249
+ if a different version of the locale is used on any replicas.
251
250
252
251
If you have a database with an unsafe locale, the safest way to fix the issue is to dump the database and recreate it with
253
252
the correct locale parameter (as shown above). It is also possible to change the
Original file line number Diff line number Diff line change @@ -142,6 +142,10 @@ def check_new_database(self, txn: Cursor) -> None:
142
142
apply stricter checks on new databases versus existing database.
143
143
"""
144
144
145
+ allow_unsafe_locale = self .config .get ("allow_unsafe_locale" , False )
146
+ if allow_unsafe_locale :
147
+ return
148
+
145
149
collation , ctype = self .get_db_locale (txn )
146
150
147
151
errors = []
@@ -155,7 +159,9 @@ def check_new_database(self, txn: Cursor) -> None:
155
159
if errors :
156
160
raise IncorrectDatabaseSetup (
157
161
"Database is incorrectly configured:\n \n %s\n \n "
158
- "See docs/postgres.md for more information." % ("\n " .join (errors ))
162
+ "See docs/postgres.md for more information. You can override this check by"
163
+ "setting 'allow_unsafe_locale' to true in the database config." ,
164
+ "\n " .join (errors ),
159
165
)
160
166
161
167
def convert_param_style (self , sql : str ) -> str :
You can’t perform that action at this time.
0 commit comments