element-hq / element-hq/synapse
`allow_unsafe_locale: true` still enforces the check on postgres' encoding
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
This issue has been migrated from [#13709](https://github.com/matrix-org/synapse/issues/13709).
---
### Description
`allow_unsafe_locale` still fails to work when a non-C locale is supplied.
### Steps to reproduce
- Run Synapse with YugabyteDB as the database
- Observe it fails to work because Yugabyte storage actually does not support `C` collation
### Homeserver
local test setup
### Synapse Version
1.66.0
### Installation Method
Docker (matrixdotorg/synapse)
### Platform
Yugabyte is also from the latest docker.
### Relevant log output
```shell
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/synapse/app/homeserver.py", line 382, in setup
hs.setup()
File "/usr/local/lib/python3.9/site-packages/synapse/server.py", line 308, in setup
self.datastores = Databases(self.DATASTORE_CLASS, self)
File "/usr/local/lib/python3.9/site-packages/synapse/storage/databases/__init__.py", line 74, in __init__
prepare_database(
File "/usr/local/lib/python3.9/site-packages/synapse/storage/prepare_database.py", line 152, in prepare_database
_setup_new_database(cur, database_engine, databases=databases)
File "/usr/local/lib/python3.9/site-packages/synapse/storage/prepare_database.py", line 213, in _setup_new_database
database_engine.check_new_database(cur)
File "/usr/local/lib/python3.9/site-packages/synapse/storage/engines/postgres.py", line 137, in check_new_database
raise IncorrectDatabaseSetup(
synapse.storage.engines._base.IncorrectDatabaseSetup: Database is incorrectly configured:
- 'CTYPE' is set to 'en_US.UTF-8'. Should be 'C'
See docs/postgres.md for more information.
******************************************************
Error during initialisation:
Database is incorrectly configured:
- 'CTYPE' is set to 'en_US.UTF-8'. Should be 'C'
See docs/postgres.md for more information.
There may be more information in the logs.
******************************************************
```
### Anything else that would be useful to know?
_No response_
Contributor guide
Research direction
Start in synapse/storage/engines/postgres.py at check_new_database, following the call from synapse/storage/prepare_database.py. Reproduce the setup with YugabyteDB and allow_unsafe_locale enabled, then verify that the unsupported CTYPE check no longer prevents initialization while the relevant database checks still run; docs/postgres.md explains the current requirement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100