Skip to content

Conversation

@ezelkow1
Copy link
Member

When hosting.config reloads, currently the file is properly loaded and placed in a new hosting table. However when ats goes to place it in use in the current cache structure it's using an ink_atomic_swap(new_table, old_table). This function does not actually swap, it only does a set, so it effectively overwrites the new table with the old table, and then continues, never updating. This is why reloading with a new hosting.config never sees an update in use.

This PR changes that to get rid of the ink_atomic use and just use a std_atomic for the table, replaces the host table ptr, and deletes the old one

closes #7220

@ezelkow1
Copy link
Member Author

suggestion from @SolidWallOfCode to take a look at the ipallow logic and see if we can do similar here

@zwoop zwoop added this to the 10.0.0 milestone May 26, 2022
@apache apache deleted a comment from ezelkow1 Jul 5, 2022
@apache apache deleted a comment from ezelkow1 Jul 5, 2022
@ezelkow1
Copy link
Member Author

Finally getting back to this, using the ipallow logic would take a very large rewrite from what I can tell. IMHO we should just do the simplest fix of swapping the values to the 'atomic_swap', the way it was meant to be used in the first place, to at least have this working. Then when we get around to a full hosting rewrite can look at doing it better then

@SolidWallOfCode
Copy link
Member

What we should really do is change it to a std::shared_ptr with a read/write mutex. This fix retains the arbitrary timeout which could lead to issues.

@ezelkow1
Copy link
Member Author

[approve ci]

CacheHostTable *old = (CacheHostTable *)ink_atomic_swap(&t, *ppt);
CacheHostTable *t = new CacheHostTable((*ppt)->cache, (*ppt)->type);
auto old = *ppt;
(*ppt) = t;
Copy link
Member

@rob05c rob05c Aug 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be a std::atomic<CacheHostTable *>* ppt or possibly std::atomic<std::atomic<CacheHostTable *>*> ppt;.

With the outer pointer-pointer being atomic, but not the inner, I believe in auto old = *ppt the dereference *ppt will be atomic, but not the assignment to old. Likewise, in (*ppt) = t; I believe the *ppt dereference will be atomic, but when it takes t and assigns it to the value-pointer-to-by ppt, I don't think that will be atomic.

typedef int (CacheHostTableConfig::*CacheHostTabHandler)(int, void *);
struct CacheHostTableConfig : public Continuation {
CacheHostTable **ppt;
std::atomic<CacheHostTable **> ppt;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this isn't used by anything external. It'd be nice to make it private, to enforce that, and make it easier for readers to know that

@randall
Copy link
Contributor

randall commented Oct 25, 2022

Is this pr still needed now that #9046 has been merged?

@ezelkow1
Copy link
Member Author

Is this pr still needed now that #9046 has been merged?

nope, closing

@ezelkow1 ezelkow1 closed this Oct 25, 2022
@zwoop zwoop removed this from the 10.0.0 milestone Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hosting.config requires restart, but docs say reloadable

5 participants