コード例 #1
0
static bool PersistentRelation_CheckTablespaceScanTupleCallback(
    ItemPointer persistentTid,
    int64 persistentSerialNum,
    Datum *values)
{
  RelFileNode relFileNode;

  PersistentFileSysState state;
  int32 reserved;
  TransactionId parentXid;
  int64 serialNum;
  ItemPointerData previousFreeTid;

  bool sharedStorage;

  GpPersistentRelationNode_GetValues(
                                      values,
                                      &relFileNode.spcNode,
                                      &relFileNode.dbNode,
                                      &relFileNode.relNode,
                                      &state,
                                      &reserved,
                                      &parentXid,
                                      &serialNum,
                                      &previousFreeTid,
                                      &sharedStorage);

  if (state == PersistentFileSysState_Created &&
      relFileNode.spcNode == persistentRelationCheckTablespace)
  {
    persistentRelationCheckTablespaceUseCount++;
    if (persistentRelationCheckTablespaceUseCount == 1)
    {
      memcpy(&persistentRelationCheckTablespaceRelationNode, &relFileNode, sizeof(RelFileNode));
    }
  }

  return true; // Continue;
}
コード例 #2
0
ファイル: cdbpersistentcheck.c プロジェクト: BenjaminYu/gpdb
static inline void GpPersistentRelationNodeGetValues(Datum* values, PT_GpPersistentRelationNode *relnode)
{
	GpPersistentRelationNode_GetValues(
									values,
									&relnode->tablespaceOid,
									&relnode->databaseOid,
									&relnode->relfilenodeOid,
									&relnode->segmentFileNum,
									&relnode->relationStorageManager,
									&relnode->persistentState,
									&relnode->createMirrorDataLossTrackingSessionNum,
									&relnode->mirrorExistenceState,
									&relnode->mirrorDataSynchronizationState,
									&relnode->mirrorBufpoolMarkedForScanIncrementalResync,
									&relnode->mirrorBufpoolResyncChangedPageCount,
									&relnode->mirrorBufpoolResyncCkptLoc,
									&relnode->mirrorBufpoolResyncCkptBlockNum,
									&relnode->mirrorAppendOnlyLossEof,
									&relnode->mirrorAppendOnlyNewEof,
									&relnode->relBufpoolKind,
									&relnode->parentXid,
									&relnode->persistentSerialNum,
									&relnode->previousFreeTid);
}
コード例 #3
0
ファイル: gp_persistent.c プロジェクト: HaozhouWang/gpdb
void GpPersistent_GetCommonValues(
	PersistentFsObjType 			fsObjType,
	Datum							*values,

	PersistentFileSysObjName		*fsObjName,
	PersistentFileSysState			*persistentState,
	MirroredObjectExistenceState	*mirrorExistenceState,
	TransactionId					*parentXid,
	int64							*persistentSerialNum)
{
	int64 createMirrorDataLossTrackingSessionNum;
	int32 reserved;

	switch (fsObjType)
	{
	case PersistentFsObjType_RelationFile:
		{
			RelFileNode 					relFileNode;
			int32 							segmentFileNum;

			PersistentFileSysRelStorageMgr	relationStorageManager;
			MirroredRelDataSynchronizationState mirrorDataSynchronizationState;
			bool							mirrorBufpoolMarkedForScanIncrementalResync;
			int64							mirrorBufpoolResyncChangedPageCount;
			XLogRecPtr						mirrorBufpoolResyncCkptLoc;
			BlockNumber 					mirrorBufpoolResyncCkptBlockNum;
			int64							mirrorAppendOnlyLossEof;
			int64							mirrorAppendOnlyNewEof;
			PersistentFileSysRelBufpoolKind relBufpoolKind;

			GpPersistentRelationNode_GetValues(
											values,
											&relFileNode.spcNode,
											&relFileNode.dbNode,
											&relFileNode.relNode,
											&segmentFileNum,
											&relationStorageManager,
											persistentState,
											&createMirrorDataLossTrackingSessionNum,
											mirrorExistenceState,
											&mirrorDataSynchronizationState,
											&mirrorBufpoolMarkedForScanIncrementalResync,
											&mirrorBufpoolResyncChangedPageCount,
											&mirrorBufpoolResyncCkptLoc,
											&mirrorBufpoolResyncCkptBlockNum,
											&mirrorAppendOnlyLossEof,
											&mirrorAppendOnlyNewEof,
											&relBufpoolKind,
											parentXid,
											persistentSerialNum);

			PersistentFileSysObjName_SetRelationFile(
												fsObjName,
												&relFileNode,
												segmentFileNum);
			
		}
		break;

	case PersistentFsObjType_DatabaseDir:
		{
			DbDirNode dbDirNode;

			GpPersistentDatabaseNode_GetValues(
									values,
									&dbDirNode.tablespace,
									&dbDirNode.database,
									persistentState,
									&createMirrorDataLossTrackingSessionNum,
									mirrorExistenceState,
									&reserved,
									parentXid,
									persistentSerialNum);

			PersistentFileSysObjName_SetDatabaseDir(
											fsObjName,
											dbDirNode.tablespace,
											dbDirNode.database);
		}
		break;

	case PersistentFsObjType_TablespaceDir:
		{
			Oid tablespaceOid;
			Oid filespaceOid;

			GpPersistentTablespaceNode_GetValues(
											values,
											&filespaceOid,
											&tablespaceOid,
											persistentState,
											&createMirrorDataLossTrackingSessionNum,
											mirrorExistenceState,
											&reserved,
											parentXid,
											persistentSerialNum);

			PersistentFileSysObjName_SetTablespaceDir(
												fsObjName, 
												tablespaceOid);
		}
	break;
	
	case PersistentFsObjType_FilespaceDir:
		{
			Oid filespaceOid;
			int16 dbId1;
			char locationBlankPadded1[FilespaceLocationBlankPaddedWithNullTermLen];
			int16 dbId2;
			char locationBlankPadded2[FilespaceLocationBlankPaddedWithNullTermLen];

			GpPersistentFilespaceNode_GetValues(
											values,
											&filespaceOid,
											&dbId1,
											locationBlankPadded1,
											&dbId2,
											locationBlankPadded2,
											persistentState,
											&createMirrorDataLossTrackingSessionNum,
											mirrorExistenceState,
											&reserved,
											parentXid,
											persistentSerialNum);

			PersistentFileSysObjName_SetFilespaceDir(
												fsObjName, 
												filespaceOid);
		}
	break;

	default:
		elog(ERROR, "Unexpected persistent file-system object type: %d",
			 fsObjType);
	}
		
}
コード例 #4
0
static bool
PersistentRelation_ScanTupleCallback(
	ItemPointer persistentTid,
	int64 persistentSerialNum,
	Datum *values)
{
	RelFileNode relFileNode;

	PersistentFileSysState state;
	int32 reserved;
	TransactionId parentXid;
	int64 serialNum;
	ItemPointerData previousFreeTid;

	RelationDirEntry relationDirEntry;
	bool sharedStorage;

	GpPersistentRelationNode_GetValues(
								values,
								&relFileNode.spcNode,
								&relFileNode.dbNode,
								&relFileNode.relNode,
								&state,
								&reserved,
								&parentXid,
								&serialNum,
								&previousFreeTid,
								&sharedStorage);

	if (state == PersistentFileSysState_Free)
	{
		if (Debug_persistent_print)
		{
			elog(Persistent_DebugPrintLevel(),
				"PersistentRelation_ScanTupleCallback: TID %s, serial number " INT64_FORMAT " is free",
				ItemPointerToString2(persistentTid),
				persistentSerialNum);
		}

		return true;
	}

	relationDirEntry = PersistentRelation_CreateEntryUnderLock(&relFileNode);

	if (relationDirEntry == NULL)
	{
		elog(ERROR, "Out of shared-memory for persistent relations");
	}

	relationDirEntry->state = state;
	relationDirEntry->persistentSerialNum = serialNum;
	relationDirEntry->persistentTid = *persistentTid;

	if (Debug_persistent_print)
	{
		elog(Persistent_DebugPrintLevel(),
			"PersistentRelation_ScanTupleCallback: tablespace %u, database %u, relation %u, state %s, TID %s, serial number " INT64_FORMAT,
			relFileNode.spcNode,
			relFileNode.dbNode,
			relFileNode.relNode,
			PersistentFileSysObjState_Name(state),
			ItemPointerToString2(persistentTid),
			persistentSerialNum);
	}

	return true;
}
コード例 #5
0
ファイル: cdbpersistentrelation.c プロジェクト: ricky-wu/gpdb
static bool PersistentRelation_CheckTablespaceScanTupleCallback(
    ItemPointer 			persistentTid,
    int64					persistentSerialNum,
    Datum					*values)
{
    RelFileNode		relFileNode;
    int32			segmentFileNum;

    PersistentFileSysRelStorageMgr relationStorageManager;

    PersistentFileSysState	state;

    int64			createMirrorDataLossTrackingSessionNum;

    MirroredObjectExistenceState		mirrorExistenceState;

    MirroredRelDataSynchronizationState mirrorDataSynchronizationState;
    bool							mirrorBufpoolMarkedForScanIncrementalResync;
    int64							mirrorBufpoolResyncChangedPageCount;
    XLogRecPtr						mirrorBufpoolResyncCkptLoc;
    BlockNumber 					mirrorBufpoolResyncCkptBlockNum;

    int64					mirrorAppendOnlyLossEof;
    int64					mirrorAppendOnlyNewEof;

    PersistentFileSysRelBufpoolKind relBufpoolKind;

    TransactionId			parentXid;
    int64					serialNum;
    ItemPointerData			previousFreeTid;

    GpPersistentRelationNode_GetValues(
        values,
        &relFileNode.spcNode,
        &relFileNode.dbNode,
        &relFileNode.relNode,
        &segmentFileNum,
        &relationStorageManager,
        &state,
        &createMirrorDataLossTrackingSessionNum,
        &mirrorExistenceState,
        &mirrorDataSynchronizationState,
        &mirrorBufpoolMarkedForScanIncrementalResync,
        &mirrorBufpoolResyncChangedPageCount,
        &mirrorBufpoolResyncCkptLoc,
        &mirrorBufpoolResyncCkptBlockNum,
        &mirrorAppendOnlyLossEof,
        &mirrorAppendOnlyNewEof,
        &relBufpoolKind,
        &parentXid,
        &serialNum,
        &previousFreeTid);

    if (state == PersistentFileSysState_Created &&
            relFileNode.spcNode == persistentRelationCheckTablespace)
    {
        persistentRelationCheckTablespaceUseCount++;
        if (persistentRelationCheckTablespaceUseCount == 1)
        {
            memcpy(&persistentRelationCheckTablespaceRelFileNode, &relFileNode, sizeof(RelFileNode));
        }
    }

    return true;	// Continue.
}
コード例 #6
0
void GpPersistent_GetCommonValues(
	PersistentFsObjType 			fsObjType,
	Datum							*values,
	PersistentFileSysObjName		*fsObjName,
	PersistentFileSysState			*persistentState,
	TransactionId					*parentXid,
	int64							*persistentSerialNum)
{
	int32 reserved;
	ItemPointerData previousFreeTid;
	bool sharedStorage;

	switch (fsObjType)
	{
	case PersistentFsObjType_RelationFile:
		{
			RelFileNode 					relFileNode;
			int32 							segmentFileNum;

			PersistentFileSysRelStorageMgr	relationStorageManager;
			PersistentFileSysRelBufpoolKind relBufpoolKind;

			GpPersistentRelfileNode_GetValues(
											values,
											&relFileNode.spcNode,
											&relFileNode.dbNode,
											&relFileNode.relNode,
											&segmentFileNum,
											&relationStorageManager,
											persistentState,
											&relBufpoolKind,
											parentXid,
											persistentSerialNum,
											&previousFreeTid,
											&sharedStorage);

			PersistentFileSysObjName_SetRelationFile(
												fsObjName,
												&relFileNode,
												segmentFileNum,
												NULL);
			fsObjName->hasInited = true;
			fsObjName->sharedStorage = sharedStorage;
			
		}
		break;

	case PersistentFsObjType_RelationDir:
		{
			RelFileNode relFileNode;

			GpPersistentRelationNode_GetValues(
									values,
									&relFileNode.spcNode,
									&relFileNode.dbNode,
									&relFileNode.relNode,
									persistentState,
									&reserved,
									parentXid,
									persistentSerialNum,
									&previousFreeTid,
									&sharedStorage);

			PersistentFileSysObjName_SetRelationDir(
									fsObjName,
									&relFileNode,
									NULL);
			fsObjName->hasInited = true;
			fsObjName->sharedStorage = sharedStorage;
		}
		break;

	case PersistentFsObjType_DatabaseDir:
		{
			DbDirNode dbDirNode;

			GpPersistentDatabaseNode_GetValues(
									values,
									&dbDirNode.tablespace,
									&dbDirNode.database,
									persistentState,
									&reserved,
									parentXid,
									persistentSerialNum,
									&previousFreeTid,
									&sharedStorage);

			PersistentFileSysObjName_SetDatabaseDir(
											fsObjName,
											dbDirNode.tablespace,
											dbDirNode.database,
											NULL);
			fsObjName->hasInited = true;
			fsObjName->sharedStorage = sharedStorage;
		}
		break;

	case PersistentFsObjType_TablespaceDir:
		{
			Oid tablespaceOid;
			Oid filespaceOid;

			GpPersistentTablespaceNode_GetValues(
											values,
											&filespaceOid,
											&tablespaceOid,
											persistentState,
											&reserved,
											parentXid,
											persistentSerialNum,
											&previousFreeTid,
											&sharedStorage);

			PersistentFileSysObjName_SetTablespaceDir(
												fsObjName, 
												tablespaceOid,
												NULL);
			fsObjName->hasInited = true;
			fsObjName->sharedStorage = sharedStorage;
		}
	break;
	
	case PersistentFsObjType_FilespaceDir:
		{
			Oid filespaceOid;
			int16 dbId1;
			char locationBlankPadded1[FilespaceLocationBlankPaddedWithNullTermLen];

			GpPersistentFilespaceNode_GetValues(
											values,
											&filespaceOid,
											&dbId1,
											locationBlankPadded1,
											persistentState,
											&reserved,
											parentXid,
											persistentSerialNum,
											&previousFreeTid,
											&sharedStorage);

			PersistentFileSysObjName_SetFilespaceDir(
												fsObjName, 
												filespaceOid,
												NULL);
			fsObjName->hasInited = true;
			fsObjName->sharedStorage = sharedStorage;
		}
	break;

	default:
		elog(ERROR, "Unexpected persistent file-system object type: %d",
			 fsObjType);
	}
		
}