# ERROR: out of shared memory HINT: You might need to increase max_pred_locks_per_transaction.

- **ID:** `database/postgresql-max-pred-locks-per-transaction`
- **Domain:** database
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

PostgreSQL 的谓词锁定（predicate locking）用于可重复读隔离级别下的序列化事务，当事务持有过多谓词锁时，共享内存耗尽，导致错误。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| PostgreSQL 13.10 | active | — | — |
| PostgreSQL 14.7 | active | — | — |
| PostgreSQL 15.3 | active | — | — |

## Workarounds

1. **编辑 postgresql.conf，增加 max_pred_locks_per_transaction 值（例如从 64 增加到 128 或 256），然后重启 PostgreSQL 服务。** (85% success)
   ```
   编辑 postgresql.conf，增加 max_pred_locks_per_transaction 值（例如从 64 增加到 128 或 256），然后重启 PostgreSQL 服务。
   ```
2. **降低事务隔离级别为 READ COMMITTED，避免使用谓词锁定：SET TRANSACTION ISOLATION LEVEL READ COMMITTED;** (70% success)
   ```
   降低事务隔离级别为 READ COMMITTED，避免使用谓词锁定：SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
   ```

## Dead Ends

- **** — 增加 max_locks_per_transaction 而不是 max_pred_locks_per_transaction，不解决谓词锁问题。 (75% fail)
- **** — 重启 PostgreSQL 而不调整配置，临时释放内存但问题会重复出现。 (80% fail)
