Skip to content

Amazon Athena: Internal error when running MSCK REPAIR TABLE

0

Hi, I got the error when running MSCK REPAIR TABLE on a specific table:

Amazon Athena experienced an internal error while executing this query. Please try submitting the query again and if the issue reoccurs, contact AWS support for further assistance. We apologize for the inconvenience. This query ran against the "mydatabase" database, unless qualified by the query. Please post the error message on our forum or contact customer support with Query Id: 8536ab8c-f97a-4ce7-9626-5b9ef85366c1

This is reproducible. The data in the underlying S3 bucket has been updated. It is partitioned into a large number of partitions within a directory structure with multiple levels. Any ideas what the problem actually might be and how to solve it? Thanks,

asked a year ago195 views

1 Answer
0

The internal error you're experiencing with MSCK REPAIR TABLE is likely due to the large number of partitions in your table. When a table has more than approximately 100,000 partitions, MSCK REPAIR TABLE can fail due to memory limitations.

To solve this issue, I recommend using ALTER TABLE ADD PARTITION instead of MSCK REPAIR TABLE. This approach allows you to add partitions incrementally rather than all at once, which helps avoid the memory constraints that cause the internal error.

Other potential causes for this error could include:

  1. Temporary system issues within Athena's query engine
  2. Particularly complex partition structures
  3. Partition values containing special characters like colons (:) which can cause MSCK REPAIR TABLE to fail silently
  4. Partition column names beginning with an underscore (_)

If you need to continue using MSCK REPAIR TABLE, you might try breaking down your operation by working with smaller subsets of partitions at a time. However, for tables with very large numbers of partitions, ALTER TABLE ADD PARTITION is the recommended approach.

Also, ensure that your partition locations use the s3:// protocol (not s3a://) and that data for separate tables is kept in separate folder hierarchies to avoid partition confusion.
Sources
Troubleshoot issues in Athena - Amazon Athena
MSCK REPAIR TABLE - Amazon Athena
INTERNAL_ERROR_QUERY_ENGINE | AWS re:Post

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.