pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #8553: CRITICAL - delete from doesn't delete rows, select returns them anyway
5+ messages / 3 participants
[nested] [flat]

* BUG #8553: CRITICAL - delete from doesn't delete rows, select returns them anyway
@ 2013-10-25 02:37  vadim@mvscusa.com
  0 siblings, 1 reply; 5+ messages in thread

From: vadim@mvscusa.com @ 2013-10-25 02:37 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      8553
Logged by:          Vadim Yevsyukov
Email address:      vadim@mvscusa.com
PostgreSQL version: 9.3.1
Operating system:   CentOS 6.4
Description:        

After upgrading to PostgreSQL 9.3.1.


Schema:


create sequence JobSeq start 1;
create table Job
(
	jobId int not null default nextval('JobSeq'),
	name varchar(50) not null,
	className varchar(50) not null,
	timeoutSeconds int null,
	enabled boolean not null,
	nextRun timestamp null,
	running boolean not null,
	dayMask int null,
	timeOfDaySeconds int null,
	dayOfMonth int null,
	nextRunForce boolean not null,
	constraint PK_Job primary key (jobId)
);


I noticed a weird exceptions in my billing system that's processing
payments. After some research, I found that my internal job scheduler's
table in PostgreSQL has two records for 'Payment Processor' job (jobId = 2),
which should not be possible, since jobId is the primary key.


I tried to delete records: delete from Job where jobId = 2; But instead of
reporting '2 records affected', PostgreSQL has reported 'one record
affected'. I ran 'select from Job where jobId = 2' and it returned no rows,
however when I ran query without 'where' clause 'select * from Job' - it did
returned two records with jobId = 2.


Query 'select count(*) from Job where jobId = 2' also reporting 0, despite
two records returned in 'select * from Job'.


Does look like a CRITICAL bug to me. Let me know please if additional
information is needed.


Thank you,
Vadim



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #8553: CRITICAL - delete from doesn't delete rows, select returns them anyway
@ 2013-10-25 14:14  Pavel Stehule <pavel.stehule@gmail.com>
  parent: vadim@mvscusa.com
  0 siblings, 2 replies; 5+ messages in thread

From: Pavel Stehule @ 2013-10-25 14:14 UTC (permalink / raw)
  To: vadim@mvscusa.com; +Cc: pgsql-bugs

It looks like broken index. I dont know what is reason of this error, but
REINDEX should helps.
Dne 25.10.2013 16:03 <vadim@mvscusa.com> napsal(a):

> The following bug has been logged on the website:
>
> Bug reference:      8553
> Logged by:          Vadim Yevsyukov
> Email address:      vadim@mvscusa.com
> PostgreSQL version: 9.3.1
> Operating system:   CentOS 6.4
> Description:
>
> After upgrading to PostgreSQL 9.3.1.
>
>
> Schema:
>
>
> create sequence JobSeq start 1;
> create table Job
> (
>         jobId int not null default nextval('JobSeq'),
>         name varchar(50) not null,
>         className varchar(50) not null,
>         timeoutSeconds int null,
>         enabled boolean not null,
>         nextRun timestamp null,
>         running boolean not null,
>         dayMask int null,
>         timeOfDaySeconds int null,
>         dayOfMonth int null,
>         nextRunForce boolean not null,
>         constraint PK_Job primary key (jobId)
> );
>
>
> I noticed a weird exceptions in my billing system that's processing
> payments. After some research, I found that my internal job scheduler's
> table in PostgreSQL has two records for 'Payment Processor' job (jobId =
> 2),
> which should not be possible, since jobId is the primary key.
>
>
> I tried to delete records: delete from Job where jobId = 2; But instead of
> reporting '2 records affected', PostgreSQL has reported 'one record
> affected'. I ran 'select from Job where jobId = 2' and it returned no rows,
> however when I ran query without 'where' clause 'select * from Job' - it
> did
> returned two records with jobId = 2.
>
>
> Query 'select count(*) from Job where jobId = 2' also reporting 0, despite
> two records returned in 'select * from Job'.
>
>
> Does look like a CRITICAL bug to me. Let me know please if additional
> information is needed.
>
>
> Thank you,
> Vadim
>
>
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #8553: CRITICAL - delete from doesn't delete rows, select returns them anyway
@ 2013-10-25 17:19  Vadim Yevsyukov <vadim@mvscusa.com>
  parent: Pavel Stehule <pavel.stehule@gmail.com>
  1 sibling, 1 reply; 5+ messages in thread

From: Vadim Yevsyukov @ 2013-10-25 17:19 UTC (permalink / raw)
  To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: pgsql-bugs

