Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ticker: updates of markets.json are not atomic #2361

Closed
jacekn opened this issue Mar 5, 2020 · 1 comment · Fixed by #2362
Closed

ticker: updates of markets.json are not atomic #2361

jacekn opened this issue Mar 5, 2020 · 1 comment · Fixed by #2362
Assignees

Comments

@jacekn
Copy link
Contributor

jacekn commented Mar 5, 2020

We noticed that occasionally GET requests for markets.json return empty result. The problem always corrects itself without intervention. It also always happens 2-3s after past a minute which makes me thing it's related with the following cronjob:

* * * * * /opt/stellar/bin/ticker generate market-data --db-url=xxx -o /opt/stellar/www/markets.json

I looked at the code and the file is truncated using os.Create() and then written again:
https://github.com/stellar/go/blob/master/services/ticker/internal/utils/main.go#L21

If there is a temporary storate slowness we can serve empty or incomplete file for a brief moment.

It would be good to make the update operation atomic (simple way could be to write markets.json.new and then move to markets.json but there may be a better way in go).

@accordeiro
Copy link
Member

@jacekn thanks for finding the problem and already coming with a solution! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants