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 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.

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.

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

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).

Sans titre.png (1×1 px, 118 KB)

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

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)

Can you verify it's fixed?

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

Tgr claimed this task.

Cool. Sorry for the inconvenience!