REINDEX cannot be done. Getting "ERROR:  could not create unique index 
"pk_job" DETAIL:  Key (jobid)=(2) is duplicated". And as I mentioned 
earlier - I cannot delete these rows as well.

Vadim Yevsyukov
Motor Vehicle Software Corporation
http://www.mvscusa.com

On 10/25/2013 7:14 AM, Pavel Stehule wrote:
>
> It looks like broken index. I dont know what is reason of this error, 
> but REINDEX should helps.
>
> Dne 25.10.2013 16:03 <vadim@mvscusa.com <mailto:vadim@mvscusa.com>> 
> napsal(a):
>
>     The following bug has been logged on the website:
>
>     Bug reference:      8553
>     Logged by:          Vadim Yevsyukov
>     Email address: vadim@mvscusa.com <mailto:vadim@mvscusa.com>
>     PostgreSQL version: 9.3.1
>     Operating system:   CentOS 6.4
>     Description:
>
>     After upgrading to PostgreSQL 9.3.1.
>
>
>     Schema:
>
>
>     create sequence JobSeq start 1;
>     create table Job
>     (
>             jobId int not null default nextval('JobSeq'),
>             name varchar(50) not null,
>             className varchar(50) not null,
>             timeoutSeconds int null,
>             enabled boolean not null,
>             nextRun timestamp null,
>             running boolean not null,
>             dayMask int null,
>             timeOfDaySeconds int null,
>             dayOfMonth int null,
>             nextRunForce boolean not null,
>             constraint PK_Job primary key (jobId)
>     );
>
>
>     I noticed a weird exceptions in my billing system that's processing
>     payments. After some research, I found that my internal job
>     scheduler's
>     table in PostgreSQL has two records for 'Payment Processor' job
>     (jobId = 2),
>     which should not be possible, since jobId is the primary key.
>
>
>     I tried to delete records: delete from Job where jobId = 2; But
>     instead of
>     reporting '2 records affected', PostgreSQL has reported 'one record
>     affected'. I ran 'select from Job where jobId = 2' and it returned
>     no rows,
>     however when I ran query without 'where' clause 'select * from
>     Job' - it did
>     returned two records with jobId = 2.
>
>
>     Query 'select count(*) from Job where jobId = 2' also reporting 0,
>     despite
>     two records returned in 'select * from Job'.
>
>
>     Does look like a CRITICAL bug to me. Let me know please if additional
>     information is needed.
>
>
>     Thank you,
>     Vadim
>
>
>
>     --
>     Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org
>     <mailto:pgsql-bugs@postgresql.org>)
>     To make changes to your subscription:
>     http://www.postgresql.org/mailpref/pgsql-bugs
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #8553: CRITICAL - delete from doesn't delete rows, select returns them anyway
@ 2013-10-25 17:25  Vadim Yevsyukov <vadim@mvscusa.com>
  parent: Pavel Stehule <pavel.stehule@gmail.com>
  1 sibling, 0 replies; 5+ messages in thread

From: Vadim Yevsyukov @ 2013-10-25 17:25 UTC (permalink / raw)
  To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: pgsql-bugs

Additional information on the issue - 'Equal' and 'between' operators 
return different results, see below.

 >psql -h pgsqltest -U billing -d billing

billing=# select jobid, name from job where jobid = 2;
  jobid |       name
-------+-------------------
      2 | Payment Processor
(1 row)


billing=# select jobid, name from job where jobid between 2 and 2;
  jobid |       name
-------+-------------------
      2 | Payment Processor
      2 | Payment Processor
      2 | Payment Processor
(3 rows)

Dump file also contains duplicates, see attached file.

 >pg_dump.exe --host pgsqltest ...  --format plain --file 
"job-plain.backup" --table "public.job" "billing"

Vadim Yevsyukov
Motor Vehicle Software Corporation
http://www.mvscusa.com

On 10/25/2013 7:14 AM, Pavel Stehule wrote:
>
> It looks like broken index. I dont know what is reason of this error, 
> but REINDEX should helps.
>
> Dne 25.10.2013 16:03 <vadim@mvscusa.com <mailto:vadim@mvscusa.com>> 
> napsal(a):
>
>     The following bug has been logged on the website:
>
>     Bug reference:      8553
>     Logged by:          Vadim Yevsyukov
>     Email address: vadim@mvscusa.com <mailto:vadim@mvscusa.com>
>     PostgreSQL version: 9.3.1
>     Operating system:   CentOS 6.4
>     Description:
>
>     After upgrading to PostgreSQL 9.3.1.
>
>
>     Schema:
>
>
>     create sequence JobSeq start 1;
>     create table Job
>     (
>             jobId int not null default nextval('JobSeq'),
>             name varchar(50) not null,
>             className varchar(50) not null,
>             timeoutSeconds int null,
>             enabled boolean not null,
>             nextRun timestamp null,
>             running boolean not null,
>             dayMask int null,
>             timeOfDaySeconds int null,
>             dayOfMonth int null,
>             nextRunForce boolean not null,
>             constraint PK_Job primary key (jobId)
>     );
>
>
>     I noticed a weird exceptions in my billing system that's processing
>     payments. After some research, I found that my internal job
>     scheduler's
>     table in PostgreSQL has two records for 'Payment Processor' job
>     (jobId = 2),
>     which should not be possible, since jobId is the primary key.
>
>
>     I tried to delete records: delete from Job where jobId = 2; But
>     instead of
>     reporting '2 records affected', PostgreSQL has reported 'one record
>     affected'. I ran 'select from Job where jobId = 2' and it returned
>     no rows,
>     however when I ran query without 'where' clause 'select * from
>     Job' - it did
>     returned two records with jobId = 2.
>
>
>     Query 'select count(*) from Job where jobId = 2' also reporting 0,
>     despite
>     two records returned in 'select * from Job'.
>
>
>     Does look like a CRITICAL bug to me. Let me know please if additional
>     information is needed.
>
>
>     Thank you,
>     Vadim
>
>
>
>     --
>     Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org
>     <mailto:pgsql-bugs@postgresql.org>)
>     To make changes to your subscription:
>     http://www.postgresql.org/mailpref/pgsql-bugs
>

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

job-plain.backup (text/plain, 3.3K) download -- -- PostgreSQL database dump -- -- Dumped from database version 9.3.1 -- Dumped by pg_dump version 9.3.0 -- Started on 2013-10-25 16:01:16 SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- TOC entry 215 (class 1259 OID 359233) -- Name: job; Type: TABLE; Schema: public; Owner: postgres; Tablespace: -- CREATE TABLE job ( jobid integer DEFAULT nextval('jobseq'::regclass) NOT NULL, name character varying(50) NOT NULL, classname character varying(50) NOT NULL, timeoutseconds integer, enabled boolean NOT NULL, nextrun timestamp without time zone, running boolean NOT NULL, daymask integer, timeofdayseconds integer, dayofmonth integer, nextrunforce boolean NOT NULL ); ALTER TABLE public.job OWNER TO postgres; -- -- TOC entry 3361 (class 0 OID 359233) -- Dependencies: 215 -- Data for Name: job; Type: TABLE DATA; Schema: public; Owner: postgres -- COPY job (jobid, name, classname, timeoutseconds, enabled, nextrun, running, daymask, timeofdayseconds, dayofmonth, nextrunforce) FROM stdin; 20 Ach Upload Checker AchUploadCheckerJob \N f 2012-11-18 13:00:00 f 127 46800 \N f 17 Theft & Lien Report Sender NvsReportSenderJob \N t 2013-10-25 00:00:00 f \N 0 1 f 3 Mail Sender MailSenderJob 60 t 2013-10-24 19:23:30.763 f 127 \N \N f 12 ACH Activity Report Sender AchActivityReportSenderJob \N t 2013-10-25 12:00:00 f 127 43200 \N f 13 Support Ticket Synchronizer SupportTicketSynchronizerJob \N t 2013-10-25 00:00:00 f 127 0 \N f 14 Subscription Controller SubscriptionControllerJob \N t 2013-10-25 01:00:00 f 127 3600 \N f 19 Database Cleanup DatabaseCleanupJob \N t 2013-10-25 00:30:00 f 127 1800 \N f 2 Payment Processor PaymentProcessorJob 300 t 2013-10-16 11:39:12.243 f 127 \N \N f 9 Contract Status Watcher ContractStatusWatcherJob 3600 t 2013-10-24 20:03:46.037 f 127 \N \N f 18 Digital Signature Controller DigiSignControllerJob 3600 t 2013-10-24 20:03:46.08 f 127 \N \N f 16 Arkona GL/Accounting Processor ArkonaAccountingProcessorJob 3600 t 2013-10-24 20:03:46.053 f 127 \N \N f 2 Payment Processor PaymentProcessorJob 300 t 2013-10-16 11:34:12.243 f 127 \N \N f 2 Payment Processor PaymentProcessorJob 300 t 2013-10-16 11:39:12.243 f 127 \N \N f 5 Financial Activity Receiver FinancialActivityReceiverJob 3600 t 2013-10-19 02:03:45.96 f 127 \N \N f 7 Payment Overdue Watcher PaymentOverdueWatcherJob 3600 t 2013-10-19 02:03:46.007 f 127 \N \N f 6 Report Generator ReportGeneratorJob \N t 2013-10-25 06:00:00 f 127 21600 \N f 1 Invoice Generator InvoiceGeneratorJob 300 t 2013-10-16 14:29:12.227 f 127 \N \N f 8 User Status Watcher UserStatusWatcherJob 300 t 2013-10-16 15:14:12.267 f 127 \N \N f 11 ACH Processor AchProcessorJob 300 t 2013-09-27 01:49:12.287 f 127 \N \N f 4 Dashboard Updater DashboardUpdaterJob 3600 t 2013-10-19 02:03:45.947 f 127 \N \N f \. -- -- TOC entry 3251 (class 2606 OID 359238) -- Name: pk_job; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: -- ALTER TABLE ONLY job ADD CONSTRAINT pk_job PRIMARY KEY (jobid); -- Completed on 2013-10-25 16:01:42 -- -- PostgreSQL database dump complete --
^ permalink raw reply [nested|flat] 5+ messages in thread

* Re: BUG #8553: CRITICAL - delete from doesn't delete rows, select returns them anyway
@ 2013-10-25 17:27  Pavel Stehule <pavel.stehule@gmail.com>
  parent: Vadim Yevsyukov <vadim@mvscusa.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Pavel Stehule @ 2013-10-25 17:27 UTC (permalink / raw)
  To: Vadim Yevsyukov <vadim@mvscusa.com>; +Cc: pgsql-bugs

2013/10/25 Vadim Yevsyukov <vadim@mvscusa.com>

>  REINDEX cannot be done. Getting "ERROR:  could not create unique index
> "pk_job" DETAIL:  Key (jobid)=(2) is duplicated". And as I mentioned
> earlier - I cannot delete these rows as well.
>

so it is little bit worse:

a) delete a duplicate rows:

set enable_indexscan to off; -- now indexes will not be used
select jobid from job group by 1 having count(*) > 1; -- print duplicates
delete from job where jobid in (2, ...)

reindex job;

regards

Pavel

p.s. you should to find a reason why indexes are broken - not enough
space, ...

and check all indexes


>
> Vadim Yevsyukov
> Motor Vehicle Software Corporationhttp://www.mvscusa.com
>
> On 10/25/2013 7:14 AM, Pavel Stehule wrote:
>
> It looks like broken index. I dont know what is reason of this error, but
> REINDEX should helps.
> Dne 25.10.2013 16:03 <vadim@mvscusa.com> napsal(a):
>
>> The following bug has been logged on the website:
>>
>> Bug reference:      8553
>> Logged by:          Vadim Yevsyukov
>> Email address:      vadim@mvscusa.com
>> PostgreSQL version: 9.3.1
>> Operating system:   CentOS 6.4
>> Description:
>>
>> After upgrading to PostgreSQL 9.3.1.
>>
>>
>> Schema:
>>
>>
>> create sequence JobSeq start 1;
>> create table Job
>> (
>>         jobId int not null default nextval('JobSeq'),
>>         name varchar(50) not null,
>>         className varchar(50) not null,
>>         timeoutSeconds int null,
>>         enabled boolean not null,
>>         nextRun timestamp null,
>>         running boolean not null,
>>         dayMask int null,
>>         timeOfDaySeconds int null,
>>         dayOfMonth int null,
>>         nextRunForce boolean not null,
>>         constraint PK_Job primary key (jobId)
>> );
>>
>>
>> I noticed a weird exceptions in my billing system that's processing
>> payments. After some research, I found that my internal job scheduler's
>> table in PostgreSQL has two records for 'Payment Processor' job (jobId =
>> 2),
>> which should not be possible, since jobId is the primary key.
>>
>>
>> I tried to delete records: delete from Job where jobId = 2; But instead of
>> reporting '2 records affected', PostgreSQL has reported 'one record
>> affected'. I ran 'select from Job where jobId = 2' and it returned no
>> rows,
>> however when I ran query without 'where' clause 'select * from Job' - it
>> did
>> returned two records with jobId = 2.
>>
>>
>> Query 'select count(*) from Job where jobId = 2' also reporting 0, despite
>> two records returned in 'select * from Job'.
>>
>>
>> Does look like a CRITICAL bug to me. Let me know please if additional
>> information is needed.
>>
>>
>> Thank you,
>> Vadim
>>
>>
>>
>> --
>> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-bugs
>>
>
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2013-10-25 17:27 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-10-25 02:37 BUG #8553: CRITICAL - delete from doesn't delete rows, select returns them anyway vadim@mvscusa.com
2013-10-25 14:14 ` Pavel Stehule <pavel.stehule@gmail.com>
2013-10-25 17:19   ` Vadim Yevsyukov <vadim@mvscusa.com>
2013-10-25 17:27     ` Pavel Stehule <pavel.stehule@gmail.com>
2013-10-25 17:25   ` Vadim Yevsyukov <vadim@mvscusa.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox