Resolve missing customer_grid_flat table error in Adobe Commerce
The customer_grid_flat table missing error in Adobe Commerce 2.4.5 occurs when overlapping reindexing processes both delete and recreate the customer_gridtable simultaneously, causing SQLSTATE[ 42S02] failures. To resolve this, verify admin action logs for process conflicts, avoid manual reindexing during cron execution, reset the indexer using bin/magento indexer:reset customer_grid, and monitor cron job schedules to prevent future overlaps.
Description description
Environment
- Product: Adobe Commerce, v2.4.5
- Instance: Production
Issue/Symptoms
- The
customer_grid_flattable is missing from the database. - Errors like SQLSTATE
[42S02]: Base table or view not found: 1146 Table ‘z3gmkbwmwrl4g.customer_grid_flat’ doesn’t exist appear.
Cause
The issue arises because when the customer_grid full indexer runs, it drops and recreates the customer_grid table to adjust the columns, then inserts data. If a manual reindex and the indexer_reindex_all_invalid cron job run at the same time, one process deletes the customer_grid table while another process tries to insert data into it. This overlap leads to SQLSTATE[ 42S02] : Base table or view not found: 1146 Table ‘z3gmkbwmwrl4g.customer_grid_flat’ doesn’t exist errors.
Resolution resolution
Restore the table by performing a full reindex. To address and prevent this issue, follow these steps:
- Verify if the manual reindexing operation (
bin/magento indexer:reindex customer_grid) overlapped with the execution of theindexer_reindex_all_invalidcron job by checking the admin action logs. - Do not execute
bin/magento indexer:reindex customer_gridwhile theindexer_reindex_all_invalid cronis running. If a full reindex is required, usebin/magento indexer:reset customer_grid. Theindexer_reindex_all_invalidcron will handle the full reindex as a background process, automatically recreating and populating tables without conflicts. - Use monitoring tools to track when critical cron jobs like
indexer_reindex_all_invalidare running to avoid scheduling overlapping tasks.