提交 e2c699c8 编写于 作者: A Ashwin Agrawal

Gpexpand use gp_add_segment to register primaries.

Currently, dbid is used in tablespace path. Hence, while creating
segment need dbid. To get the dbid need to add segment to catalog
first. But adding segment to catalog before creating causes
issues. Hence, modify gpexpand to not let database generate the dbid,
but instead pass the dbid upfront generated while registering in
catalog. This way dbid used while creating the segment will be same as
dbid in catalog.
Reviewed-by: NJimmy Yih <jyih@pivotal.io>
上级 bcdcb827
...@@ -126,10 +126,8 @@ class GpConfigurationProviderUsingGpdbCatalog(GpConfigurationProvider) : ...@@ -126,10 +126,8 @@ class GpConfigurationProviderUsingGpdbCatalog(GpConfigurationProvider) :
for seg in update.mirror_to_add: for seg in update.mirror_to_add:
mirror_map[ seg.getSegmentContentId() ] = seg mirror_map[ seg.getSegmentContentId() ] = seg
# reset dbId of new primary and mirror segments to -1 # reset dbId of new mirror segments to -1
# before invoking the operations which will assign them new ids # before invoking the operations which will assign them new ids
for seg in update.primary_to_add:
seg.setSegmentDbId(-1)
for seg in update.mirror_to_add: for seg in update.mirror_to_add:
seg.setSegmentDbId(-1) seg.setSegmentDbId(-1)
...@@ -273,16 +271,22 @@ class GpConfigurationProviderUsingGpdbCatalog(GpConfigurationProvider) : ...@@ -273,16 +271,22 @@ class GpConfigurationProviderUsingGpdbCatalog(GpConfigurationProvider) :
def __callSegmentAdd(self, conn, gpArray, seg): def __callSegmentAdd(self, conn, gpArray, seg):
""" """
Call gp_add_segment_primary() to add the primary. Ideally, should call gp_add_segment_primary() to add the
Return the new segment's dbid. primary. But due to chicken-egg problem, need dbid for
creating the segment but can't add to catalog before creating
segment. Hence, instead using gp_add_segment() which takes
dbid and registers in catalog using the same. Return the new
segment's dbid.
""" """
logger.debug('callSegmentAdd %s' % repr(seg)) logger.debug('callSegmentAdd %s' % repr(seg))
sql = "SELECT gp_add_segment_primary(%s, %s, %s, %s)" \ sql = "SELECT gp_add_segment(%s::int2, %s::int2, 'p', 'p', 'n', 'u', %s, %s, %s, %s)" \
% ( % (
self.__toSqlIntValue(seg.getSegmentDbId()),
self.__toSqlIntValue(seg.getSegmentContentId()),
self.__toSqlIntValue(seg.getSegmentPort()),
self.__toSqlTextValue(seg.getSegmentHostName()), self.__toSqlTextValue(seg.getSegmentHostName()),
self.__toSqlTextValue(seg.getSegmentAddress()), self.__toSqlTextValue(seg.getSegmentAddress()),
self.__toSqlIntValue(seg.getSegmentPort()),
self.__toSqlTextValue(seg.getSegmentDataDirectory()), self.__toSqlTextValue(seg.getSegmentDataDirectory()),
) )
logger.debug(sql) logger.debug(sql)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册