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_grid
table 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_flat
table 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_invalid
cron job by checking the admin action logs. - Do not execute
bin/magento indexer:reindex customer_grid
while theindexer_reindex_all_invalid cron
is running. If a full reindex is required, usebin/magento indexer:reset customer_grid
. Theindexer_reindex_all_invalid
cron 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_invalid
are running to avoid scheduling overlapping tasks.