Page MenuHomePhabricator

DB error trying to set block option in abusefilter
Closed, ResolvedPublic

Description

Trying to se up "block" option for abusefilters at it.wiki mediawiki shows:

A database query error has occurred. This may indicate a bug in the software.
Function: AbuseFilterViewEdit::show
Error: 1062 Duplicate entry '344-disallow' for key 'PRIMARY' (10.64.16.7)

Also, I successfully removed the option from a filter but I'm not able to add it again.

Event Timeline

Vituzzu created this task.Jun 3 2016, 10:18 AM
Restricted Application added subscribers: Zppix, Aklapper. · View Herald TranscriptJun 3 2016, 10:18 AM
Vituzzu triaged this task as High priority.Jun 3 2016, 10:19 AM

Reproduced on fr.wikipedia:

Fonction : AbuseFilterViewEdit::show + Erreur : 1062 Duplicate entry '277-warn' for key 'PRIMARY' (10.64.16.145)

So it happens with all options. Dunno if it's related but now I see "warn" sub-options even if warn is not choosen.

matmarex added a subscriber: Tgr.Jun 3 2016, 2:25 PM

There was a non-trivial change by @Tgr this week:

e71808f4c4deca416ecd39160d12f2584bfb9d65 Add extension.json, empty php entry point

It caused some issues with WMF configuration (T136644). I think this might be more fallout from that.

I queried logstash for 'AbuseFilterViewEdit' and I see stuff like: (V1F5OApAEFIAAAJQChoAAADF)

Query: INSERT  INTO `abuse_filter_action` (afa_filter,afa_consequence,afa_parameters) VALUES ('268','disallow',''),('268','disallow','')
Function: AbuseFilterViewEdit::show
Error: 1062 Duplicate entry '268-disallow' for key 'PRIMARY' (10.64.16.7)

So yeah, these are quite obviously duplicate entries we're trying to insert.


The code:

			// Actions
			global $wgAbuseFilterAvailableActions;
			$deadActions = array();
			$actionsRows = array();
			foreach ( $wgAbuseFilterAvailableActions as $action ) {
				// Check if it's set
				$enabled = isset( $actions[$action] ) && (bool)$actions[$action];

				if ( $enabled ) {
					$parameters = $actions[$action]['parameters'];

					$thisRow = array(
						'afa_filter' => $new_id,
						'afa_consequence' => $action,
						'afa_parameters' => implode( "\n", $parameters )
					);
					$actionsRows[] = $thisRow;
				} else {
					$deadActions[] = $action;
				}
			}

...

			$dbw->insert( 'abuse_filter_action', $actionsRows, __METHOD__ );

This doesn't do any de-duplication, so if $wgAbuseFilterAvailableActions contains duplicate entries, this will try to insert duplicate rows and cause this error. I think that the fix/workaround for T136644 (6dc19cee21a3fd4153744b253c38d5f8c10cc5a1) might be causing this.

Tgr added a comment.Jun 3 2016, 2:45 PM

Probably the extension registry merges in the defaults one more time.

0x010C added a subscriber: 0x010C.Jun 3 2016, 2:55 PM

The same as Vituzzu, on frwiki I see now all the sub-options even if the option is not checked. Furthermore, It seems that all the options are repeated twice (see attachment).

Change 292566 had a related patch set uploaded (by Gergő Tisza):
Revert extension registration and following changes

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

Change 292567 had a related patch set uploaded (by Gergő Tisza):
Revert extension registration and following changes

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

Change 292566 merged by jenkins-bot:
Revert extension registration and following changes

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

Change 292567 merged by jenkins-bot:
Revert extension registration and following changes

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

Paladox added a subscriber: Paladox.Jun 3 2016, 3:13 PM

Change 292572 had a related patch set uploaded (by Gergő Tisza):
Revert "Workaround for T136644"

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

Change 292572 merged by jenkins-bot:
Revert "Workaround for T136644"

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

Mentioned in SAL [2016-06-03T15:24:07Z] <tgr@tin> Started scap: revert AbuseFilter + config to pre-extension-registration state T136929

Mentioned in SAL [2016-06-03T15:30:20Z] <tgr@tin> Finished scap: revert AbuseFilter + config to pre-extension-registration state T136929 (duration: 06m 13s)

Tgr added a comment.Jun 3 2016, 3:31 PM

Can you verify it's fixed?

0x010C added a comment.Jun 3 2016, 3:33 PM

@Tgr That's fine on frwiki now, thanks!

Tgr closed this task as Resolved.Jun 3 2016, 3:34 PM
Tgr claimed this task.

Cool. Sorry for the inconvenience!