"row not found" updating partitioned table in PgSQL

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

"row not found" updating partitioned table in PgSQL

Alex Povolotsky
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?

Alex

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: "row not found" updating partitioned table in PgSQL

Matt S Trout-2
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.

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: "row not found" updating partitioned table in PgSQL

Alex Povolotsky
Thank you for quick and complete answer. I'll do my best investiganting
postgres part of the case and eventually it will work fine)

On 10.11.2016 0:31, Matt S Trout wrote:

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

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...