Thread: heap_mark4update: (am)invalid tid

heap_mark4update: (am)invalid tid

From
"Robert Creager"
Date:
Hey folks,

I found reference to this problem at
http://archives.postgresql.org/pgsql-general/2003-02/msg00135.php,
but there was no apparent resolution.

Postgres is from Mandrake 9.1 install, running on an Athlon SMP with
2.4.21.  Version select is:
PostgreSQL 7.3.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC)
3.2.2 (Mandrake Linux 9.1 3.2.2-3mdk)

The data is filled in from other tables, through a perl script which
runs DBD::Pg.  I can dump the data if desirable.  Currently, the
steps leading up the failure are not being committed.

I'd be happy to ditch the RPM and recompile from source, and can use
gdb with some direction as to find what is desired.

The error occurs on the following update:

UPDATE obs_v
SET mag = obs_v.imag + zp.zero_v + cg.color_v * (obs_v.imag -
i.imag),
    use = true
FROM color_group AS cg, zero_pair AS zp, obs_i AS i, files AS f
WHERE  obs_v.star_id = i.star_id
   AND obs_v.file_id = f.file_id
   AND cg.group_id = f.group_id
   AND f.group_id = $group_id
   AND zp.pair_id = f.pair_id;

$group_id happens to be 1 in this instance.

tables are as follows:

                        Table "public.obs_v"
 Column  |  Type   |                   Modifiers
---------+---------+------------------------------------------------
 x       | real    | not null
 y       | real    | not null
 imag    | real    | not null
 smag    | real    | not null
 ra      | real    | not null
 dec     | real    | not null
 obs_id  | integer | not null default nextval('"obs_id_seq"'::text)
 file_id | integer | not null
 use     | boolean | default false
 solve   | boolean | default false
 star_id | integer |
 mag     | real    |
Indexes: obs_v_file_id_index btree (file_id),
         obs_v_loc_index btree (ra, "dec"),
         obs_v_obs_id_index btree (obs_id),
         obs_v_star_id_index btree (star_id)
Foreign Key constraints: obs_v_files_constraint FOREIGN KEY (file_id)



REFERENCES files(file_id) ON UPDATE NO ACTION ON DELETE CASCADE
Triggers: obs_v_trig

   Table "public.zero_pair"
 Column  |  Type   | Modifiers
---------+---------+-----------
 pair_id | integer | not null
 zero_u  | real    | default 0
 zero_b  | real    | default 0
 zero_v  | real    | default 0
 zero_r  | real    | default 0
 zero_i  | real    | default 0
Indexes: zero_pair_pkey primary key btree (pair_id)
Foreign Key constraints: $1 FOREIGN KEY (pair_id) REFERENCES
files(file_id) ON UPDATE NO ACTION ON DELETE CASCADE

   Table "public.color_group"
  Column  |  Type   | Modifiers
----------+---------+-----------
 group_id | integer | not null
 color_u  | real    | default 0
 color_b  | real    | default 0
 color_v  | real    | default 0
 color_r  | real    | default 0
 color_i  | real    | default 0
Indexes: color_group_pkey primary key btree (group_id)
Foreign Key constraints: $1 FOREIGN KEY (group_id) REFERENCES
files(file_id) ON UPDATE NO ACTION ON DELETE CASCADE

                                     Table "public.files"
  Column  |           Type           |
Modifiers
----------+--------------------------+--------------------------------



------------------------
 file_id  | integer                  | not null default
nextval('"files_file_id_seq"'::text)
 group_id | integer                  | not null default
nextval('"files_group_id_seq"'::text)
 pair_id  | integer                  | not null default
nextval('"files_pair_id_seq"'::text)
 date     | timestamp with time zone | not null
 name     | character varying        | not null
 ra_min   | real                     | default 0
 ra_max   | real                     | default 0
 dec_min  | real                     | default 0
 dec_max  | real                     | default 0
Indexes: files_pkey primary key btree (file_id)

Re: heap_mark4update: (am)invalid tid

From
Tom Lane
Date:
"Robert Creager" <pgsql-bugs@logicalchaos.org> writes:
> I found reference to this problem at
> http://archives.postgresql.org/pgsql-general/2003-02/msg00135.php,
> but there was no apparent resolution.

If (a) obs_v_trigger is a BEFORE trigger, *and* (b) the problem UPDATE
could try to update a row of obs_v more than once (ie, there are
multiple rows in obs_i/files that match a row in obs_v), then I think
this is a known problem.  Otherwise, we need to dig more ...

            regards, tom lane

Re: heap_mark4update: (am)invalid tid

From
"Robert Creager"
Date:
From:               Tom Lane <tgl@sss.pgh.pa.us>
> "Robert Creager" <pgsql-bugs@logicalchaos.org> writes:
> > I found reference to this problem at
> > http://archives.postgresql.org/pgsql-general/2003-02/msg00135.php,
> > but there was no apparent resolution.
>
> If (a) obs_v_trigger is a BEFORE trigger, *and* (b) the problem UPDATE
> could try to update a row of obs_v more than once (ie, there are
> multiple rows in obs_i/files that match a row in obs_v), then I think
> this is a known problem.  Otherwise, we need to dig more ...
>
>    regards, tom lane

Yes, and yes.  Any work arounds (ie current sources, smarter SQL),
other than to break this up into multiple updates?

Thanks,
Rob

Re: heap_mark4update: (am)invalid tid

From
Tom Lane
Date:
"Robert Creager" <pgsql-bugs@logicalchaos.org> writes:
>> If (a) obs_v_trigger is a BEFORE trigger, *and* (b) the problem UPDATE
>> could try to update a row of obs_v more than once (ie, there are
>> multiple rows in obs_i/files that match a row in obs_v), then I think
>> this is a known problem.  Otherwise, we need to dig more ...

> Yes, and yes.  Any work arounds (ie current sources, smarter SQL),
> other than to break this up into multiple updates?

The fix is in CVS.  I've been pestering Marc to wrap up a snapshot
tarball of REL7_3_STABLE branch tip, but he hasn't got round to it.
So probably the easiest answer for you is to check out the branch
from our anonymous-CVS server --- see basic instructions at
http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/cvs.html
but note the initial checkout command should be
    cvs ... co -P -r REL7_3_STABLE pgsql
to get the stable branch rather than development tip.  Note you will
need a fairly current version of bison to build from source.

            regards, tom lane

Re: heap_mark4update: (am)invalid tid

From
"Robert Creager"
Date:
From:               Tom Lane <tgl@sss.pgh.pa.us>
> The fix is in CVS.

Sure is.  It works fine now.  Thanks Tom.

Cheers,
Rob