# org.apache.kafka.common.errors.InvalidCommitOffsetSizeException: The commit offset size 1048577 exceeds the maximum allowed size 1048576

- **ID:** `kafka/invalid-commit-offset-size`
- **Domain:** kafka
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 75%

## Root Cause

Consumer group offset commit metadata exceeds the configured maximum size (default 1 MB), often due to storing large custom metadata in the commit request.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| kafka_2.13-3.5.0 | active | — | — |
| kafka_2.13-3.6.0 | active | — | — |
| kafka_2.13-3.7.0 | active | — | — |

## Workarounds

1. **Reduce the size of custom metadata passed to `commitSync(Map<TopicPartition, OffsetAndMetadata>)` by removing large objects or storing references externally. Example: `consumer.commitSync(Collections.singletonMap(partition, new OffsetAndMetadata(offset, "small_metadata")));`** (90% success)
   ```
   Reduce the size of custom metadata passed to `commitSync(Map<TopicPartition, OffsetAndMetadata>)` by removing large objects or storing references externally. Example: `consumer.commitSync(Collections.singletonMap(partition, new OffsetAndMetadata(offset, "small_metadata")));`
   ```
2. **Increase `offset.commit.metadata.max.size` in the broker configuration (e.g., to 2097152 bytes) and restart the broker. This setting is dynamic but requires broker restart to take effect.** (80% success)
   ```
   Increase `offset.commit.metadata.max.size` in the broker configuration (e.g., to 2097152 bytes) and restart the broker. This setting is dynamic but requires broker restart to take effect.
   ```
3. **If metadata is not needed, set it to empty string: `consumer.commitSync(Collections.singletonMap(partition, new OffsetAndMetadata(offset, "")));`** (95% success)
   ```
   If metadata is not needed, set it to empty string: `consumer.commitSync(Collections.singletonMap(partition, new OffsetAndMetadata(offset, "")));`
   ```

## Dead Ends

- **** — This affects replication, not the metadata size limit; the commit size limit is independent. (95% fail)
- **** — This controls how many records are polled, not the offset metadata size; the error occurs during commit, not poll. (85% fail)
- **** — This removes all committed offsets for all groups, causing data loss and does not fix the size limit; the topic is recreated with default config. (99% fail)
