Skip to content
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

Access current maxlag value of the server #510

Closed
tfrancart opened this issue Jun 25, 2020 · 7 comments · Fixed by #470
Closed

Access current maxlag value of the server #510

tfrancart opened this issue Jun 25, 2020 · 7 comments · Fixed by #470

Comments

@tfrancart
Copy link

A query with -1 as the maxLag value returns the actual server lag without any metadata.
I would find it convenient if the API could provide a simple "ping" call that would return the current server maxLag, so that we are informed how busy the server is. I could not find a way to know this besides receiving an Exception when the call fails due to maximum number of retries reached.

@tfrancart
Copy link
Author

@wetneb
Copy link
Member

wetneb commented Jun 25, 2020

The code for this is in #470, hold my beer

@tfrancart
Copy link
Author

Cool. The throttling parameter the PR contain might very well explain why I am receiving tons of "[failed-save] The save has failed." Exceptions because edits are performed too rapidly. Do I understand correctly Wikibase refuses updates if the lag is too high ?

@tfrancart
Copy link
Author

Argh, just saw you removed that throttling logic thing, I could have used that, too.
What would be your recommendations to avoid [failed-save] Exceptions ? pause before each call ? ask for maxLag before each call and if above a threshold, pause ?

@wetneb
Copy link
Member

wetneb commented Jun 25, 2020

Yes, by default WDTK will send a maxlag=5 parameter in all its editing requests, so that they fail if the lag is above 5 (which is the officially recommended value for this parameter on Wikidata).

If you want your bot to be more aggressive (keep editing even if the lag is high) you can use setMaxLag() on the ApiConnection to change this to a higher value, and your bot will keep running even if the servers are behind.

Concerning the throttling, we lack official guidance from WMDE to implement this properly. https://phabricator.wikimedia.org/T240442

wetneb added a commit that referenced this issue Jun 25, 2020
@tfrancart
Copy link
Author

I am seeing 2 kinds of different behaviors :

  1. Sometimes the API call just hungs, in that case I know it is in a retry loop because maxLag is too high, and if after 14 retries lag is till too high, I get a MaxlagErrorException: [maxlag] Waiting for all: 10.016666666667 seconds lagged.

  2. But sometimes after the bot has made 7 or 8 edits, I get a bunch of [failed-save] The save has failed. Exception directly, without waiting for any retry, and then processing resumes as normal, again for 7 or 8 edits, and then a bunch of Exceptions, etc. Is this second behavior also driven my maxLag ? should I try increasing averageTimePerEdit maybe ?

@wetneb
Copy link
Member

wetneb commented Jun 25, 2020

  1. Yes the lag can stay above 5 for hours and hours…
  2. Perhaps linked to https://phabricator.wikimedia.org/T255804?

Overall, as client you do not have many possibilities: keep retrying.

wetneb added a commit that referenced this issue Jun 26, 2020
* Add method to fetch the current lag from the server.

Closes #510.

* Add missing test resource
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants