Make temporary tables use shared storage on datanodes
authorPavan Deolasee <[email protected]>
Wed, 2 Aug 2017 06:52:14 +0000 (12:22 +0530)
committerPavan Deolasee <[email protected]>
Wed, 2 Aug 2017 06:52:14 +0000 (12:22 +0530)
Since a temporary table may be accessed by multiple backends on a datanode, XL
mostly treats such tables as regular tables. But the technique that was used to
distingush between temporary tables that may need shared storage vs those which
are accessed only by a single backend, wasn't very full proof. We were relying
on global session activation to make that distinction. This clearly fails when
a background process, such as autovacuuum process, tries to figure out whether
a table is using local or shared storage. This was leading to various problems,
such as, when the underlying file system objects for the table were getting
cleaned up, but without first discarding all references to the table from the
shared buffers.

We now make all temp tables to use shared storage on the datanodes and thus
simplify things. Only EXECUTE DIRECT anyways does not set up global session, so
I don't think this will have any meaningful impact on the performance.

This should fix the checkpoint failures during regression tests.

src/include/storage/relfilenode.h
src/include/storage/smgr.h

index 075ce6b077ef6e3f529404b5e0d42f1d1ae00968..593ca91a1fffd273545b9414d3a7353404f5e262 100644 (file)
@@ -15,6 +15,7 @@
 #define RELFILENODE_H
 
 #include "common/relpath.h"
+#include "pgxc/pgxc.h"
 #include "storage/backendid.h"
 
 /*
@@ -77,7 +78,7 @@ typedef struct RelFileNodeBackend
 
 #ifdef XCP
 #define RelFileNodeBackendIsTemp(rnode) \
-       (!OidIsValid(MyCoordId) && ((rnode).backend != InvalidBackendId))
+       (!IS_PGXC_DATANODE && ((rnode).backend != InvalidBackendId))
 #else
 #define RelFileNodeBackendIsTemp(rnode) \
        ((rnode).backend != InvalidBackendId)
index 27c33af846bb9fb8e31513365d0e0da4b3b5bb27..06a1db8339efae33502079dc3284965e3add7187 100644 (file)
@@ -78,14 +78,8 @@ typedef struct SMgrRelationData
 
 typedef SMgrRelationData *SMgrRelation;
 
-#ifdef XCP
-#define SmgrIsTemp(smgr) \
-       (!OidIsValid(MyCoordId) && \
-       RelFileNodeBackendIsTemp((smgr)->smgr_rnode))
-#else
 #define SmgrIsTemp(smgr) \
        RelFileNodeBackendIsTemp((smgr)->smgr_rnode)
-#endif
 
 extern void smgrinit(void);
 extern SMgrRelation smgropen(RelFileNode rnode, BackendId backend);