There is 1 comment.
 
 
XWiki Platform / cid:jira-generated-image-avatar-f84a57d5-e04a-4ae0-b268-92658db15686 XWIKI-13300 Open

Change saved into a LESS SSX that is already cache does not always get recompiled

 
View issue   ยท   Add comment
 

1 comment

 
cid:jira-generated-image-avatar-277a00bf-1204-47ed-8c99-31f48d89be6b Manuel Leduc on 15/Oct/26 11:23
 

Reproduced on 17.10.13 (jetty-hsqldb distribution). The stale CSS shows up when the SSX is saved while it is being loaded by other requests. It does not happen on a plain edit with no concurrent load.

Steps

  1. Generate a LESS stylesheet large enough to take about 1.5 s to compile:
    python3 -c 'print(".a { color: red; }\n.m(@x) { width: (@x * 2px); height: darken(#abcdef, (@x / 100%)); }"); [print(".w%d { .m(%d); .n { margin: (%d px / 3); } }" % (i, i % 90, i)) for i in range(1500)]' > ssx.less
    
  2. Create the page LessRepro.Race with an XWiki.StyleSheetExtension object: Content Type LESS, Use this extension On this page or on demand, Code = the content of ssx.less. Save.
  3. Load /xwiki/bin/ssx/LessRepro/Race?language=en&k=0 and check that it contains color:red.
  4. Start 3 parallel loaders on the SSX. The k parameter only gives each loader its own URL:
    rm -f /tmp/stop
    for k in 0 1 2; do
      (while [ ! -f /tmp/stop ]; do
        curl -s -u Admin:admin -o /dev/null "http://localhost:8080/xwiki/bin/ssx/LessRepro/Race?language=en&k=$k"
      done) &
    done
    
  5. While the loaders run, edit the object, replace color: red with color: blue and save.
  6. Wait about 2 seconds, then stop the loaders: touch /tmp/stop
  7. Check what each URL serves:
    for k in 0 1 2; do
      curl -s -u Admin:admin "http://localhost:8080/xwiki/bin/ssx/LessRepro/Race?language=en&k=$k" | grep -o 'color:[a-z]*' | head -1
    done
    

Result

Expected: every URL serves color:blue.
Actual: some URLs keep serving color:red, although the saved object contains color: blue.

Saving the document again does not always fix it. In one run, one URL kept serving an old color through 11 later saves, including a save made with no concurrent load, while the other URLs served the new color each time.

It does not happen on every attempt: between 2 and 6 out of 10 saves left stale CSS in my runs. Repeat steps 4 to 7 (alternating the color) if the first attempt serves the new CSS everywhere. A smaller stylesheet makes the problem much rarer.