[Dbix-class] "row not found" updating partitioned table in PgSQL

Matt S Trout mst at shadowcat.co.uk
Wed Nov 9 21:31:25 GMT 2016


On Wed, Nov 09, 2016 at 11:50:32PM +0300, Alex Povolotsky wrote:
> Hello
> 
> I do see everyone busy resolving fate of DBIx::Class, but I have a
> problem right here and now.
> 
> I have a table, in Postgres, partitioned with all required triggers.
> 
> When I update a row, posrgres returns "UPDATE 0". I'm not sure if
> it's a bug or a feature, but DBIx::Class becomes VERY upset on it,
> writing tons of lines like
> 
> Mojo::Reactor::EV: I/O watcher failed: DBIx::Class::Row::update():
> Can't update Schema::Result::InstaImages1=HASH(0x197e690): row not
> found at imageloader-ev-new line 107
> 
> Can I somehow turn off this warning?

It's actually an exception, not a warning - because it normally means
something like "the row you're trying to UPDATE has been DELETEd under you"
which is normally really not a good thing. So, *generally*, feature. But
obviously not for you right now.

However, the row count is the return value of $storage->update, so what
you could do is something like

  package My::Storage {
    use mro 'c3';
    use base qw(DBIx::Class::Storage::DBI::Pg);
  
    sub update {
      my $self = shift;
      my ($source) = @_;
      my $ret = $self->next::method(@_);
      return 1 if $source->name eq 'partitioned_table';
      return $ret;
    }
  }

and then in your Schema class

  __PACKAGE__->storage_type('My::Storage');

and that way you're only disabling the sanity check for the specific table.

Or you could always patch DBIx::Class to provide a flag to disable it, but
when/whether you'd be able to get such a patch upstream is obviously not
something that's entirely predictable at this point.

-- 
Matt S Trout - Shadowcat Systems - Perl consulting with a commit bit and a clue

http://shadowcat.co.uk/blog/matt-s-trout/   http://twitter.com/shadowcat_mst/

Email me now on mst (at) shadowcat.co.uk and let's chat about how our CPAN
commercial support, training and consultancy packages could help your team.



More information about the DBIx-Class mailing list