Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2b84d2d

Browse files
committed
Set application_name to make shardman deadlock detector happy.
Also port postgres_fdw.use_repeatable_read guc.
1 parent 4c8cda3 commit 2b84d2d

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

contrib/postgres_fdw/connection.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,19 +451,19 @@ static void
451451
begin_remote_xact(ConnCacheEntry *entry)
452452
{
453453
int curlevel = GetCurrentTransactionNestLevel();
454+
char sql[128];
455+
454456

455457
/* Start main transaction if we haven't yet */
456458
if (entry->xact_depth <= 0)
457459
{
458-
const char *sql;
459-
460460
elog(DEBUG3, "starting remote transaction on connection %p",
461461
entry->conn);
462462

463-
if (IsolationIsSerializable())
464-
sql = "START TRANSACTION ISOLATION LEVEL SERIALIZABLE";
465-
else
466-
sql = "START TRANSACTION ISOLATION LEVEL REPEATABLE READ";
463+
sprintf(sql, "START TRANSACTION %s; set application_name='pgfdw:%lld:%d';",
464+
IsolationIsSerializable() ? "ISOLATION LEVEL SERIALIZABLE" :
465+
UseRepeatableRead ? "ISOLATION LEVEL REPEATABLE READ" : "",
466+
(long long) GetSystemIdentifier(), MyProcPid);
467467
entry->changing_xact_state = true;
468468
do_sql_command(entry->conn, sql);
469469
entry->xact_depth = 1;

contrib/postgres_fdw/postgres_fdw.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ typedef struct
269269
} ec_member_foreign_arg;
270270

271271
bool UseGlobalSnapshots;
272+
bool UseRepeatableRead;
272273
void _PG_init(void);
273274

274275
/*
@@ -5805,4 +5806,8 @@ _PG_init(void)
58055806
"Use global snapshots for FDW transactions", NULL,
58065807
&UseGlobalSnapshots, false, PGC_USERSET, 0, NULL,
58075808
NULL, NULL);
5809+
DefineCustomBoolVariable("postgres_fdw.use_repeatable_read",
5810+
"Use repeatable read isilation error for remote transactions", NULL,
5811+
&UseRepeatableRead, true, PGC_USERSET, 0, NULL,
5812+
NULL, NULL);
58085813
}

contrib/postgres_fdw/postgres_fdw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ extern const char *get_jointype_name(JoinType jointype);
184184
extern bool is_builtin(Oid objectId);
185185
extern bool is_shippable(Oid objectId, Oid classId, PgFdwRelationInfo *fpinfo);
186186

187+
extern bool UseRepeatableRead;
187188
extern bool UseGlobalSnapshots;
188189

189190
#endif /* POSTGRES_FDW_H */

0 commit comments

Comments
 (0)