Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1npj3w-0005Md-Mt for pgsql-admin@arkaria.postgresql.org; Sat, 14 May 2022 04:07:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1npj2v-0002Pv-D8 for pgsql-admin@arkaria.postgresql.org; Sat, 14 May 2022 04:06:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1npj2v-0002Pm-08 for pgsql-admin@lists.postgresql.org; Sat, 14 May 2022 04:06:25 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1npj2o-0006oX-F8 for pgsql-admin@lists.postgresql.org; Sat, 14 May 2022 04:06:24 +0000 Received: by mail-pl1-x62c.google.com with SMTP id x18so9701709plg.6 for ; Fri, 13 May 2022 21:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xzilla-net.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=5894pzUN87mJnjBG/0FPxUOKr4BPiWKlAH3ZTwoNSDA=; b=eEqayT1ywDMdmfDA6G/43wEQcfAHsjurodQ635DsXVINh1xXt2ZTPTDe0ramu76/qU O83LKyQnmme1177w8Ei1rJF/um8wRZLqqYA6850C37ypqYUtXJIiq5Lu3Fropxs0I92B 5CQkZfGpv/rQCAuVrkBcz/CyKb6JRUqkDL1l2fRJftzfkizctXyuDcoyiYIh5b+sIB7H Iok3HKa07LwJf9PnRa6DW6R3uvjK7HtLjULiDACdRtyqaH8DKM4BnRSgKJ7CvkZUt/CB WBp3Tt940PB70CWsVfnQsvTgzvRzoRVcy3a3msSqUFtLrS4fw+nkDcMZrq47ALRdckGC 65aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=5894pzUN87mJnjBG/0FPxUOKr4BPiWKlAH3ZTwoNSDA=; b=wL8w6RRo9QFG5GRwZEhVkM7t5LEvlprg6DaEW3KIzoG1M0LAwNUGqYnqjofWCGV9mN 5UT1SnscKsfZzVEF/j1R018m4gGQFua0V8qAo6X4rwcXvHFW2mQcismn98BSf/DuhrIN /id0P+XOrhNpvf9pvCCKGsVvdvkiWFeuAPEorVadGaZCUCDkgTP2BeGy9Sjm9lHrWiLn fkYwZirhFuvtvPjRrG+YrDwRRCdyIjXheawXwMGzo+Ut8yWthjojSTMXJ8RMiioDLupP 5HIqCae5XAoCB2n9r6doyrc36spVRB4wConrV6LVj/nEwDjmOLX7THZf0Y+C8omzUtma gTag== X-Gm-Message-State: AOAM533P1t6yTwtLlEKyUFn6JO3ckwTtpIVUuwtsYEqPe9iBLI4pLj15 kQtwItfaCi8s6+ESvihyrFY2/L02dqrwlWJG2nW6NASB2lk= X-Google-Smtp-Source: ABdhPJxS5lRtDptT2feRLqMdL2yIPYAOBTJNJLc9Seg/l2f+wlBb1yexkMWc/cAXBBj+2mKjv+4wQshyJ7XMCOYmeRA= X-Received: by 2002:a17:90a:ca89:b0:1d9:7d1a:c337 with SMTP id y9-20020a17090aca8900b001d97d1ac337mr19208496pjt.88.1652501175964; Fri, 13 May 2022 21:06:15 -0700 (PDT) MIME-Version: 1.0 References: <397f5b28-0f5c-de1f-c825-06e2ea7b6a1f@gmail.com> In-Reply-To: From: Robert Treat Date: Sat, 14 May 2022 00:06:05 -0400 Message-ID: Subject: Re: Losing records in PostgreSQL 9.6 To: A G Cc: pgsql-admin@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk If you are asking if it is within the realm of possibility that an old version of Postgres with known bugs running on a presumably old version of Linux which probably also has known bugs that happens to also have some form of hardware failure that could include corrupted memory and/or corrupted storage (did I mention filesystem bugs?) could possibly lose data... well I reckon that probably is possible. However, because the pg_dumps produce what sound like working / proper output, I don't think it'd be any of those things. You didn't mention if you have any ability to look at any of the database statistics tables, which would be a first place to look to see if there are any DML statements or DML activity tracked. Beyond that, if I had access to the server in question (or better an exact physical copy, which might be difficult in your case), I'd want to see if I could find the old rows which might still be on-disk even if not visible due to deletion or transaction semantics, and would also want to rule out things like index corruption that might cause some weird side effects. Robert Treat On Fri, May 13, 2022 at 1:53 PM A G wrote: > > Thanks for your input! > > We checked the application that has access to the database, but it would = never delete rows from that table. The missing rows in the database were st= ored at some point through committed transactions and had a lower sequentia= l primary key. We don't think the transactions were rolled back since they = were part of an older backup. > > We believe that there was probably a manual access through the customer o= r a service partner, but wanted to make sure that there is no other way tha= t Postgres would lose rows during a pg_dump because of something like a har= dware failure, for instance. > > Best regards, > Andreas > > On Sat, May 7, 2022 at 4:03 PM Ron wrote: >> >> On 5/4/22 09:55, A G wrote: >> >> Hi, >> thanks for your help. >> >> My team is using Postgres 9.6.10 for an on-premise application (we are p= laning on upgrading to a newer Postgres version). Our application comes wit= h Postgres running in a docker container with its data stored in a docker v= olume. Our software uses pg_dump / pg_restore to backup and restore the dat= abase. >> >> Now we got a ticket from a customer where their database is missing rows= from a table. There are 971 consecutive rows missing from the beginning of= the table. The missing rows were inserted first. We find it also strange, = that all the other tables don=E2=80=99t seem to be affected at all. It appe= ars that there is only data loss in this single table. >> Unfortunately, we don=E2=80=99t have access to the original database any= more and need to find out what happened through the backups the customer pr= ovides. We have one backup right after they installed and initially configu= red the application, which seems complete. Then there is another backup 10 = months later where the first 971 rows are already missing in this one table= . >> >> If we exclude a manual deletion, which the customer denies, >> >> >> There's more to PEBKAC than manual deletion. >> >> we are wondering if it=E2=80=99s possible that Postgres 9.6 could lose s= ome of its data through a storage or memory error and would create a =E2=80= =9Csuccessful=E2=80=9D pg_dump with only partial data? Is such a behaviour = even thinkable with Postgres? >> >> Do you have an idea what else could cause this issue? >> >> >> Uncommitted transactions? >> * Purge job with a bug in it? >> * Two different date columns (for example "transaction_date" and "posted= _date") which are expected to be the same apparently not always. Since the= errors apparently happen at the beginning of the month, the purge job migh= t have seen them as the previous month's records. >> >> These are our dump and restore commands: >> pg_dump -Fc --no-acl --no-owner -U acme -h 127.0.0.1 acme > acme.dump >> pg_restore -d acme -n public -U acme -h 127.0.0.1 --jobs=3D4 acme.dump >> >> We use just a single db user to access the database and we don=E2=80=99t= use RLS. >> >> Thank you. >> >> Best regards, >> Andreas >> >> >> -- >> Angular momentum makes the world go 'round.