3906: Failed to update database because the database is read-only (데이터베이스가 읽기 전용이어서 갱신 실패)
SQL Server의미
읽기 전용으로 표시된 데이터베이스에서 데이터를 수정(INSERT/UPDATE/DELETE/DDL)하려 했다. SQL Server가 쓰기를 거부했다.
원인
데이터베이스가 READ_ONLY로 설정되었거나, 연결이 Availability Group의 secondary replica(읽기용)로 갔거나, 스냅샷이나 복원 후 데이터베이스가 읽기 전용으로 남았거나, 파일 시스템이 읽기 전용인 경우다. 애플리케이션이 실수로 secondary replica로 라우팅되는 것이 전형적인 원인이다.
해결 방법
정말 쓰기가 가능해야 한다면: ALTER DATABASE mydb SET READ_WRITE; Availability Group에서는 애플리케이션을 primary replica로 라우팅한다(ReadWrite 연결 라우팅 / ApplicationIntent 확인). 읽기 전용 스냅샷에는 쓸 수 없으므로 원본 데이터베이스를 대상으로 한다. 파일 권한과 파일 시스템도 확인한다.
같은 데이터베이스의 다른 항목
- 102Incorrect syntax near 'token'
- 8114Error converting data type X to Y
- 1204The instance of the SQL Server Database Engine cannot obtain a LOCK resource (SQL Server Database Engine 인스턴스가 LOCK 리소스를 확보할 수 없음)
- 15023User already exists in the current database (현재 데이터베이스에 사용자가 이미 존재)
- 18452Login failed. The login is from an untrusted domain and cannot be used with Windows authentication (로그인 실패. 신뢰할 수 없는 도메인의 로그인은 Windows 인증에 사용할 수 없음)
- 605Attempt to fetch logical page belongs to a different allocation unit (가져오려는 논리 페이지가 다른 allocation unit에 속함)
- 4922ALTER TABLE ALTER COLUMN failed because one or more objects access this column (하나 이상의 객체가 이 컬럼에 접근하므로 ALTER TABLE ALTER COLUMN 실패)