What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi, when using the twig cache with a quick ramp of high load (e.g. during load test scenarios), we

U013KSS3MM0
U013KSS3MM0 Posts: 14 🧑🏻‍🚀 - Cadet
edited February 2022 in Help

Hi,

when using the twig cache with a quick ramp of high load (e.g. during load test scenarios), we experienced race conditions during updates of the file src/Generated/Yves/Twig/codeBucket/.pathCache (which could then get corrupt temporarily).

This file is prefilled by the twig cache warmer and contains most Yves twig files. However, we found out that not all files are contained, for example twig files which are located in a Shared module namespace, or some vendor twig files. Furthermore, some cache keys appear to be wrong. For example (first b2c demo shop home page request with warmed cache out of the box):

diff
     '@Pyz:ShopUi/components/atoms/icon-sprite/icon-sprite.twig' => '/data/src/Pyz/Yves/ShopUi/Theme/default/components/atoms/icon-sprite/icon-sprite.twig',
+    '@@SprykerShop:ShopUi/templates/page-layout-main/page-layout-main.twig' => '/data/vendor/spryker-shop/shop-ui/src/SprykerShop/Yves/ShopUi/Theme/default/templates/page-layout-main/page-layout-main.twig',
+    '@@SprykerShop:ShopUi/templates/page-blank/page-blank.twig' => '/data/vendor/spryker-shop/shop-ui/src/SprykerShop/Yves/ShopUi/Theme/default/templates/page-blank/page-blank.twig',
+    '@CmsBlock/template/navigation_block.twig' => '/data/src/Pyz/Shared/CmsBlock/Theme/default/template/navigation_block.twig',
[...]

As a result, we'd be happy to know:
1. Will there be a fix to warm up the cache with all twig files located inside the project?
2. Will the wrong cache keys (e.g. see [1], [2]; the result is a @@ prefix) be fixed? According to [3], the @ char is automatically prepended.
Regarding the race conditions itself:
1. Is it a known issue that the .pathCache file can get corrupted during concurrent file writes?
2. The creation of a directory may also fail with a warning which is "converted" to an ErrorException by the default error handler (ErrorHandlerEnvironment::setErrorHandler()).
FYI: Our current solution is to enhance the cache warmer by custom template name builders and introduce exception handling to the twig FilesystemCache.

Thanks! :)

[1] https://github.com/spryker-shop/b2c-demo-shop/blob/202108.0-p1/src/Pyz/Yves/ShopUi/Theme/default/components/molecules/cart-counter/cart-counter.twig#L1
[2] https://github.com/spryker-shop/b2c-demo-shop/blob/202108.0-p1/src/Pyz/Yves/AgentPage/Theme/default/components/molecules/agent-navigation/agent-navigation.twig#L1
[3] https://docs.spryker.com/docs/scos/dev/front-end-development/yves/custom-twig-functions-for-yves.html

Comments

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 ✨ - Novice

    Is it a known issue that the .pathCache file can get corrupted during concurrent file writes?

    Yes, this is a known issue and the internal ticket is in the backlog to be fixed when there is such a possibility.