Page MenuHomePhabricator

Unable to upload new versions of images with PostgreSQL
Closed, ResolvedPublic

Description

Author: olleg_s

Description:

  • MediaWiki: 1.9.3
    • PHP: 5.2.0-8+etch1 (apache2handler)
    • PostgreSQL: PostgreSQL 8.1.8 on x86_64-pc-linux-gnu, compiled by GCC cc

(GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)

When I try to upload new version of image I get in html:

Warning: pg_query() [functlion.pg-query]: Query failed: ERROR: duplicate key
violates unique constraint "image_pkey" in
/usr/share/mediawiki1.9/includes/DatabasePostgres.php on line 389

Warning: pg_affected_rows(): supplied argument is not a valid PostgreSQL result
resource in /usr/share/mediawiki1.9/includes/DatabasePostgres.php on line 454

And in database log:

2007-03-26 12:32:36 MSD ERROR: duplicate key violates unique constraint
"image_pkey"
2007-03-26 12:32:36 MSD STATEMENT: INSERT /* Image::recordUpload */ INTO image
(img_name,img_size,img_width,img_height,img_bits,img_media_type,img_major_mime,
img_minor_mime,img_timestamp,img_description,img_user,img_user_text,img_metadata
) VALUES ('History1.jpg','128756','1056','1426','8','BITMAP','image','jpeg','200
7-03-26 08:32:36 GMT','','2','Olleg','a:0:{}')


Version: 1.9.x
Severity: normal
Platform: PC

Details

Reference
bz9417

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.
StatusSubtypeAssignedTask
InvalidNone
ResolvedNone

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:40 PM
bzimport set Reference to bz9417.
bzimport added a subscriber: Unknown Object (MLST).

Rather than checking for existence, the software simply tries an insert. If that
fails, it does an update. Looking into an elegant workaround.

olleg_s wrote:

lock table (to avoid concurrent insertion)
try to update if updated 0 then insert
commit

Looks like the DatabasePostgres class is not honoring INSERT IGNORE;
you need to fix that or various other things are going to die as well.

Jdforrester-WMF subscribed.

Migrating from the old tracking task to a tag for PostgreSQL-related tasks.