Skip to content

fix(adapter): map engine table-limit errors to Limit - #1077

Merged
abnegate merged 1 commit into
mainfrom
fix/map-ddl-limit-errors
Nov 23, 2026
Merged

abnegate merged 1 commit into
mainfrom
fix/map-ddl-limit-errors

Conversation

@abnegate

@abnegate abnegate commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

What

Maps the engine errors for a table definition past an engine limit to Limit (a Schema exception):

Engine Code Message
MariaDB/MySQL 1118 ER_TOO_BIG_ROWSIZE Row width limit reached
MariaDB/MySQL 1117 ER_TOO_MANY_FIELDS Column limit reached
MariaDB/MySQL 1069 ER_TOO_MANY_KEYS Index limit reached
MariaDB/MySQL 1070 ER_TOO_MANY_KEY_PARTS Index attribute limit reached
MariaDB/MySQL 1074 ER_TOO_BIG_FIELDLENGTH Attribute size limit reached
Postgres 54011 too many columns Column limit reached

Why

On staging, a table with ~120 varchar columns hit SQLSTATE[42000] 1118 Row size too large ... is 8126. InnoDB's inline row ceiling (8126 bytes) is far below the 65535 bytes Database::createAttribute()'s width check counts against, so the DDL reaches the engine, and processException() returned the raw PDOException. The Appwrite databases worker treats Schema exceptions as a rejection of the customer's request (mark the column failed, ACK the job), but a raw PDOException looks like an outage, so each job was retried 5 times over ~22 minutes of NATS backoff. 16 of them held every maxAckPending slot on the consumer, and other projects' columns on that pool stayed processing for 30+ minutes.

The MariaDB-family codes are matched on errno alone because their SQLSTATEs differ (1117 is HY000, the rest 42000).

Tests

EngineErrorMappingTest::testTableDefinitionPastAnEngineLimitIsALimit: 11 cases (5 codes × MariaDB/MySQL + Postgres 54011). All 11 fail without the adapter change. The existing "other 54000 stays raw" fixture used the 1600-column message, which Postgres actually raises as 54011, so it now uses a real 54000 (row is too big).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Schema limit errors from MariaDB and PostgreSQL are now reported as clear limit-related errors, including cases involving too many columns, oversized rows, and limits on indexes or column sizes. Other database error handling remains unchanged.

MySQL raises 1118 (row size too large) against InnoDB's 8126-byte inline
row ceiling, well below the 65535 bytes the width pre-check counts, so a
wide table of varchar columns reaches the engine and comes back as a raw
PDOException. Callers that classify failures by exception type (the
Appwrite databases worker treats Schema as a rejection of the request)
cannot tell it apart from an outage, so the job was retried until its
delivery budget ran out.

Map ER_TOO_BIG_ROWSIZE, ER_TOO_MANY_FIELDS, ER_TOO_MANY_KEYS,
ER_TOO_MANY_KEY_PARTS and ER_TOO_BIG_FIELDLENGTH on MariaDB/MySQL, and
54011 (too many columns) on Postgres, to Limit. These are matched on the
engine errno alone because the SQLSTATE differs between them (1117 is
HY000, the rest 42000).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@appwrite

appwrite Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Code review

Commit Status Tier Verdict Details
199590a Reviewed Reviewed 🟢 S · Ready to merge ✅ Approved View review

The mappings fit the existing exception-handling conventions and the added tests cover the changed cases.

The MariaDB/MySQL adapters now map selected engine schema-limit error codes to Limit exceptions, and Postgres maps SQLSTATE 54011 for excessive columns. Unit coverage exercises the mappings for both MariaDB-family adapters and Postgres, while keeping the unrelated Postgres 54000 case raw.

Walkthrough (3)
File Change
src/Database/Adapter/MariaDB.php Maps MariaDB/MySQL table and index limit error numbers to Limit exceptions.
src/Database/Adapter/Postgres.php Maps Postgres SQLSTATE 54011 to a column-limit exception.
tests/unit/EngineErrorMappingTest.php Adds engine error mapping cases and updates the unrelated 54000 fixture.

Reviewed 199590a

Tip

Comment @appwrite review to re-run, or mention @appwrite with a question.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

MariaDB and PostgreSQL adapters now map selected schema-limit errors to LimitException. Unit tests cover the mappings and verify passthrough behavior for a PostgreSQL row-too-large error.

Changes: Schema-limit error mapping

Layer / File(s) Summary
Map schema-limit errors
src/Database/Adapter/MariaDB.php, src/Database/Adapter/Postgres.php
MariaDB maps selected driver error codes to limit messages. PostgreSQL maps error code 54011 with driver error code 7 to LimitException('Column limit reached').
Test error mappings
tests/unit/EngineErrorMappingTest.php
Tests cover MariaDB and MySQL schema-limit mappings and the PostgreSQL too-many-columns mapping. The PostgreSQL passthrough test now uses a row-too-large error.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: arnabchatterjee20k, appwrite

Merge Risk: Minimal · up to 19959

Oversized table definitions that hit engine limits will now be reported as schema limit rejections instead of raw database exceptions. The change is small and covered by unit tests. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(adapter): map engine table-limit errors to Limit" matches the main change. The PR maps MariaDB/MySQL table-definition limit errors (1069, 1070, 1074, 1117, 1118) and PostgreSQL 54011 to…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(adapter): map engine table-limit errors to Limit" matches the main change. The PR maps MariaDB/MySQL table-definition limit errors (1069, 1070, 1074, 1117, 1118) and PostgreSQL 54011 to the Limit schema exception, as shown in the MariaDB, Postgres, and test file changes. The title is specific and concise. It does not name the database engines, but it still identifies the primary change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b0da7f7 and 199590a.

Files selected for processing: 3

  • src/Database/Adapter/MariaDB.php
  • src/Database/Adapter/Postgres.php
  • tests/unit/EngineErrorMappingTest.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@abnegate
abnegate merged commit df03619 into main Nov 23, 2026
22 checks passed
@abnegate
abnegate deleted the fix/map-ddl-limit-errors branch November 23, 2026 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant