=== Applying patches on top of PostgreSQL commit ID 53a49365052026907afff7613929710d1e7f0da0 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Fri Jan 31 20:27:27 UTC 2025 On branch cf/5070 nothing to commit, working tree clean === applying patch ./reissue-cancel-requests.patch Applied patch to 'contrib/postgres_fdw/connection.c' with conflicts. U contrib/postgres_fdw/connection.c diff --cc contrib/postgres_fdw/connection.c index 8a8d3b4481,7a8cac83cb..0000000000 --- a/contrib/postgres_fdw/connection.c +++ b/contrib/postgres_fdw/connection.c @@@ -101,7 -100,7 +101,11 @@@ static uint32 pgfdw_we_get_result = 0 * the race condition where the remote session ignored our cancel request * because it arrived while idle. */ ++<<<<<<< ours +#define RETRY_CANCEL_TIMEOUT 1000 ++======= + #define RE_CANCEL_TIMEOUT 1000 ++>>>>>>> theirs /* Macro for constructing abort command to be sent */ #define CONSTRUCT_ABORT_COMMAND(sql, entry, toplevel) \ @@@ -153,7 -152,7 +157,11 @@@ static void pgfdw_reset_xact_state(Conn static bool pgfdw_cancel_query(PGconn *conn); static bool pgfdw_cancel_query_begin(PGconn *conn, TimestampTz endtime); static bool pgfdw_cancel_query_end(PGconn *conn, TimestampTz endtime, ++<<<<<<< ours + TimestampTz retrycanceltime, ++======= + TimestampTz recanceltime, ++>>>>>>> theirs bool consume_input); static bool pgfdw_exec_cleanup_query(PGconn *conn, const char *query, bool ignore_errors); @@@ -163,7 -162,7 +171,11 @@@ static bool pgfdw_exec_cleanup_query_en bool consume_input, bool ignore_errors); static bool pgfdw_get_cleanup_result(PGconn *conn, TimestampTz endtime, ++<<<<<<< ours + TimestampTz retrycanceltime, ++======= + TimestampTz recanceltime, ++>>>>>>> theirs PGresult **result, bool *timed_out); static void pgfdw_abort_cleanup(ConnCacheEntry *entry, bool toplevel); static bool pgfdw_abort_cleanup_begin(ConnCacheEntry *entry, bool toplevel, @@@ -1395,7 -1333,7 +1407,11 @@@ pgfdw_cancel_query(PGconn *conn { TimestampTz now = GetCurrentTimestamp(); TimestampTz endtime; ++<<<<<<< ours + TimestampTz retrycanceltime; ++======= + TimestampTz recanceltime; ++>>>>>>> theirs /* * If it takes too long to cancel the query and discard the result, assume @@@ -1407,11 -1345,11 +1423,19 @@@ * Also, lose patience and re-issue the cancel request after a little bit. * (This serves to close some race conditions.) */ ++<<<<<<< ours + retrycanceltime = TimestampTzPlusMilliseconds(now, RETRY_CANCEL_TIMEOUT); + + if (!pgfdw_cancel_query_begin(conn, endtime)) + return false; + return pgfdw_cancel_query_end(conn, endtime, retrycanceltime, false); ++======= + recanceltime = TimestampTzPlusMilliseconds(now, RE_CANCEL_TIMEOUT); + + if (!pgfdw_cancel_query_begin(conn, endtime)) + return false; + return pgfdw_cancel_query_end(conn, endtime, recanceltime, false); ++>>>>>>> theirs } /* @@@ -1438,7 -1376,7 +1462,11 @@@ pgfdw_cancel_query_begin(PGconn *conn, static bool pgfdw_cancel_query_end(PGconn *conn, TimestampTz endtime, ++<<<<<<< ours + TimestampTz retrycanceltime, bool consume_input) ++======= + TimestampTz recanceltime, bool consume_input) ++>>>>>>> theirs { PGresult *result; bool timed_out; @@@ -1459,7 -1397,7 +1487,11 @@@ } /* Get and discard the result of the query. */ ++<<<<<<< ours + if (pgfdw_get_cleanup_result(conn, endtime, retrycanceltime, ++======= + if (pgfdw_get_cleanup_result(conn, endtime, recanceltime, ++>>>>>>> theirs &result, &timed_out)) { if (timed_out) @@@ -1579,18 -1517,18 +1611,30 @@@ pgfdw_exec_cleanup_query_end(PGconn *co * This might be a query that is being interrupted by a cancel request or by * transaction abort, or it might be a query that was initiated as part of * transaction abort to get the remote side back to the appropriate state. ++<<<<<<< ours + * + * endtime is the time at which we should give up and assume the remote side + * is dead. retrycanceltime is the time at which we should issue a fresh + * cancel request (pass the same value as endtime if this is not wanted). + * ++======= + * + * endtime is the time at which we should give up and assume the remote + * side is dead. recanceltime is the time at which we should issue a fresh + * cancel request (pass the same value as endtime if this is not wanted). + * ++>>>>>>> theirs * Returns true if the timeout expired or connection trouble occurred, * false otherwise. Sets *result except in case of a true result. * Sets *timed_out to true only when the timeout expired. */ static bool pgfdw_get_cleanup_result(PGconn *conn, TimestampTz endtime, ++<<<<<<< ours + TimestampTz retrycanceltime, ++======= + TimestampTz recanceltime, ++>>>>>>> theirs PGresult **result, bool *timed_out) { @@@ -1603,7 -1541,7 +1647,11 @@@ /* In what follows, do not leak any PGresults on an error. */ PG_TRY(); { ++<<<<<<< ours + int canceldelta = RETRY_CANCEL_TIMEOUT * 2; ++======= + int canceldelta = RE_CANCEL_TIMEOUT * 2; ++>>>>>>> theirs for (;;) { @@@ -1624,7 -1562,7 +1672,11 @@@ } /* If we need to re-issue the cancel request, do that. */ ++<<<<<<< ours + if (now >= retrycanceltime) ++======= + if (now >= recanceltime) ++>>>>>>> theirs { /* We ignore failure to issue the repeated request. */ (void) libpqsrv_cancel(conn, endtime); @@@ -1633,15 -1571,15 +1685,24 @@@ now = GetCurrentTimestamp(); /* Adjust re-cancel timeout in increasing steps. */ ++<<<<<<< ours + retrycanceltime = TimestampTzPlusMilliseconds(now, + canceldelta); ++======= + recanceltime = TimestampTzPlusMilliseconds(now, + canceldelta); ++>>>>>>> theirs canceldelta += canceldelta; } /* If timeout has expired, give up, else get sleep time. */ cur_timeout = TimestampDifferenceMilliseconds(now, Min(endtime, ++<<<<<<< ours + retrycanceltime)); ++======= + recanceltime)); ++>>>>>>> theirs if (cur_timeout <= 0) { *timed_out = true; @@@ -1964,7 -1902,7 +2025,11 @@@ pgfdw_finish_abort_cleanup(List *pendin ConnCacheEntry *entry = (ConnCacheEntry *) lfirst(lc); TimestampTz now = GetCurrentTimestamp(); TimestampTz endtime; ++<<<<<<< ours + TimestampTz retrycanceltime; ++======= + TimestampTz recanceltime; ++>>>>>>> theirs char sql[100]; Assert(entry->changing_xact_state); @@@ -1980,11 -1918,11 +2045,19 @@@ */ endtime = TimestampTzPlusMilliseconds(now, CONNECTION_CLEANUP_TIMEOUT); ++<<<<<<< ours + retrycanceltime = TimestampTzPlusMilliseconds(now, + RETRY_CANCEL_TIMEOUT); + + if (!pgfdw_cancel_query_end(entry->conn, endtime, + retrycanceltime, true)) ++======= + recanceltime = TimestampTzPlusMilliseconds(now, + RE_CANCEL_TIMEOUT); + + if (!pgfdw_cancel_query_end(entry->conn, endtime, + recanceltime, true)) ++>>>>>>> theirs { /* Unable to cancel running query */ pgfdw_reset_xact_state(entry, toplevel);