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

Expiring stickiness mid-request/job/console #206

Closed
ankane opened this issue May 24, 2018 · 3 comments
Closed

Expiring stickiness mid-request/job/console #206

ankane opened this issue May 24, 2018 · 3 comments

Comments

@ankane
Copy link
Contributor

ankane commented May 24, 2018

Hi, it looks like in #194, the decision was made to freeze time when the context is initialized. In the context of stickiness, this means:

  • Expiration starts when the request is completed
  • Stored items do not expire mid-request/job/console
  • Staged data never expires

From my perspective, none of these seem super intuitive or desirable. Are you open to revisiting this? I'm happy to put together a PR if we want to proceed. Here's what I would expect the behavior to be if master_ttl is 5 (whether run in request, job, or console):

User.create! # primary
sleep(5)
User.last # replica
@bleonard
Copy link
Contributor

bleonard commented May 25, 2018

Interesting. What is your use case? I expect that it is not a normal web request.

I actually saw it an intuitive that once a request sticks, it sticks for the whole time. One person's intuitive can easily be someone else's crazy, of course. Overall, my mind was blown a bit with possibly varying degrees of sync-ness within the request.

Just thinking more about it, if there was to be a clock ticking, we'd want to make sure it would take transactions into consideration. One danger of the naive approach (last "master" SQL call made) might be a long request in a transaction. This wouldn't start syncing over until the COMMIT. So we'd want to handle that.

@ankane
Copy link
Contributor Author

ankane commented May 25, 2018

I was thinking console operations or long running rake tasks/jobs primarily. Once a write happens, it'll never unstick. Good point about transactions.

@bleonard
Copy link
Contributor

We have master stuck automatically on all of our rake jobs just from seeing a few issues over the years.

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

No branches or pull requests

2 participants