502 error message with "UPDATE" query

I am trying to update a field for a single record in an AWS Athena Iceberg table.

The query executes and updates the field in the database. Confirmed by querying the table directly in Athena.

After the query executes, Retool throws a 502 error. What could be causing this?

Hello @digidoc1010 Welcome to the Retool Community,

The 502 error you're encountering in Retool after a successful Athena Iceberg table update suggests a communication or timeout issue between Retool and Athena, not a problem with the update itself since you've confirmed it in Athena. Here's a possible causes :

1. Query Timeout: Iceberg updates can be slow. Increase Retool's query timeout and match it to Athena's execution time. Consider asynchronous updates if supported.

2. Network: Check network stability between Retool and Athena. Verify VPC/proxy config if applicable.

3. Retool Resources: Check Retool logs for errors or resource limits. Contact support if needed.

3 Likes

Thank you for your reply. I don't think it is any of those reasons. There are other queries that take much longer to run so I don't think it's a timeout, network, or resource issue. This is the simplest query I am using in the application, and it runs in less than 3 sec. It is interesting to me that it only happens with this UPDATE query and it is the only UPDATE query in the application. All other queries including INSERT queries run just fine with no errors.

Hi @digidoc1010,

Good to know that this query runs fast, as a networking/gateway timeout would have been my first guess for the culprit.

Do you have any networking layers on top of this AWS server? A load balancer, proxy/reverse-proxy or firewall could be the culprit as well.

Very interesting that all the other queries that are not UPDATE are running fine without and error message. Also good that the update works to successfully change the DB as needed.

Are you about to check our AWS server's logs to see if there are any further details from their end? A 502 error shouldn't be thrown by Retool's backend/server, so this error is likely coming from the AWS server :thinking:

Hi @Jack_T ,

Thank you for your reply. We did check the AWS logs and couldn't find any errors there. After reading about this, it seems like the problem is that I was using a custom sql UPDATE query and not using the gui query interface. I am also going to try disabling "converting queries to prepared statements" and see if that helps.

Could those things be causing the error?

1 Like

Hmm that is very odd the AWS logs didn't have any errors.

My guess is that some middleware could be closing the connection after a certain amount of time. But it is possible that using the GUI will build the query in a way that it can be handled without getting an error response back.

Since the updates 'work' and change the table, it seems like its just a matter of how the code finishes the connection request/response cycle.

Disabling "converting queries to prepared statements" could also help if the issue is with how Retool is formatting the query.

So looking into this more deeply, it seems that the Retool gui editor is not available for an AWS Athena resource, and disabling prepared statements is not shown as an option in the resource settings. How are folks doing insert or update queries against an AWS Athena resource without throwing errors?