Page MenuHomePhabricator

Template used as campaign headerLabel is cached unwantedly
Closed, ResolvedPublic

Description

Author: romaine.wiki

Description:
Today Wiki Loves Earth started, a big project similar to Wiki Loves Monuments. Above the upload wizard when users use the wizard to upload through a specially created campaign, above it they see a banner which shows if the campaign has started, running or finished. As Wiki Loves Monuments had more than 100 campaigns, this switch we made automatically to make sure uploads are excluded when they are uploaded outside the contest period and to make sure that participants see information on top that they know they can upload or have to wait if they want to participate.

Today we noticed that the automatic switch we built in with a template is not working as it did before, template is not changed in the way it works. We had to do null edits on all campaigns to make the campaigns show the correct banner.

Please let the campaigns not be cached, just as before, so that users will be able to see the actual banners above it. Thanks.

(I am the maintainer of campaigns for Wiki Loves Earth and Wiki Loves Earth, the largest photo competition in the world.)


Version: unspecified
Severity: major

Details

Reference
bz64685

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 3:21 AM
bzimport added a project: UploadWizard.
bzimport set Reference to bz64685.
bzimport added a subscriber: Unknown Object (MLST).

(In reply to Romaine from comment #0)

Today we noticed that the automatic switch we built in with a template is
not working as it did before, template is not changed in the way it works.

Link to template welcome.

romaine.wiki wrote:

The current template is https://commons.wikimedia.org/wiki/Template:Wiki_Loves_Earth_is_running

This template is identical in structure of https://commons.wikimedia.org/wiki/Template:WLM-is-running - the template we used for Wiki Loves Monuments in more than 100 campaigns in both 2012 as 2013, both editions it worked fine.

Confirmed locally. When the template doesn't exist UploadWizard shows a red link, when the template is created, UW picks it up, but when the template is updated, UW still displays the old version.

Caching was introduced here: https://gerrit.wikimedia.org/r/#/c/86960/

The commit message suggests that there's supposed to be a job-based invalidation.

OK, I think I've figured it out. Basically that caching was introduced and it has a couple of limitations, which I don't think we can avoid:

The link between the campaign and the templates it uses will only be created if you create or save the campaign while the template exists. If you create the campaign before the templates it references, the connection won't be made and subsequent updates to the template won't get picked up. The workaround is to re-save the campaign once you've created the template. That create the link between the two and any subsequent update of the template will update the campaign.

Secondly, the parent template (in this case https://commons.wikimedia.org/w/index.php?title=Template:Wiki_Loves_Earth_is_running ) needs to be saved in order for the update to trickle down to the template. That's a single save to update all the campaigns though. This is what you used to have, right?

Lastly, the update that trickles down to the campaigns runs through a job, so it won't be immediate. I don't know what the job queue on Commons is usually like, but it could be seconds, minutes, or hours depending on the job queue at the time of the template update.

Does that all make sense? I imagine you either ran into the red link issue (referencing templates before they exist) or the fact that the update is asynchronous. As for this caching, I imagine it was introduced for performance reasons.

And by the way I've verified that the update/invalidation works correctly on my local install.

romaine.wiki wrote:

I do not think this describes the experienced problem. (We do not have a red link issue.) On top of the campaign, we want to be able to show a banner if the campaign has not started yet, a banner for if it is running or a banner if it has ended.

With Wiki Loves Monuments we had about 100 campaigns we had to start. To prevent errors and to lighten the workload, we introduced in 2012 a timer template. This timer template automatically changes the banner (before, during or after) at certain points in time: when the contest starts or ends. This worked perfectly in both 2012 and 2013. Users see the banner and think: ok, now my uploads are eligible or not.

Now with Wiki Loves Earth, we use exactly the same set-up and now it doesn't work any more. When the point of time is reached that a contest starts/ends, the campaign shows the previous banner template instead of the actual banner. (Previous it showed the actual banner.)

Only when we did a null edit on every campaign, the right banner was shown.

romaine.wiki wrote:

This problem of not showing the actual banner caused a lot of confusion at the beginning of this month and a lot of users reported this problem to us, it is an essential part of the infrastructure of contests.

Wiki Loves Monuments is coming again in September with many campaigns, also at the end of this month and a month later this is a problem.

You'll need to re-save the template and the changes should trickle down. The caching introduced at the end of last year was probably introduced as an operational necessity, I imagine that the lack of caching was inefficient. That sort of thing is rarely introduced for frivolous reasons, in all likelihood it means that the old cache-less technique was a strain on servers.

The caching is what's preventing the time-based template from updating automatically. Re-saving each campaign shouldn't be necessary, just re-saving the common template should do the job. That sounds like a reasonable workaround to me. The automatic time-based conditions won't work (since you have to re-save the template anyway), but at least there's only one template to update for all campaigns. Thus it scales to any amount of campaigns running at the same time. I agree that having to re-save all campaigns would be a major inconvenience and time sink, but it's not necessary (granted, once again, that the template existed the last time the campaigns were saved).

The issue of having to re-save the template at a specific time remains the only inconvenience, but it's a side-effect of the caching that I think can't be worked around easily. I'm not very familiar with templates, could you show me what rules/syntax are used for the time-based stuff? This way I could investigate how they work and if there's any chance the campaigns could support them better. I'm not very hopeful at this point, though, I think it's quite likely that this limitation is going to be impossible to avoid.

(In reply to Gilles Dubuc from comment #9)

You'll need to re-save the template and the changes should trickle down.

I tried to re-save the template but it did not work after Romaine re-saved each campaign. Probably a campaign should have a definition for starting and ending time to manage it correctly avoiding a trick with templates.

Yes, that sounds like a much better idea. Basically define the start and end date in the campaign settings, and have optional content/template settings to display before, during and after. I'll file it as a task.

romaine.wiki wrote:

Can this bug me solved soon or do we have the do nulledits on all the campaigns at the end of this month and again twice for Wiki Loves Monuments at the begin and end of September? (about 100 campaigns!!)

Since the Multimedia team is now focusing on UploadWizard for at least 2 quarters, we should find time to implement this feature at some point this summer, in time for Wiki Loves Monuments.

romaine.wiki wrote:

I hope the Multimedia team is interested in the ideas of the UploadWizard from the users who use them?

romaine.wiki wrote:

(In reply to Gilles Dubuc from comment #11)

Yes, that sounds like a much better idea. Basically define the start and end
date in the campaign settings, and have optional content/template settings
to display before, during and after. I'll file it as a task.

If that solves the caching of the campaign, it sounds fine to me. I am willing to implement it to all relevant campaigns if it works. Please contact me when it is tested in an example campaign.

Change 153818 had a related patch set uploaded by MarkTraceur:
Add start/end and whileActive to the campaigns

https://gerrit.wikimedia.org/r/153818

I think this patch will just about do the trick.

Change 155351 had a related patch set uploaded by MarkTraceur:
Add beforeActive and afterActive to campaigns

https://gerrit.wikimedia.org/r/155351

Change 153818 merged by jenkins-bot:
Add start/end and whileActive to the campaigns

https://gerrit.wikimedia.org/r/153818

Change 155351 merged by jenkins-bot:
Add beforeActive and afterActive to campaigns

https://gerrit.wikimedia.org/r/155351

Change 156692 had a related patch set uploaded by MarkTraceur:
Add start/end and whileActive to the campaigns

https://gerrit.wikimedia.org/r/156692

Change 156692 merged by jenkins-bot:
Add start/end and whileActive to the campaigns

https://gerrit.wikimedia.org/r/156692

Change 156694 had a related patch set uploaded by MarkTraceur:
Add beforeActive and afterActive to campaigns

https://gerrit.wikimedia.org/r/156694

Change 156694 merged by jenkins-bot:
Add beforeActive and afterActive to campaigns

https://gerrit.wikimedia.org/r/156694

I believe the two patches fix this issue. If there are further caching issues with the campaign contents, let us know and we can reopen. :)

Gilles raised the priority of this task from High to Unbreak Now!.Dec 4 2014, 10:11 AM
Gilles moved this task from Untriaged to Done on the Multimedia board.
Gilles lowered the priority of this task from Unbreak Now! to High.Dec 4 2014, 11:22 AM