Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9ed770f

Browse files
danolivoarssher
authored andcommitted
[PGPRO-4074] Port fix the foreign_key.sql regression test problem.
Cherry pick of[PGPRO-3171] Fix the foreign_key.sql regression test problem.We allow to apply transactions with temporary tables by any worker.Each worker has MyBackendId. At the stage of initialization of temporaryrelation into the relcache, it is set rel->rd_backend to MyBackendId.If worker try to open the ralation it will use rd-backend field to construct the path.If it is differ from the rd_backend of relation creator we catch the ERROR "could not open file ..."Fix the problem by modify BackendIdForTempRelations() routine. Now all workers willinitialize its rd_backend field of corresponding temporary relation by the same value.(cherry picked from commit fae6fc9b861fd7518cb5df8ae506b6f63c5434f6)ars:Funnily enough, the patch has been forgotten in v12 but I've failed to reproducethe original issue there. I suspect it has to do with PGPRO-3124 patch whodelays temp table file creation as late as possible (which on receiver side inmm should mean never create the file, as temp table is ever empty there), butnot 100% sure.tags: multimaster(cherry picked from commit 69036af77ebb5cc51f2733a5a6bcb76a780967d3)
1 parent49ddc13 commit9ed770f

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

‎src/backend/catalog/namespace.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3326,6 +3326,28 @@ GetTempToastNamespace(void)
33263326
returnmyTempToastNamespace;
33273327
}
33283328

3329+
/*
3330+
* MTM-CRUTCH.
3331+
*
3332+
* The BackendId to use for our session's temp relations is normally our own,
3333+
* but parallel workers should use their leader's ID.
3334+
* In a multimaster configuration it is a session id from the node, which
3335+
* connected to the user.
3336+
*/
3337+
int
3338+
BackendIdForTempRelations(void)
3339+
{
3340+
OidnspOid,tnspOid;
3341+
3342+
GetTempNamespaceState(&nspOid,&tnspOid);
3343+
3344+
if (OidIsValid(nspOid))
3345+
returnGetTempNamespaceBackendId(nspOid);
3346+
elseif(OidIsValid(tnspOid))
3347+
returnGetTempNamespaceBackendId(tnspOid);
3348+
else
3349+
returnParallelMasterBackendId==InvalidBackendId ?MyBackendId :ParallelMasterBackendId;
3350+
}
33293351

33303352
/*
33313353
* GetTempNamespaceState - fetch status of session's temporary namespace

‎src/backend/catalog/storage.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include"access/xlog.h"
2626
#include"access/xloginsert.h"
2727
#include"access/xlogutils.h"
28+
#include"catalog/namespace.h"
2829
#include"catalog/storage.h"
2930
#include"catalog/storage_xlog.h"
3031
#include"miscadmin.h"

‎src/include/catalog/namespace.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ extern bool isOtherTempNamespace(Oid namespaceId);
156156
externTempNamespaceStatuscheckTempNamespaceStatus(OidnamespaceId);
157157
externintGetTempNamespaceBackendId(OidnamespaceId);
158158
externOidGetTempToastNamespace(void);
159+
externintBackendIdForTempRelations(void);
159160
externvoidGetTempNamespaceState(Oid*tempNamespaceId,
160161
Oid*tempToastNamespaceId);
161162
externvoidSetTempNamespaceState(OidtempNamespaceId,

‎src/include/storage/backendid.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,4 @@ extern PGDLLIMPORT BackendId MyBackendId;/* backend id of this backend */
2727
/* backend id of our parallel session leader, or InvalidBackendId if none */
2828
externPGDLLIMPORTBackendIdParallelMasterBackendId;
2929

30-
/*
31-
* The BackendId to use for our session's temp relations is normally our own,
32-
* but parallel workers should use their leader's ID.
33-
*/
34-
#defineBackendIdForTempRelations() \
35-
(ParallelMasterBackendId == InvalidBackendId ? MyBackendId : ParallelMasterBackendId)
36-
3730
#endif/* BACKENDID_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp