164: READONLY (code 164)
The session runs under the readonly setting, so INSERT, CREATE, ALTER and other writes are refused at the server.
- Код ошибки
164- Имя
READONLY- Категория
- Authentication and access
Что это значит
READONLY (164) means the session's readonly setting blocks data changes: readonly = 1 allows reads only, so SET is blocked too; readonly = 2 allows reads and SET but still blocks data changes. The value comes from the user's profile or the connection string, not from the table; a table refusing writes is TABLE_IS_READ_ONLY (242).
Распространённые причины
- The user's profile sets readonly = 1 or 2, common for dashboards and the HTTP interface.
- The connection string or driver appends readonly=1 and the application then sends writes.
- A proxy or managed service hands out a readonly profile the user never asked for.
Find the cause
`system.settings` for the session value, `SHOW GRANTS FOR app_user` and `system.users` for the profile, and the server's users.xml or access-control storage for where readonly is set.
Как исправить
-
See what the session enforces and whether it was changed on the fly.
SELECT name, value, changed FROM system.settings WHERE name = 'readonly';
-
Ask an administrator to move the user into a writable profile; do not try to escape the restriction.
ALTER USER app_user SETTINGS PROFILE default;
-
Split workloads: keep dashboards on their readonly user and run writes as a separate read-write user.
GRANT SELECT ON my_db.* TO dashboard_ro;
Other ways to handle it
ACCESS_DENIED (497) fails one statement for missing grants; 164 blocks all writes for the session. A readonly = 1 session that tries SET gets 164 (Cannot modify 'max_threads' setting in readonly mode); a readonly = 2 session may SET other settings, but changing readonly itself also returns 164.
Безопасное воспроизведение
The same INSERT succeeds for an unrestricted user, which proves the block is the session profile, not the table.
clickhouse-client --setting readonly=1, then INSERT INTO scratch_f VALUES (1) returns 164; the same INSERT as an unrestricted user succeeds.
Вопросы
What is the difference between readonly 1 and 2?
readonly = 1 blocks data changes and SET; readonly = 2 allows SET but still blocks data changes. Remove the managed-service sentence unless it is sourced.
Is this the same as a table in read-only mode?
No. 164 is the session setting, 242 TABLE_IS_READ_ONLY is a per-table state. The message and code tell you which one you hit.
Связанные ошибки
More authentication and access errors
Код и текст сообщения взяты из ClickHouse documentation (system.errors). Смотрите весь ClickHouse error list или поиск по всем ошибкам баз данных.
Work on ClickHouse in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for ClickHouse and the other databases you use.
Текст и данные на этой странице: CC BY 4.0, с указанием SQLly (sqlly.app). Код и фрагменты SQL: MIT. Подробнее о лицензии Цитируемый текст сообщений об ошибках принадлежит производителю СУБД.