]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Don't hint that you can reconnect when the database is dropped
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 3 Feb 2026 13:08:16 +0000 (15:08 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 3 Feb 2026 13:08:16 +0000 (15:08 +0200)
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/4cc13ba1-4248-4884-b6ba-4805349e7f39@iki.fi

src/backend/tcop/postgres.c

index d01d7a0898c18ad06d0957e375ec1b63902246d6..02e9aaa6bca7f069ab42c34c557ca4bf7334c2d1 100644 (file)
@@ -3209,27 +3209,29 @@ ProcessRecoveryConflictInterrupt(ProcSignalReason reason)
                                }
                        }
 
-                       /* Intentional fall through to session cancel */
-                       /* FALLTHROUGH */
-
-               case PROCSIG_RECOVERY_CONFLICT_DATABASE:
-
                        /*
-                        * Retrying is not possible because the database is dropped, or we
-                        * decided above that we couldn't resolve the conflict with an
-                        * ERROR and fell through.  Terminate the session.
+                        * We couldn't resolve the conflict with ERROR, so terminate the
+                        * whole session.
                         */
                        pgstat_report_recovery_conflict(reason);
                        ereport(FATAL,
-                                       (errcode(reason == PROCSIG_RECOVERY_CONFLICT_DATABASE ?
-                                                        ERRCODE_DATABASE_DROPPED :
-                                                        ERRCODE_T_R_SERIALIZATION_FAILURE),
+                                       (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
                                         errmsg("terminating connection due to conflict with recovery"),
                                         errdetail_recovery_conflict(reason),
                                         errhint("In a moment you should be able to reconnect to the"
                                                         " database and repeat your command.")));
                        break;
 
+               case PROCSIG_RECOVERY_CONFLICT_DATABASE:
+
+                       /* The database is being dropped; terminate the session */
+                       pgstat_report_recovery_conflict(reason);
+                       ereport(FATAL,
+                                       (errcode(ERRCODE_DATABASE_DROPPED),
+                                        errmsg("terminating connection due to conflict with recovery"),
+                                        errdetail_recovery_conflict(reason)));
+                       break;
+
                default:
                        elog(FATAL, "unrecognized conflict mode: %d", (int) reason);
        }