-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
pipelined plugin css ordering and static naming? #1614
Comments
Ive done some more debugging on our setup, and I can confirm that the 'order' of the plugins is different on the two servers Both servers are running identical docker containers that spin the grav site up behind nginx. No css files are modified at startup time, it seems like the load order is different for the plugins. How can we control this? |
Also, am I correct in assuming that the following code is the code that determines the order in which the plugins are loaded :
If so, is there a chance that different operating systems might return different order of plugins in the iterator? |
It's definitely possible that any Are you running two different platforms in your load balanced solution? I thought you mentioned they were identical docker containers, but is the underlying platform different? |
I checked that, and the docker hosts are both ubuntu 14.04. The docker image is based off phusion/baseimage:0.9.19. The entrypoint doesnt do anything other than start the nginx server up. |
Also, digging deeper, the order for the asset is actually set in the call to addCss(). This is called by each plugin in each plugin's onTwigSiteVariables() handler, and the handlers are added by the following code :
The order that the handlers are added is the order of the associative array 'items', and the order that the events are firedis the order in which the handlers are stored in 'RocketTheme\Toolbox\Event\EventDispatcher (hence Symfony\Component\EventDispatcher\EventDispatcher). So Im really strugglling to understand how this can be different in the two containers. |
I have added extra logging. In the two containers, the order of loading the plugins is very different
This is also the order in which addSubscriber() is called. The order in which addCss is called (via the EventDispatcher calling onTwigSiteVariables() ) is completely different :
|
That's good info. What are the timestamps on the files like in the two containers? Do they line up with the ordering? |
in container1 I have a log line in addTo() that outputs the following on container 1:
and on container 2
|
Suspicious that modified is the same for all? |
Yah, i'm wondering if its related to your container setup or docker in general. I need to try some tests to see if i can replicate the order changing. |
What determines the ordering in Symfony\Component\EventDispatcher\EventDispatcher, I think this :
However in my ./vendor/symfony/event-dispatcher/EventDispatcher.php file the equivalent function is :
|
I will update. As well as Grav, I can see SimpleSearch and LangSwitcher are out of date.
|
(Accidentally closed issue sorry) |
The problem is still there after updating |
The issue is that in Linux many filesystems return the files by order of inodes or generally without applying for any particular order than in which they have been stored into the disk index. The ordering of the plugins is not well defined. I believe that the The only way to enforce some well-defined ordering is to order the items after foreach'ing through them. Actually, I just looked into this code few days ago and was hoping that nobody depended on the ordering. :) |
Can you please try editing your
This basically gets a list of the plugin names, natural sorts the, then runs through and adds the plugins. It should ensure the plugins are loaded in the correct order. |
I am doing something very similar right now as it happens. |
Im pretty sure that is working. I assume that although the containers are based off the same image, aufs gives them different inodes then. The Events are dispatched in the order that Symfony determines, but this is an incomplete sort and does depend on the order of calls to addSubscriber(). So I think this explains it. I am suprised nobody else has hit this issue. It seems that no one else is running css pipelining behind a load balancer...? |
ok cool, we're looking into a better long-term fix though. |
At least not with docker containers where the order is so random probably because everything has the same createdate but different inode ordering ( I assume). |
Thanks for the support on this guys! Grav is a great tool. |
I have a problem with pipeline css when we load balance multiple instances of grav. It seems that the ordering of sections of the pipelined css can be different (although the content is exactly the same). Hence the uri generated from the hash of the css is different and this breaks the load balancer since the css asset has a different name on each server.
In particular it seems like sometimes the langswitcher plugin css gets pipelined before the simplesearch plugin css (both have priority 10) and sometimes the other way around. Is there a way to force the ordering of the plugin css?
Firstly, is this a bug, or is the order of plugins in the pipelined css non-deterministic? i.e. in consecutive startups are you guaranteed to get the same pipelined css?
I have looked at the docs and it seems inconclusive :
Secondly, Im looking for a workaround. Is there a way to set the name of the pipelines css file to something static e.g. style.css rather than the uid. Unfortunately, Ive looked at the code and it seems like the uid is enforced.
The text was updated successfully, but these errors were encountered: