504 error on download CSV/XLSX

Hello, I recently upgraded to Metabase version 0.33.2, which unlocked the option to download more than 2000 rows of a question.
But when I try to download the question results, the application just crashes after some time and gives a 504 error.
I am using version 0.33.2, with AWS Beanstalk (using a t3.medium machine as EC2), connecting to PostgreSQL (RDS). The question is just a simple SQL Query (SELECT * FROM table), and the results are ± 300000 entries (way below the 1000000 limit).
Is this known bug? Or there is a way to avoid this? (I cannot put any log from metabase here, because after the 504 error, I must reboot the EC2 and due to this all the logs are cleaned)

Thanks

Hi @ulidantas
Without logs, it’s difficult to figure out what’s going on exactly.
But 504 is a timeout error, which doesn’t come from Metabase, but a reverse-proxy or load balancer. Make sure that you change the timeout of anything in front of Metabase to allow it to finish the download. Most timeouts defaults to 60 seconds.

Thanks! I raised the Load Balancer time limit, but anyway the download failed. The good part is that I was able to see the log after that, and this point got my attention:

[05947b80-81e6-4eaa-9787-98bd8f2ee12f] 2019-09-18T16:35:31-03:00 INFO metabase.middleware.exceptions Requisição cancelada antes de finalizar (Requisition cancelled before ending)
[05947b80-81e6-4eaa-9787-98bd8f2ee12f] 2019-09-18T16:35:31-03:00 ERROR metabase.middleware.log POST /api/dataset/xlsx 500 4,1 mins (11 DB calls)
{:message "Java heap space", :type java.lang.OutOfMemoryError, :stacktrace (nil)}

[05947b80-81e6-4eaa-9787-98bd8f2ee12f] 2019-09-18T16:35:31-03:00 INFO metabase.middleware.exceptions Requisição cancelada antes de finalizar (Requisition cancelled before ending)

@ulidantas
When downloading 300k rows, it’s going to take a lot of RAM for Metabase to produce the XLSX file, so I would recommend that you try CSV instead.
And you might need more RAM anyways, since Metabase is not streaming the CSV download, but is generating it and then pushing to the client - there’s a couple of issues open on that.

I am also facing the CSV download issue after upgrading to v0.33.3. I am able to get the first 2000 rows in Metabase, but when I try to export to CSV, I get 504 timeout error. It gets time out after 1 minute.
My team is unable to work because of CSV failures. Please look into this urgently.
I am running Metabase in a docker container. Here are the logs:

10-01 08:27:45 INFO middleware.exceptions :: Request canceled before finishing.
10-01 08:27:45 ERROR middleware.log :: Error logging API request
java.lang.NullPointerException
    	at clojure.lang.Numbers.ops(Numbers.java:1068)
    	at clojure.lang.Numbers.gte(Numbers.java:263)
    	at clojure.lang.Numbers.gte(Numbers.java:3981)
    	at metabase.middleware.log$fn__65659.invokeStatic(log.clj:81)
    	at metabase.middleware.log$fn__65659.invoke(log.clj:80)
    	at metabase.middleware.log$log_info$fn__65682.invoke(log.clj:104)
    	at clojure.core$some.invokeStatic(core.clj:2701)
    	at clojure.core$some.invoke(core.clj:2692)
    	at metabase.middleware.log$log_info.invokeStatic(log.clj:104)
    	at metabase.middleware.log$log_info.invoke(log.clj:102)
    	at metabase.middleware.log$logged_response.invokeStatic(log.clj:139)
    	at metabase.middleware.log$logged_response.invoke(log.clj:133)
    	at clojure.core$comp$fn__5807.invoke(core.clj:2569)
    	at clojure.core$comp$fn__5807.invoke(core.clj:2569)
    	at clojure.core$comp$fn__5807.invoke(core.clj:2569)
    	at metabase.api.dataset$fn__47399$as_format_async__47404$fn__47405$fn__47470$state_machine__12318__auto____47499$fn__47502.invoke(dataset.clj:132)
    	at metabase.api.dataset$fn__47399$as_format_async__47404$fn__47405$fn__47470$state_machine__12318__auto____47499.invoke(dataset.clj:125)
    	at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:973)
    	at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:972)
    	at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:977)
    	at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:975)
    	at clojure.core.async.impl.ioc_macros$take_BANG_$fn__12336.invoke(ioc_macros.clj:986)
    	at clojure.core.async.impl.channels.ManyToManyChannel$fn__7222$fn__7223.invoke(channels.clj:95)
    	at clojure.lang.AFn.run(AFn.java:22)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    	at java.base/java.lang.Thread.run(Unknown Source)

@devrajshourya But 504 is a timeout error, which doesn’t come from Metabase, but a reverse-proxy or load balancer in front of Metabase. Make sure that you change the timeout of anything in front of Metabase to allow it to finish the download.

@flamber Thank you for your reply and explanation. I figured out the problem and increased the timeout in the ngnix configuration. I added the following params in the nginx.conf to fix the issue:

proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;