[Amazon Athena][ErrorCode: INTERNAL_ERROR_QUERY_ENGINE] Amazon Athena experienced an internal error while executing this query. Please contact AWS support for further assistance. You will not be charged for this query. We apologize for the inconvenience.

In the past couple months, I was developing an application that uses Amazon Athena. Amazon Athena is basically their own version of MariaDB ColumnStore, which is more integrated with their own infrastructures. Long story short, it is Amazon’s own MySQL database for big data engine. While I was checking out its new features, I tried some simple queries such as SELECT count(*) from my_table, and it throws out the following error:

Here is the error message:

[ErrorCode: INTERNAL_ERROR_QUERY_ENGINE] Amazon Athena experienced an internal error while executing this query. Please contact AWS support for further assistance. You will not be charged for this query. We apologize for the inconvenience.

Obviously, the error message didn’t tell much about what was the problem.

Here is my input:

$athenaClient->startQueryExecution(
		array(
			'QueryExecutionContext' => array(
				'Catalog' 	=> 'AwsDataCatalog',
        		        'Database' 	=> 'my_database',
			),
			'QueryString' => 'SELECT * FROM "my_database"."my_table" limit 10;',

			'ResultConfiguration' => array(
				'OutputLocation' => 'S3://s3bucket/my_folder/', 
			),
			'WorkGroup' => 'primary',
			
		)

Here is my output:

$athenaClient->GetQueryResults()

[Status] => Array
                (
                    [State] => FAILED
                    [StateChangeReason] => [ErrorCode: INTERNAL_ERROR_QUERY_ENGINE] Amazon Athena experienced an internal error while executing this query. Please contact AWS support for further assistance. You will not be charged for this query. We apologize for the inconvenience.
                    [SubmissionDateTime] => Aws\Api\DateTimeResult Object
                        (
                            [date] => 2022-11-24 15:51:13.344000
                            [timezone_type] => 3
                            [timezone] => UTC
                        )

                    [CompletionDateTime] => Aws\Api\DateTimeResult Object
                        (
                            [date] => 2022-11-24 15:51:14.488000
                            [timezone_type] => 3
                            [timezone] => UTC
                        )

                    [AthenaError] => Array
                        (
                            [ErrorCategory] => 1
                            [ErrorType] => 401
                            [Retryable] => 
                            [ErrorMessage] => [ErrorCode: INTERNAL_ERROR_QUERY_ENGINE] Amazon Athena experienced an internal error while executing this query. Please contact AWS support for further assistance. You will not be charged for this query. We apologize for the inconvenience.
                        )

                )


So what was the problem? The problem had nothing to do with the query. Instead, it was my S3 bucket URL. The protocol of the URL needed to be in lower case, i.e., s3://, not S3://. After I changed it to lower case, everything worked fine.

Our sponsors:

One Reply to “[Amazon Athena][ErrorCode: INTERNAL_ERROR_QUERY_ENGINE] Amazon Athena experienced an internal error while executing this query. Please contact AWS support for further assistance. You will not be charged for this query. We apologize for the inconvenience.”

  1. Phil

    Thank you!
    I also had an issue with the s3 location. I think you actually have this error whenever you cannot right to S3 but it is not really checked before hand that you can write there (A simple check for AWS might be to check if they can create objects at the desired location before or while running the query).

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *