diff --git a/src/common/backend/catalog/heap.cpp b/src/common/backend/catalog/heap.cpp index 01b2f6f37b3319bc57912b8e3f1f7b00d08e3554..c0b5e93634abdac36c6a7a77c0cc74a22684adc5 100644 --- a/src/common/backend/catalog/heap.cpp +++ b/src/common/backend/catalog/heap.cpp @@ -2717,6 +2717,12 @@ Oid heap_create_with_catalog(const char *relname, Oid relnamespace, Oid reltable ereport(WARNING, (errmsg("Store unlogged table in segment when enable system table segment"))); } + /* store tables in segment storage as all possible while initdb */ + if (relpersistence == RELPERSISTENCE_PERMANENT && (relkind == RELKIND_RELATION || + relkind == RELKIND_INDEX || relkind == RELKIND_GLOBAL_INDEX)) { + storage_type = SEGMENT_PAGE; + reloptions = AddSegmentOption(reloptions); + } } pg_class_desc = heap_open(RelationRelationId, RowExclusiveLock); diff --git a/src/gausskernel/bootstrap/bootstrap.cpp b/src/gausskernel/bootstrap/bootstrap.cpp index de044b23ada6c5ac2d2b211caaea7fec178fea10..a1719d5d9b86187ab7be7b68bb9ac3eeaa67932f 100755 --- a/src/gausskernel/bootstrap/bootstrap.cpp +++ b/src/gausskernel/bootstrap/bootstrap.cpp @@ -734,6 +734,9 @@ void InsertOneTuple(Oid objectid) ereport(FATAL, (errmsg("Built-in functions should not be added into pg_proc"))); } + if (IsBootingPgClass(t_thrd.bootstrap_cxt.boot_reldesc) && EnableInitDBSegment) { + ChangePgClassBucketValueForSegment(); + } tupDesc = CreateTupleDesc(t_thrd.bootstrap_cxt.numattr, RelationGetForm(t_thrd.bootstrap_cxt.boot_reldesc)->relhasoids, t_thrd.bootstrap_cxt.attrtypes, diff --git a/src/gausskernel/optimizer/commands/tablecmds.cpp b/src/gausskernel/optimizer/commands/tablecmds.cpp index 8d5b98c6e7a6ecf253e8f21aff8e611de8d40bef..d9978c38b91868fcbffc46fe3ac086702c802d5d 100755 --- a/src/gausskernel/optimizer/commands/tablecmds.cpp +++ b/src/gausskernel/optimizer/commands/tablecmds.cpp @@ -2960,11 +2960,17 @@ ObjectAddress DefineRelation(CreateStmt* stmt, char relkind, Oid ownerId, Object } } - if (!IsInitdb && (relkind == RELKIND_RELATION) && !IsSystemNamespace(namespaceId) && + if ((ENABLE_DMS && !IsInitdb) && (relkind == RELKIND_RELATION) && !IsSystemNamespace(namespaceId) && !IsCStoreNamespace(namespaceId) && (pg_strcasecmp(storeChar, ORIENTATION_ROW) == 0) && (stmt->relation->relpersistence == RELPERSISTENCE_PERMANENT) && !u_sess->attr.attr_storage.enable_recyclebin) { bool isSegmentType = (storage_type == SEGMENT_PAGE); - } else if (storage_type == SEGMENT_PAGE) { + if (!isSegmentType && (u_sess->attr.attr_storage.enable_segment || bucketinfo != NULL)) { + storage_type = SEGMENT_PAGE; + DefElem *storage_def = makeDefElem("segment", (Node *)makeString("on")); + stmt->options = lappend(stmt->options, storage_def); + reloptions = transformRelOptions((Datum)0, stmt->options, NULL, validnsps, true, false); + } + } else if (ENABLE_DMS && storage_type == SEGMENT_PAGE) { if (u_sess->attr.attr_storage.enable_recyclebin) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmodule(MOD_SEGMENT_PAGE), errmsg("The table %s do not support segment-page storage", stmt->relation->relname), @@ -3029,15 +3035,25 @@ ObjectAddress DefineRelation(CreateStmt* stmt, char relkind, Oid ownerId, Object } if (ENABLE_DMS && !u_sess->attr.attr_common.IsInplaceUpgrade) { - if (pg_strcasecmp(storeChar, ORIENTATION_ROW) != 0 || + if ((relkind == RELKIND_RELATION && storage_type != SEGMENT_PAGE + && (stmt->relation->relpersistence != RELPERSISTENCE_UNLOGGED) + && (stmt->relation->relpersistence != RELPERSISTENCE_TEMP) + && (stmt->relation->relpersistence != RELPERSISTENCE_GLOBAL_TEMP))|| + pg_strcasecmp(storeChar, ORIENTATION_ROW) != 0 || pg_strcasecmp(COMPRESSION_NO, StdRdOptionsGetStringData(std_opt, compression, COMPRESSION_NO)) != 0 || IsCompressedByCmprsInPgclass((RelCompressType)stmt->row_compress)) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("Only support ASTORE while DMS and DSS enabled.\n" + errmsg("Only support segment storage ASTORE while DMS and DSS enabled.\n" "Compression is not supported."))); } } + if (!IsInitdb && u_sess->attr.attr_storage.enable_segment && storage_type == SEGMENT_PAGE && + !CheckSegmentStorageOption(stmt->options)) { + ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("Only support segment storage type while parameter enable_segment is ON."))); + } + CheckSegmentCompressOption(stmt->options, relkind, storage_type, storeChar); /* diff --git a/src/gausskernel/process/tcop/utility.cpp b/src/gausskernel/process/tcop/utility.cpp index 82ff13e09d62012ab8bc379028854e06f8f0f097..36663de8ad6aea54e647d975a0bdae25ef8cb5a1 100755 --- a/src/gausskernel/process/tcop/utility.cpp +++ b/src/gausskernel/process/tcop/utility.cpp @@ -14577,16 +14577,15 @@ static void PreRedoTableInOndemandRecovery(Oid relId) { } /* Check if support target relation type when enable DMS. If not, no need to redo. */ - if (relation->rd_rel->relkind == RELKIND_RELATION || + if ((relation->rd_rel->relkind == RELKIND_RELATION && IsSegmentPhysicalRelNode(relation->rd_node)) || RelationIsTableAccessMethodUStoreType(relation->rd_options) || RelationIsCUFormat(relation) || - relation->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED || RowRelationIsCompressed(relation)) { if (SS_IN_ONDEMAND_RECOVERY) { heap_close(relation, ExclusiveLock); ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("[On-demand]Only support ASTORE while DMS and DSS enable.\n" - "unlogged table is not supported.\nCompression is not supported."))); + errmsg("[On-demand]Only support segment storage type and ASTORE while DMS and DSS enable.\n" + "Compression is not supported."))); } } diff --git a/src/gausskernel/storage/buffer/bufmgr.cpp b/src/gausskernel/storage/buffer/bufmgr.cpp index f69c4da0d03af93c996ff670a6e371d3332e2c54..bb24aff8ca213ce5a369b1d77d0cd46337908aca 100644 --- a/src/gausskernel/storage/buffer/bufmgr.cpp +++ b/src/gausskernel/storage/buffer/bufmgr.cpp @@ -2764,6 +2764,11 @@ found_branch: if (LWLockHeldByMe(bufHdr->io_in_progress_lock)) { TerminateBufferIO(bufHdr, false, 0); } + /* when in failover worker thread should exit */ + if (SS_IN_FAILOVER && SS_AM_BACKENDS_WORKERS) { + SSUnPinBuffer(bufHdr); + ereport(ERROR, (errmodule(MOD_DMS), (errmsg("worker thread which in failover are exiting")))); + } pg_usleep(5000L); continue; } @@ -2773,6 +2778,11 @@ found_branch: if (LWLockHeldByMe(bufHdr->io_in_progress_lock)) { TerminateBufferIO(bufHdr, false, 0); } + /* when in failover worker thread should exit */ + if (SS_IN_FAILOVER && SS_AM_BACKENDS_WORKERS) { + SSUnPinBuffer(bufHdr); + ereport(ERROR, (errmodule(MOD_DMS), (errmsg("worker thread which in failover are exiting")))); + } continue; } diff --git a/src/test/regress/parallel_schedule0 b/src/test/regress/parallel_schedule0 index 4a0aab753736e99419998f9ea901ad080ecbeb0d..856ba905c7f1d6862dcdfce434288329c1b7533e 100644 --- a/src/test/regress/parallel_schedule0 +++ b/src/test/regress/parallel_schedule0 @@ -433,7 +433,7 @@ test: partiton_pathkey_col_plan partiton_pathkey_col_randomexec partiton_pathkey #test: create_function_1 test: create_table create_table_2 create_table_3 test: temp__4 -#test: create_seg_table +test: create_seg_table #test: copy# diff --git a/src/test/regress/parallel_schedule0A b/src/test/regress/parallel_schedule0A index 67b07c8f184ecda9d750e26dc2af37d835c218a8..53ca87897bf2ba0b74e57cef4490bb08959ec6ff 100644 --- a/src/test/regress/parallel_schedule0A +++ b/src/test/regress/parallel_schedule0A @@ -421,7 +421,7 @@ test: partiton_pathkey_col_plan partiton_pathkey_col_randomexec partiton_pathkey #test: create_function_1 test: create_table create_table_2 create_table_3 test: temp__4 obsscaninfo -#test: create_seg_table +test: create_seg_table #test: copy# # show_events