-
Notifications
You must be signed in to change notification settings - Fork 17
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
Evaluate whether userlist-thread lock is working #32
Comments
Krinkle
changed the title
Evaluate whether userlist-thread lock is needed
Evaluate whether userlist-thread lock is working
Oct 15, 2017
Krinkle
added a commit
that referenced
this issue
Oct 16, 2017
* Remove locking and static state from userlist fetchers. * Instead of using static members to pass data to the thread, use parameters instead (ParameterizedThreadStart). * Remove the db locking. This was mostly a remnant from when the AddGroupToList method still used its own dedicated database connection (before baef0f3). However now that it uses its uses the main connection, we no longer need a lock around the whole batch (if anything, we very much don't want to have such a long-held lock). Instead, just let the for loop call addUserToList() for individual items as it does already which already ensures a lock on each individual update/insert. * Get rid of the early returns that (tried to) prevent starting multiple userlist fetchers at the same time. * Re-use local Thread variable in batchGetAll. * Make the while-true loop sleep for 1ms instead of 0ms. * Fix broken AddGroupToList() method: - Fix url to use HTTPS. Not sure whether it followed redirects. - Use the MediaWiki API instead of scraping Special:Listusers. This was broken in at least three ways: - On en.wikipedia.org, the legend also contains a <ul>, so we're not going through the correct list. - Pattern wasn't matching because it assumed <a> to have only "href" and "title" attributes, whereas class="mw-userlink" is now set as well. - Bot was adding entries like "<bdi>Krinkle</bdi>" to the database, because at some point in the last year, user names in HTML output started to be wrapped by <bdi>. Fixes #32.
Krinkle
added a commit
that referenced
this issue
Oct 16, 2017
* Remove locking and static state from userlist fetchers. * Instead of using static members to pass data to the thread, use parameters instead (ParameterizedThreadStart). * Remove the db locking. This was mostly a remnant from when the AddGroupToList method still used its own dedicated database connection (before baef0f3). However now that it uses its uses the main connection, we no longer need a lock around the whole batch (if anything, we very much don't want to have such a long-held lock). Instead, just let the for loop call addUserToList() for individual items as it does already which already ensures a lock on each individual update/insert. * Get rid of the early returns that (tried to) prevent starting multiple userlist fetchers at the same time. * Re-use local Thread variable in batchGetAll. * Make the while-true loop sleep for 1ms instead of 0ms. * Fix broken AddGroupToList() method: - Fix url to use HTTPS. Not sure whether it followed redirects. - Use the MediaWiki API instead of scraping Special:Listusers. This was broken in at least three ways: - On en.wikipedia.org, the legend also contains a <ul>, so we're not going through the correct list. - Pattern wasn't matching because it assumed <a> to have only "href" and "title" attributes, whereas class="mw-userlink" is now set as well. - Bot was adding entries like "<bdi>Krinkle</bdi>" to the database, because at some point in the last year, user names in HTML output started to be wrapped by <bdi>. Fixes #32.
Krinkle
added a commit
that referenced
this issue
Oct 16, 2017
* Remove locking and static state from userlist fetchers. * Instead of using static members to pass data to the thread, use parameters instead (ParameterizedThreadStart). * Remove the db locking. This was mostly a remnant from when the AddGroupToList method still used its own dedicated database connection (before baef0f3). However now that it uses its uses the main connection, we no longer need a lock around the whole batch (if anything, we very much don't want to have such a long-held lock). Instead, just let the for loop call addUserToList() for individual items as it does already which already ensures a lock on each individual update/insert. * Get rid of the early returns that (tried to) prevent starting multiple userlist fetchers at the same time. * Re-use local Thread variable in batchGetAll. * Make the while-true loop sleep for 1ms instead of 0ms. * Fix broken AddGroupToList() method: - Fix url to use HTTPS. Not sure whether it followed redirects. - Use the MediaWiki API instead of scraping Special:Listusers. This was broken in at least three ways: - On en.wikipedia.org, the legend also contains a <ul>, so we're not going through the correct list. - Pattern wasn't matching because it assumed <a> to have only "href" and "title" attributes, whereas class="mw-userlink" is now set as well. - Bot was adding entries like "<bdi>Krinkle</bdi>" to the database, because at some point in the last year, user names in HTML output started to be wrapped by <bdi>. Fixes #32.
Krinkle
added a commit
that referenced
this issue
Oct 16, 2017
* Remove locking and static state from userlist fetchers. * Instead of using static members to pass data to the thread, use parameters instead (ParameterizedThreadStart). * Remove the db locking. This was mostly a remnant from when the AddGroupToList method still used its own dedicated database connection (before baef0f3). However now that it uses its uses the main connection, we no longer need a lock around the whole batch (if anything, we very much don't want to have such a long-held lock). Instead, just let the for loop call addUserToList() for individual items as it does already which already ensures a lock on each individual update/insert. * Get rid of the early returns that (tried to) prevent starting multiple userlist fetchers at the same time. * Re-use local Thread variable in batchGetAll. * Make the while-true loop sleep for 1ms instead of 0ms. * Fix broken AddGroupToList() method: - Fix url to use HTTPS. Not sure whether it followed redirects. - Use the MediaWiki API instead of scraping Special:Listusers. This was broken in at least three ways: - On en.wikipedia.org, the legend also contains a <ul>, so we're not going through the correct list. - Pattern wasn't matching because it assumed <a> to have only "href" and "title" attributes, whereas class="mw-userlink" is now set as well. - Bot was adding entries like "<bdi>Krinkle</bdi>" to the database, because at some point in the last year, user names in HTML output started to be wrapped by <bdi>. Fixes #32.
Krinkle
added a commit
that referenced
this issue
Oct 17, 2017
* Remove locking and static state from userlist fetchers. * Instead of using static members to pass data to the thread, use parameters instead (ParameterizedThreadStart). * Remove the db locking. This was mostly a remnant from when the AddGroupToList method still used its own dedicated database connection (before baef0f3). However now that it uses its uses the main connection, we no longer need a lock around the whole batch (if anything, we very much don't want to have such a long-held lock). Instead, just let the for loop call addUserToList() for individual items as it does already which already ensures a lock on each individual update/insert. * Get rid of the early returns that (tried to) prevent starting multiple userlist fetchers at the same time. * Re-use local Thread variable in batchGetAll. * Make the while-true loop sleep for 1ms instead of 0ms. * Fix broken AddGroupToList() method: - Fix url to use HTTPS. Not sure whether it followed redirects. - Use the MediaWiki API instead of scraping Special:Listusers. This was broken in at least three ways: - On en.wikipedia.org, the legend also contains a <ul>, so we're not going through the correct list. - Pattern wasn't matching because it assumed <a> to have only "href" and "title" attributes, whereas class="mw-userlink" is now set as well. - Bot was adding entries like "<bdi>Krinkle</bdi>" to the database, because at some point in the last year, user names in HTML output started to be wrapped by <bdi>. Fixes #32.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gendarme provides various warnings for the following type of issue:
I'm not entirely convinced this logic is actually working. At least in case of
BatchGetAllAdminsAndBots
it seems like the state is checked, but then it continues regardless.We should see if there's a better way to deal with this.
The text was updated successfully, but these errors were encountered: