Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sK1ni-007xJe-TG for pgsql-general@arkaria.postgresql.org; Wed, 19 Jun 2024 20:21:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sK1nf-006Pp3-Bw for pgsql-general@arkaria.postgresql.org; Wed, 19 Jun 2024 20:21:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sK1nf-006Pou-0p for pgsql-general@lists.postgresql.org; Wed, 19 Jun 2024 20:20:59 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sK1nd-002Wr2-Ik for pgsql-general@postgresql.org; Wed, 19 Jun 2024 20:20:59 +0000 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-57c75464e77so126229a12.0 for ; Wed, 19 Jun 2024 13:20:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718828456; x=1719433256; darn=postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=pJ9PWWqWXwrjpZUA3+KNdA0QJJechJ5Tc3hPRiKAbcc=; b=VvXJWRm7elcs8z8kwjlxG7yXWZritFlCvZtoYMM0BzVwuNK88eEG/fPc/RQTH8pgRT oQWZaTOv8yS+G73xhuYcmDPb+ctjrq0FA7tFogu4tCMK4DPFdlgg+GNWOP2ds1BVk1Sb bM87lRITSh3AVMO0QnYDlpKae+Bc5wvZISEfIFwc9PP6DmeML/9Qpv/SdW+zfPXYg63A 625PZVV2Tn30EAFcTwxYOZ5B3Ju/NO69FB7NqnfakDiEmXMr7L0ivV6ViVAX+iXU7i30 wY8ZJaGhI+d1KphHfR/WtI8Tq7pdJH4lmtCeCmA0ksx9WLFdMHuAT95hu7w6AjWcZ340 dIYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718828456; x=1719433256; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pJ9PWWqWXwrjpZUA3+KNdA0QJJechJ5Tc3hPRiKAbcc=; b=rezOhcSUxYe+9NlzKNcwhe0arADX4V/P1hQbetirN3CzxcziZZaGoUttr1yAcNaHjF ieCraZWKgaM+sk89rgcDD0cLZuHHUjzfNdWSOcUID/kWdid61moKi3+CC1oM3wOXNiUN LvRoIxOzw3ypns4KbI8RKgD9LpQswA/FzZ2j9XCvCMZvJ/Ls/mY9EjEdkH3i0voPQ7NQ Nh6kXohDhxz/J7wWGm3ZYoSKcqsPEwbafxqrwrhQfeCSoE6jg2LIeB6dXhwtoMdUHfcF hb0fUTMT1lDgSyVFYkdrLGwTvm5JGz90elX60BXzm0a54cMTNakm+w2ZOmsr+E4GJav1 rk7Q== X-Gm-Message-State: AOJu0YxM6OHS/9fU80qL4gWg1XpAEUNP+8yGF2xnWZ/duiJA9kESLPc8 LjwtlVbR10hgR7lSs5YSFw7ua5kF4nLSXX7rM+byxuQsPwrXtIJz X-Google-Smtp-Source: AGHT+IEE9gFsgzBEf5RfjSHXPkgl8GUcUmF5vNpzC4trFI5NrEV73gPel/MhCPuK8loPxhjMGvMKdg== X-Received: by 2002:a50:930e:0:b0:579:c3f8:591c with SMTP id 4fb4d7f45d1cf-57d07e5f0f9mr2595273a12.18.1718828456101; Wed, 19 Jun 2024 13:20:56 -0700 (PDT) Received: from smtpclient.apple ([188.212.112.125]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57cb722dad1sm8750006a12.0.2024.06.19.13.20.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2024 13:20:55 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: Transaction issue From: Alban Hertroys In-Reply-To: Date: Wed, 19 Jun 2024 22:20:45 +0200 Cc: PostgreSQL General Content-Transfer-Encoding: quoted-printable Message-Id: <65F95FD4-CBEA-4E66-AE63-EBC9F617C988@gmail.com> References: To: Rich Shepard X-Mailer: Apple Mail (2.3774.600.62) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 19 Jun 2024, at 19:56, Rich Shepard = wrote: >=20 > I now insert rows using a transaction. Sometimes psql halts with an = error: > ERROR: current transaction is aborted, commands ignored until end of = transaction block The error prior to those statements is what you need to look at. = That=E2=80=99s what=E2=80=99s causing the transaction to fail. > I issue a rollback; command but cannot continue processing. What is = the > appropriate way to respond to that error after fixing the syntax = error? I get the impression that you=E2=80=99re executing shell scripts that = run the psql command-line utility. That=E2=80=99s a great way to execute = known-to-be-good sequences of SQL statements, but in case of errors it = can be difficult to debug (although PostgreSQL is quite concise about = it=E2=80=99s errors). If a rollback isn=E2=80=99t done from the same psql session, then = you=E2=80=99re performing it from a different transaction - a different = session even. It won=E2=80=99t affect the failed transaction from the = original session, which would have rolled back automatically when that = session closed. Instead, I=E2=80=99d suggest to run those statements from within psql, = using \i to import your SQL file. Comment out any COMMIT statements in = the SQL, add (named) SAVEPOINTs where you=E2=80=99re unsure of the = results so that you can roll back to those specific points in the = transaction, so that you can figure out where the problem originates. Alternatively, it may help to split your SQL file into chunks that you = can run in sequence. Unfortunately, there=E2=80=99s no mode in psql that = allows you to import an SQL file and step through the statements one by = one. That would be helpful in your case I think. But maybe someone on = the list has ideas about that? Regards, Alban Hertroys -- If you can't see the forest for the trees, cut the trees and you'll find there is no forest.