Post not present in API output instantly

unsupported-install

(pontus) #1

Hello!

I am using https://github.com/libresh/compose-discourse 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:

docker_args: 
  - "--network name_of_the_network_you_want_to_add"

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

env:
   MYCOOLKEY: my_cool_value

Yes

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

docker_args:
  -  "-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
##
## BE *VERY* CAREFUL WHEN EDITING!
## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT!
## visit http://www.yamllint.com/ to validate this file as needed

templates:
  - "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 https://meta.discourse.org/t/17247 for details
#expose:
#  - "8080:80"   # http
#  - "4443:443" # https

docker_args:
   - "--network default"
   - "-p 80"

params:
  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

env:
  LANG: en_US.UTF-8
  # DISCOURSE_DEFAULT_LOCALE: en

  ## 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
  #UNICORN_WORKERS: 3

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

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

  ## TODO: List of comma delimited emails that will be made admin and developer
  ## on initial signup example 'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: 'email@address.com'

  ## 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_ADDRESS: smtp.coolhost.com
  DISCOURSE_SMTP_PORT: 25
  DISCOURSE_SMTP_USER_NAME: address@email.com
  DISCOURSE_SMTP_PASSWORD: password
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)
  VIRTUAL_HOST: myhost.domain.app
  VIRTUAL_NETWORK: nginx-proxy
  VIRTUAL_PORT: 80
  LETSENCRYPT_HOST: myhost.domain.app
  LETSENCRYPT_EMAIL: email@address.com

  ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate
  #LETSENCRYPT_ACCOUNT_EMAIL: me@example.com

  ## The CDN address for this Discourse instance (configured to pull)
  ## see https://meta.discourse.org/t/14857 for details
  #DISCOURSE_CDN_URL: //discourse-cdn.example.com

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

## Plugins go here
## see https://meta.discourse.org/t/19157 for details
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git

## Any custom commands to run after building
run:
  - 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='info@unconfigured.discourse.org'"
  - exec: echo "End of custom commands"


(Jay Pfaffman) #11

You can see if you have the same delay on try.discourse.org.