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_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:

  1. Verify if the manual reindexing operation (bin/magento indexer:reindex customer_grid) overlapped with the execution of the indexer_reindex_all_invalid cron job by checking the admin action logs.
  2. Do not execute bin/magento indexer:reindex customer_grid while the indexer_reindex_all_invalid cron is running. If a full reindex is required, use bin/magento indexer:reset customer_grid. The indexer_reindex_all_invalid cron will handle the full reindex as a background process, automatically recreating and populating tables without conflicts.
  3. Use monitoring tools to track when critical cron jobs like indexer_reindex_all_invalid are running to avoid scheduling overlapping tasks.
recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f