Post not present in API output instantly


(pontus) #1


I am using to set up my discourse environment. I am using discourse as an API server mostly and use a slim home-cooked client in a project I am working on.

However, there is an issue where a user would post to a topic and then refresh that topic. This would mean in api calls:

  1. Post to topic
  2. Get that topic.

In the output of the second API call (GET discourse.example/t/.json) the post made in the first api call does not show up until about 10 seconds after the first call was made.

Why does this happen? I imagine that this is some cacheing issue, how do I troubleshoot it?

(pontus) #2

I checked now and the database is updated instantly, so it seems that whatever data source the API is getting its data from is not updated quickly enough.

Is the /t/123123.json endpoint connected to the redis cache? If so, can I disable that somehow?

(Jeff Atwood) #3

This is an unsupported install so you are likely seeing broken behavior as a result of the broken install.

(pontus) #4

How do I investigate if this is a behaviour resulted due to a broken install?

What is redis role in the discourse environment? Does Redis cache database reads? Can I turn of redis database cache reads? Do I do that in configuration files that are homemade by you guys?

On the unsupported install note:
Since you have your own docker launcher I felt way more comfortable using something that everyone else uses. And therefor also am able to extend without learning a one-off docker launcher.
I run discourse( and co), an api-bot and an nginx proxy with lets encrypt that ties this all together. It would be fantastic if I could get help to troubleshoot this one issue.

If not then I have these questions about your docker launcher:
Post-install, Can I launch discourse’s image with docker-compose?
How do I set networks in discourse’s docker image?
How do I set environment variables in discourse’s docker image?
Will my docker-compose containers be able to read docker container meta-data from the discourse docker containers?

(Jay Pfaffman) #5

Everyone else uses the launcher.

It’s possible to use the launcher to build an image that you could then use with docker compose, but you won’t get any support here to do so. If you have a budget, I might be able to help. My contact info is in my profile. If you don’t have a budget, your best bet is to follow the standard install cloud document.

Yes. Redis is required and may (but may not) explain your problem.

(pontus) #6

Everyone else, as in everyone else in the docker ecosystem.

I am not looking to buy services.

The Image idea is a good way to launch it from docker-compose, thank you. However I still need to set extra environment variables and docker networks for the container. Where do I do that with discourse’s docker launcher?

So, my questions still remain for anyone not soliciting services.

(pontus) #7

I did not figure out how to do this. The discourse docker launcher spits out a docker run oneliner which I translated into a docker-compose entry but I got some pups ruby error.

as a top level key in the containers .yml file add this:

  - "--network name_of_the_network_you_want_to_add"

Its done under the env key in the containers .yml file:

   MYCOOLKEY: my_cool_value


Another thing I needed to do was adding this docker_arg to expose a port internally in my docker networks:

  -  "-p 80"

(Stephen) #8

We’re not going to be able to help you if you refuse to use the software as it was designed to be run.

Nobody is trying to solicit services, the standard install is free for anyone to use, and is used by thousands of communities in this way. For those who do things differently and back themselves into a corner expertise exists who may be willing to help you, but it doesn’t come for free.

Unsure at this point why you’re continuing to post, unless you’re offering to directly support anyone who follows your install method.

(pontus) #9

Incase someone lands here due to google crawlers I want to leave my findings. After talking to you, I am using your supported software. Everything I wrote is using your software and in the realms of that support. I wanted to clearly express that I do not want to buy help. If it was too blunt I am sorry.

(pontus) #10

Alright, Now I am using the supported software and I am still seeing the exact same issue. You can find my container config below.

The way I tried this was:

  1. Post to topic 7
  2. 1 second later, from the discourse standalone container curl localhost/t/7.json
  3. In the output the post i made in step 1 is not there.
  4. Sometime later, maybe half a minute to a minute it is present in the api output.

How do I troubleshoot this issue? What is the data source for the topic api output? Is there a cache in the webserver?

This is my container:

## this is the all-in-one, standalone Discourse Docker container template
## After making changes to this file, you MUST rebuild
## /var/discourse/launcher rebuild app
## visit to validate this file as needed

  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
  #- "templates/web.ssl.template.yml"
  #- "templates/web.letsencrypt.ssl.template.yml"

## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see for details
#  - "8080:80"   # http
#  - "4443:443" # https

   - "--network default"
   - "-p 80"

  db_default_text_search_config: "pg_catalog.english"

  ## Set db_shared_buffers to a max of 25% of the total memory.
  ## will be set automatically by bootstrap based on detected RAM, or you can override
  #db_shared_buffers: "256MB"

  ## can improve sorting performance, but adds memory usage per-connection
  #db_work_mem: "40MB"

  ## Which Git revision should this container use? (default: tests-passed)
  #version: tests-passed

  LANG: en_US.UTF-8

  ## How many concurrent web requests are supported? Depends on memory and CPU cores.
  ## will be set automatically by bootstrap based on detected CPUs, or you can override

  ## TODO: The domain name this Discourse instance will respond to
  ## Required. Discourse will not work with a bare IP number.

  ## Uncomment if you want the container to be started with the same
  ## hostname (-h option) as specified above (default "$hostname-$config")

  ## TODO: List of comma delimited emails that will be made admin and developer
  ## on initial signup example ','

  ## TODO: The SMTP mail server used to validate new accounts and send notifications
  # SMTP ADDRESS, username, and password are required
  # WARNING the char '#' in SMTP password can cause problems!
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)
  VIRTUAL_NETWORK: nginx-proxy

  ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate

  ## The CDN address for this Discourse instance (configured to pull)
  ## see for details

## The Docker container is stateless; all data is stored in /shared
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log

## Plugins go here
## see for details
    - exec:
        cd: $home/plugins
          - git clone

## Any custom commands to run after building
  - exec: echo "Beginning of custom commands"
  ## If you want to set the 'From' email address for your first registration, uncomment and change:
  ## After getting the first signup email, re-comment the line. It only needs to run once.
  #- exec: rails r "SiteSetting.notification_email=''"
  - exec: echo "End of custom commands"

(Jay Pfaffman) #11

You can see if you have the same delay on