No internet connection
  1. Home
  2. Support

Site export runs out of memory

By Christian Scheuer @chrscheuer
    2021-07-25 10:14:56.278Z

    Hi @KajMagnus

    We're relying on the site export endpoint to be able to export forum data for syncing up with our ClickUp backend. Unfortunately, it looks like it's implemented in a way where it instead of streaming the data out tries to build the entire thing in memory and fails with an Out Of Memory exception.
    Can you take a look to see how this could be improved? We're dead in the water with this now.

    
    500 Internal Server Error
    
    Something went wrong: [DwE500ERR]
    
    java.lang.OutOfMemoryError: Java heap space
    	at java.util.Arrays.copyOf(Arrays.java:3236)
    	at java.lang.StringCoding.safeTrim(StringCoding.java:79)
    	at java.lang.StringCoding.access$300(StringCoding.java:50)
    	at java.lang.StringCoding$StringEncoder.encode(StringCoding.java:305)
    	at java.lang.StringCoding.encode(StringCoding.java:344)
    	at java.lang.String.getBytes(String.java:918)
    	at akka.util.CompactByteString$.apply(ByteString.scala:942)
    	at akka.util.ByteString$.apply(ByteString.scala:52)
    	at play.api.mvc.Codec$.$anonfun$javaSupported$1(Results.scala:391)
    	at play.api.mvc.Codec$$$Lambda$620/1717967062.apply(Unknown Source)
    	at play.api.http.DefaultWriteables.$anonfun$wString$1(Writeable.scala:187)
    	at play.api.http.DefaultWriteables$$Lambda$623/1220292558.apply(Unknown Source)
    	at play.api.http.Writeable.toEntity(Writeable.scala:24)
    	at play.api.mvc.Results$Status.apply(Results.scala:519)
    	at talkyard.server.sitepatch.SitePatchController.exportSiteJsonImpl(SitePatchController.scala:66)
    	at talkyard.server.sitepatch.SitePatchController.$anonfun$exportSiteJson$1(SitePatchController.scala:53)
    	at talkyard.server.sitepatch.SitePatchController$$Lambda$7662/1089139306.apply(Unknown Source)
    	at scala.Function1.$anonfun$andThen$1(Function1.scala:57)
    	at scala.Function1$$Lambda$483/2129344690.apply(Unknown Source)
    	at ed.server.http.PlainApiActions$$anon$1.runBlockIfAuthOk(PlainApiActions.scala:595)
    	at ed.server.http.PlainApiActions$$anon$1.invokeBlockAuthViaApiSecret(PlainApiActions.scala:326)
    	at ed.server.http.PlainApiActions$$anon$1.invokeBlockImpl(PlainApiActions.scala:228)
    	at ed.server.http.PlainApiActions$$anon$1.invokeBlock(PlainApiActions.scala:123)
    	at ed.server.http.PlainApiActions$$anon$1.invokeBlock(PlainApiActions.scala:96)
    	at play.api.mvc.ActionBuilder$$anon$9.apply(Action.scala:379)
    	at ed.server.http.PlainApiActions$$anon$1.$anonfun$composeAction$1(PlainApiActions.scala:110)
    	at ed.server.http.PlainApiActions$$anon$1$$Lambda$1803/823358094.apply(Unknown Source)
    	at ed.server.http.SafeActions$ExceptionAction$.invokeBlock(SafeActions.scala:126)
    	at ed.server.http.SafeActions$ExceptionAction$.invokeBlock(SafeActions.scala:83)
    	at play.api.mvc.ActionBuilder$$anon$9.apply(Action.scala:379)
    	at play.api.mvc.Action.$anonfun$apply$4(Action.scala:82)
    	at play.api.mvc.Action$$Lambda$1818/540280121.apply(Unknown Source)
    
    
    Solved in post #3, click to view
    • 7 replies
    1. I'll do

      1. Rebooting, added more memory (will be 2 minutes downtime (sorry))

        Reply1 LikeSolution
        1. Now there's more memory.

          The OOM happened yesterday 10:12 UTC — that's 40 minutes until the same time, today.

          "eventTime":"2021-07-25T10:12:32.571Z",
          "message":"Replying internal error to:
             GET  ... /-/export-site-json [DwE500ERR] java.lang.OutOfMemoryError
          
      2. In reply tochrscheuer:

        How often does your server sync with Talkyard's database? In the HTTP logs, I don't see any request to export-site-json after last Sunday 2021-07-25. I was previously thinking it'd sync daily or sth like that

        (Maybe the sync script doesn't retry after a failure? And needs a kick)

        1. CChristian Scheuer @chrscheuer
            2021-07-27 18:49:46.427Z

            Yea the script stopped working at some point in the past. It should at least sync daily, but ideally we'd use webhooks for this instead so it doesn't need to do a full export except in special circumstances.

            1. In reply toKajMagnus:
              CChristian Scheuer @chrscheuer
                2021-07-28 20:31:57.299Z

                Thank you, this worked now.
                It takes the webserver several minutes (4+ by my estimate) to build the json, but it downloads eventually :) As long as it works now, this isn't a huge priority, but as the forum grows, this would become unmanageable eventually. I think this would need to find some way of streaming / paging the results to conserve webserver memory on huge sites. Imagine we had 10x or even 50x the amount of data (very likely scenario in the future, I believe).

                1. CChristian Scheuer @chrscheuer
                    2021-07-28 20:34:07.428Z

                    Just synced 160 bug reports and feature requests to ClickUp using this. Gonna be SO helpful for our next version :)