forked from openGauss-Ecosystem/openGauss-server
Compare commits
34 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
dde14c622e | |
|
|
93a1b93f40 | |
|
|
3246399eba | |
|
|
793e2ebf1a | |
|
|
7d9bb66972 | |
|
|
8b83bcdd2c | |
|
|
727e6ea941 | |
|
|
591e19db8d | |
|
|
cee4f486b3 | |
|
|
a94a50e30d | |
|
|
d639b6b943 | |
|
|
9e748bc12d | |
|
|
918d319bd1 | |
|
|
2468767828 | |
|
|
5dde94aeb4 | |
|
|
73f7d2f9b1 | |
|
|
34830d852d | |
|
|
b8ee37ad67 | |
|
|
ca5adff1b6 | |
|
|
8148d0a19d | |
|
|
efae2abdc9 | |
|
|
85748e3c12 | |
|
|
00eaec99a3 | |
|
|
cb4bb56d8d | |
|
|
946165b8cb | |
|
|
432cc6d43a | |
|
|
dd853ba943 | |
|
|
37de345c9c | |
|
|
1443f58545 | |
|
|
b1e88debe4 | |
|
|
227264f32a | |
|
|
7b3c0feadd | |
|
|
93b27dc49f | |
|
|
13d461869b |
|
|
@ -0,0 +1,24 @@
|
|||
[submodule "openGauss-Custom-function"]
|
||||
path = openGauss-Custom-function
|
||||
url = ../openGauss-Custom-function.git
|
||||
[submodule "openGauss-Query-select"]
|
||||
path = openGauss-Query-select
|
||||
url = ../openGauss-Query-select.git
|
||||
[submodule "openGauss-Security-control"]
|
||||
path = openGauss-Security-control
|
||||
url = ../openGauss-Security-control.git
|
||||
[submodule "openGauss-Stored-Procedure"]
|
||||
path = openGauss-Stored-Procedure
|
||||
url = ../openGauss-Stored-Procedure.git
|
||||
[submodule "openGauss-basic-operation"]
|
||||
path = openGauss-basic-operation
|
||||
url = ../openGauss-basic-operation.git
|
||||
[submodule "openGauss-transaction"]
|
||||
path = openGauss-transaction
|
||||
url = ../openGauss-transaction.git
|
||||
[submodule "openGauss-trigger"]
|
||||
path = openGauss-trigger
|
||||
url = ../openGauss-trigger.git
|
||||
[submodule "openGauss-competition"]
|
||||
path = openGauss-competition
|
||||
url = ../openGauss-competition.git
|
||||
|
|
@ -835,6 +835,7 @@
|
|||
./lib/libpagecompression.so*
|
||||
./lib/libdssapi.so
|
||||
./lib/libdms.so
|
||||
./lib/libodbc.so*
|
||||
|
||||
./include/postgresql/server/postgres_ext.h
|
||||
./include/postgresql/server/pg_config_os.h
|
||||
|
|
|
|||
|
|
@ -884,6 +884,7 @@
|
|||
./lib/postgresql/latin2_and_win1250.so
|
||||
./lib/postgresql/euc2004_sjis2004.so
|
||||
./lib/libhll.so
|
||||
./lib/libodbc.so*
|
||||
|
||||
./include/postgresql/server/postgres_ext.h
|
||||
./include/postgresql/server/pg_config_os.h
|
||||
|
|
|
|||
|
|
@ -887,6 +887,7 @@
|
|||
./lib/postgresql/latin2_and_win1250.so
|
||||
./lib/postgresql/euc2004_sjis2004.so
|
||||
./lib/libhll.so
|
||||
./lib/libodbc.so*
|
||||
|
||||
./include/postgresql/server/postgres_ext.h
|
||||
./include/postgresql/server/pg_config_os.h
|
||||
|
|
|
|||
|
|
@ -832,6 +832,7 @@
|
|||
./lib/libpagecompression.so*
|
||||
./lib/libdssapi.so
|
||||
./lib/libdms.so
|
||||
./lib/libodbc.so*
|
||||
|
||||
./include/postgresql/server/postgres_ext.h
|
||||
./include/postgresql/server/pg_config_os.h
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ static bool UseODBCLinker(char* connstr);
|
|||
#define REMOTE_CONN_HASH (get_session_context()->remoteConnHash)
|
||||
/* initial number of connection hashes */
|
||||
#define NUMCONN 16
|
||||
#define NAX_ERR_MSG_LEN 1000
|
||||
#define MAX_BUF_LEN 100000
|
||||
#define MAX_DRIVERNAME_LEN 50
|
||||
#define DBLINK_NOTIFY_COLS 3
|
||||
|
|
@ -559,6 +560,9 @@ ODBCLinker::ODBCLinker(char* connstr_or_name)
|
|||
}
|
||||
|
||||
LinkInfo linfo;
|
||||
linfo.drivername = NULL;
|
||||
linfo.password = NULL;
|
||||
linfo.username = NULL;
|
||||
int len = strlen(connstr_or_name);
|
||||
GetDrivername(connstr_or_name, &linfo);
|
||||
/* atuo commit is the default value */
|
||||
|
|
@ -568,11 +572,13 @@ ODBCLinker::ODBCLinker(char* connstr_or_name)
|
|||
securec_check(rc, "\0", "\0");
|
||||
|
||||
if ((error != SQL_SUCCESS) && (error != SQL_SUCCESS_WITH_INFO)) {
|
||||
SQLCHAR sqlcode[NAX_ERR_MSG_LEN];
|
||||
SQLGetDiagField(SQL_HANDLE_DBC, this->connHandle, 1, SQL_DIAG_MESSAGE_TEXT, &sqlcode, NAX_ERR_MSG_LEN, NULL);
|
||||
SQLFreeHandle(SQL_HANDLE_DBC, this->connHandle);
|
||||
SQLFreeHandle(SQL_HANDLE_ENV, this->envHandle);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_CONNECTION_FAILURE),
|
||||
errmsg("Error SQLConnect")));
|
||||
errmsg("Error SQLConnect\n%s", sqlcode)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -629,9 +635,8 @@ char* ODBCLinker::errorMsg()
|
|||
if (this->stmt == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
int msgLen = 100;
|
||||
char* msg = (char*)palloc(sizeof(char) * msgLen);
|
||||
SQLGetDiagRec(SQL_HANDLE_STMT, this->stmt, 1, NULL, NULL, (SQLCHAR*)msg, 100 ,NULL);
|
||||
char* msg = (char*)palloc(sizeof(char) * NAX_ERR_MSG_LEN);
|
||||
SQLGetDiagRec(SQL_HANDLE_STMT, this->stmt, 1, NULL, NULL, (SQLCHAR*)msg, NAX_ERR_MSG_LEN, NULL);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ docker_temp_server_start() {
|
|||
|
||||
# internal start of server in order to allow setup using gsql client
|
||||
# does not listen on external TCP/IP and waits until start finishes
|
||||
set -- "$@" -c listen_addresses='' -p "${PGPORT:-5432}"
|
||||
set -- "$@" -c "listen_addresses='*'" -p "${PGPORT:-5432}"
|
||||
|
||||
PGUSER="${PGUSER:-$GS_USER}" \
|
||||
gs_ctl -D "$PGDATA" \
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Subproject commit f2a09ee9e98b3c0ed1ec26da6f1c3ddacece41b1
|
||||
|
|
@ -0,0 +1 @@
|
|||
Subproject commit ba09836e0bb59243426a28b79c260570ec87e78e
|
||||
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 5c3a84bd0c656ef7529a8fcd806e07f24560b415
|
||||
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 22959853b32c2653c6dc663fb236329680847ed6
|
||||
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 26e5d6310154258393807b95336c04b2eda991ce
|
||||
|
|
@ -0,0 +1 @@
|
|||
Subproject commit a8f2377a242dbdb6a8366738c85d365bef478477
|
||||
|
|
@ -0,0 +1 @@
|
|||
Subproject commit d037643b5dfb030eb8b0da4ecb22b0bd6a51a8b1
|
||||
|
|
@ -0,0 +1 @@
|
|||
Subproject commit f7a9a3b2e2c28a4f045a857debcaea372273826d
|
||||
|
|
@ -4205,7 +4205,7 @@ int main(int argc, char* argv[])
|
|||
break;
|
||||
case 8:
|
||||
FREE_NOT_STATIC_ZERO_STRING(locale);
|
||||
locale = "C";
|
||||
locale = xstrdup("C");
|
||||
break;
|
||||
case 9:
|
||||
FREE_NOT_STATIC_ZERO_STRING(pwfilename);
|
||||
|
|
|
|||
|
|
@ -1154,8 +1154,6 @@ static void BaseBackup(void)
|
|||
/* Error message already written in GetConnection() */
|
||||
exit(1);
|
||||
|
||||
ClearAndFreePasswd();
|
||||
|
||||
/*
|
||||
* Run IDENTIFY_SYSTEM so we can get the timeline
|
||||
*/
|
||||
|
|
@ -1335,6 +1333,7 @@ static void BaseBackup(void)
|
|||
StartLogStreamer((const char *)xlogstart, timeline, sysidentifier);
|
||||
}
|
||||
|
||||
ClearAndFreePasswd();
|
||||
/* free sysidentifier after use */
|
||||
PQfreemem(sysidentifier);
|
||||
sysidentifier = NULL;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1137,6 +1137,67 @@ void* MemoryContextAllocZeroAlignedDebug(MemoryContext context, Size size, const
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* MemoryContextAllocExtended
|
||||
* Allocate space within the specified context using the given flags.
|
||||
*
|
||||
* This method supports all three memory allocation flags which makes it
|
||||
* suitable for almost all circumstances.
|
||||
*/
|
||||
void* MemoryContextAllocExtendedDebug(MemoryContext context, Size size, int flags, const char* file, int line)
|
||||
{
|
||||
void* ret = NULL;
|
||||
bool allocsz_is_valid = false;
|
||||
|
||||
Assert(MemoryContextIsValid(context));
|
||||
#ifdef MEMORY_CONTEXT_CHECKING
|
||||
PreventActionOnSealedContext(context);
|
||||
#endif
|
||||
|
||||
/* Make sure memory allocation size is valid. */
|
||||
if ((flags & MCXT_ALLOC_HUGE) != 0) {
|
||||
allocsz_is_valid = AllocHugeSizeIsValid(size);
|
||||
} else {
|
||||
allocsz_is_valid = AllocSizeIsValid(size);
|
||||
}
|
||||
|
||||
if (!allocsz_is_valid) {
|
||||
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid memory alloc request size %lu in %s:%d", (unsigned long)size, file, line)));
|
||||
}
|
||||
|
||||
context->isReset = false;
|
||||
|
||||
/* Invoke memory allocator */
|
||||
ret = (*context->methods->alloc)(context, 0, size, file, line);
|
||||
if ((flags & MCXT_ALLOC_NO_OOM) != 0) {
|
||||
/* Do nothing */
|
||||
} else if (unlikely(ret == NULL)) {
|
||||
ereport(ERROR, (errcode(ERRCODE_OUT_OF_LOGICAL_MEMORY), errmsg("memory is temporarily unavailable"),
|
||||
errdetail("Failed on request of size %lu bytes under queryid %lu in %s:%d.",
|
||||
(unsigned long)size, u_sess->debug_query_id, file, line)));
|
||||
}
|
||||
|
||||
/* Set aligned if MCXT_ALLOC_ZERO */
|
||||
if ((flags & MCXT_ALLOC_ZERO) != 0) {
|
||||
MemSetAligned(ret, 0, size);
|
||||
}
|
||||
|
||||
#ifdef MEMORY_CONTEXT_CHECKING
|
||||
/* check if the memory context is out of control */
|
||||
MemoryContextCheckMaxSize(context, size, file, line);
|
||||
#endif
|
||||
|
||||
/* check if the session used memory is beyond the limitation */
|
||||
if (unlikely(STATEMENT_MAX_MEM)) {
|
||||
MemoryContextCheckSessionMemory(context, size, file, line);
|
||||
}
|
||||
InsertMemoryAllocInfo(ret, context, file, line, size);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* palloc_extended
|
||||
* palloc with flags, it will return NULL while OOM happend.
|
||||
|
|
|
|||
|
|
@ -657,13 +657,13 @@ static HeapTuple PLy_modify_tuple(PLyProcedure* proc, PyObject* pltd, TriggerDat
|
|||
} else if (plval != Py_None) {
|
||||
PLyObToDatum* att = &proc->result.out.r.atts[atti];
|
||||
|
||||
modvalues[i] = (att->func)(att, tupdesc->attrs[atti]->atttypmod, plval);
|
||||
modvalues[i] = (att->func)(att, tupdesc->attrs[atti].atttypmod, plval);
|
||||
modnulls[i] = ' ';
|
||||
} else {
|
||||
modvalues[i] = InputFunctionCall(&proc->result.out.r.atts[atti].typfunc,
|
||||
NULL,
|
||||
proc->result.out.r.atts[atti].typioparam,
|
||||
tupdesc->attrs[atti]->atttypmod);
|
||||
tupdesc->attrs[atti].atttypmod);
|
||||
modnulls[i] = 'n';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include "executor/spi.h"
|
||||
#include "executor/executor.h"
|
||||
#include "miscadmin.h"
|
||||
#include "auditfuncs.h"
|
||||
#include "pgaudit.h"
|
||||
#include "utils/guc.h"
|
||||
#include "utils/memutils.h"
|
||||
|
|
@ -29,7 +30,6 @@
|
|||
#include "plpy_plpymodule.h"
|
||||
#include "plpy_procedure.h"
|
||||
|
||||
const int PGAUDIT_MAXLENGTH = 1024;
|
||||
|
||||
/* exported functions */
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ static PLyProcedure* PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is
|
|||
rvTypeStruct = (Form_pg_type)GETSTRUCT(rvTypeTup);
|
||||
/* Disallow pseudotype result, except for void or record */
|
||||
if (rvTypeStruct->typtype == TYPTYPE_PSEUDO) {
|
||||
if (procStruct->prorettype == TRIGGEROID || rettype == EVTTRIGGEROID) {
|
||||
if (procStruct->prorettype == TRIGGEROID || procStruct->prorettype == EVTTRIGGEROID) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("trigger functions can only be called as triggers")));
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include "ddes/dms/ss_dms_bufmgr.h"
|
||||
#include "securec_check.h"
|
||||
#include "miscadmin.h"
|
||||
#include "access/double_write.h"
|
||||
|
||||
void InitDmsBufCtrl(void)
|
||||
{
|
||||
|
|
@ -765,3 +766,98 @@ bool DmsCheckBufAccessible()
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SSTryFlushBuffer(BufferDesc *buf)
|
||||
{
|
||||
//copy from BufferAlloc
|
||||
if (!backend_can_flush_dirty_page()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (LWLockConditionalAcquire(buf->content_lock, LW_SHARED)) {
|
||||
if (dw_enabled() && pg_atomic_read_u32(&g_instance.ckpt_cxt_ctl->current_page_writer_count) > 0) {
|
||||
if (!free_space_enough(buf->buf_id)) {
|
||||
LWLockRelease(buf->content_lock);
|
||||
return false;
|
||||
}
|
||||
uint32 pos = 0;
|
||||
pos = first_version_dw_single_flush(buf);
|
||||
t_thrd.proc->dw_pos = pos;
|
||||
FlushBuffer(buf, NULL);
|
||||
g_instance.dw_single_cxt.single_flush_state[pos] = true;
|
||||
t_thrd.proc->dw_pos = -1;
|
||||
} else {
|
||||
FlushBuffer(buf, NULL);
|
||||
}
|
||||
LWLockRelease(buf->content_lock);
|
||||
ScheduleBufferTagForWriteback(t_thrd.storage_cxt.BackendWritebackContext, &buf->tag);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SSTrySegFlushBuffer(BufferDesc* buf)
|
||||
{
|
||||
//copy from SegBufferAlloc
|
||||
if (!backend_can_flush_dirty_page()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (LWLockConditionalAcquire(buf->content_lock, LW_SHARED)) {
|
||||
FlushOneSegmentBuffer(buf->buf_id + 1);
|
||||
LWLockRelease(buf->content_lock);
|
||||
ScheduleBufferTagForWriteback(t_thrd.storage_cxt.BackendWritebackContext, &buf->tag);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** true :1)this buffer dms think need flush, and flush success
|
||||
* 2) no need flush
|
||||
* false: this flush dms think need flush, but cannot flush
|
||||
*/
|
||||
bool SSHelpFlushBufferIfNeed(BufferDesc* buf_desc)
|
||||
{
|
||||
if (!ENABLE_DMS) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (IsInitdb) {
|
||||
return true;
|
||||
}
|
||||
|
||||
dms_buf_ctrl_t *buf_ctrl = GetDmsBufCtrl(buf_desc->buf_id);
|
||||
if (buf_ctrl->state & BUF_DIRTY_NEED_FLUSH) {
|
||||
// wait dw_init finish
|
||||
while (!g_instance.dms_cxt.dw_init) {
|
||||
pg_usleep(1000L);
|
||||
}
|
||||
|
||||
XLogRecPtr pagelsn = BufferGetLSN(buf_desc);
|
||||
if (!SS_IN_REFORM) {
|
||||
ereport(PANIC,
|
||||
(errmsg("[SS] this buffer should not exist with BUF_DIRTY_NEED_FLUSH but not in reform, "
|
||||
"spc/db/rel/bucket fork-block: %u/%u/%u/%d %d-%u, page lsn (0x%llx), seg info:%u-%u",
|
||||
buf_desc->tag.rnode.spcNode, buf_desc->tag.rnode.dbNode, buf_desc->tag.rnode.relNode,
|
||||
buf_desc->tag.rnode.bucketNode, buf_desc->tag.forkNum, buf_desc->tag.blockNum,
|
||||
(unsigned long long)pagelsn, (unsigned int)buf_desc->extra->seg_fileno,
|
||||
buf_desc->extra->seg_blockno)));
|
||||
}
|
||||
bool in_flush_copy = SS_IN_FLUSHCOPY;
|
||||
bool in_recovery = !g_instance.dms_cxt.SSRecoveryInfo.recovery_pause_flag;
|
||||
ereport(LOG,
|
||||
(errmsg("[SS flush copy] ready to flush buffer with need flush, "
|
||||
"spc/db/rel/bucket fork-block: %u/%u/%u/%d %d-%u, page lsn (0x%llx), seg info:%u-%u, reform phase "
|
||||
"is in flush_copy:%d, in recovery:%d",
|
||||
buf_desc->tag.rnode.spcNode, buf_desc->tag.rnode.dbNode, buf_desc->tag.rnode.relNode,
|
||||
buf_desc->tag.rnode.bucketNode, buf_desc->tag.forkNum, buf_desc->tag.blockNum,
|
||||
(unsigned long long)pagelsn, (unsigned int)buf_desc->extra->seg_fileno, buf_desc->extra->seg_blockno,
|
||||
in_flush_copy, in_recovery)));
|
||||
if (IsSegmentBufferID(buf_desc->buf_id)) {
|
||||
return SSTrySegFlushBuffer(buf_desc);
|
||||
} else {
|
||||
return SSTryFlushBuffer(buf_desc);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -300,7 +300,6 @@ static int CBDbIsPrimary(void *db_handle)
|
|||
|
||||
static int CBSwitchoverPromote(void *db_handle, unsigned char origPrimaryId)
|
||||
{
|
||||
g_instance.dms_cxt.SSClusterState = NODESTATE_STANDBY_PROMOTING;
|
||||
g_instance.dms_cxt.SSRecoveryInfo.new_primary_reset_walbuf_flag = true;
|
||||
/* allow recovery in switchover to keep LSN in order */
|
||||
t_thrd.shemem_ptr_cxt.XLogCtl->IsRecoveryDone = false;
|
||||
|
|
@ -1249,12 +1248,10 @@ static int CBRecoveryStandby(void *db_handle, int inst_id)
|
|||
Assert(inst_id == g_instance.attr.attr_storage.dms_attr.instance_id);
|
||||
ereport(LOG, (errmsg("[SS reform] Recovery as standby")));
|
||||
|
||||
g_instance.dms_cxt.SSRecoveryInfo.skip_redo_replay = true;
|
||||
if (!SSRecoveryNodes()) {
|
||||
ereport(WARNING, (errmodule(MOD_DMS), errmsg("Recovery failed in startup first")));
|
||||
return GS_ERROR;
|
||||
}
|
||||
g_instance.dms_cxt.SSRecoveryInfo.skip_redo_replay = false;
|
||||
|
||||
return GS_SUCCESS;
|
||||
}
|
||||
|
|
@ -1263,7 +1260,6 @@ static int CBRecoveryPrimary(void *db_handle, int inst_id)
|
|||
{
|
||||
Assert(g_instance.dms_cxt.SSReformerControl.primaryInstId == inst_id ||
|
||||
g_instance.dms_cxt.SSReformerControl.primaryInstId == -1);
|
||||
g_instance.dms_cxt.SSRecoveryInfo.skip_redo_replay = false;
|
||||
g_instance.dms_cxt.SSRecoveryInfo.in_flushcopy = false;
|
||||
ereport(LOG, (errmsg("[SS reform] Recovery as primary, will replay xlog from inst:%d",
|
||||
g_instance.dms_cxt.SSReformerControl.primaryInstId)));
|
||||
|
|
@ -1283,6 +1279,11 @@ static int CBFlushCopy(void *db_handle, char *pageid)
|
|||
smgrcloseall();
|
||||
}
|
||||
|
||||
// only 1) primary restart 2) failover need flush_copy
|
||||
if (SS_REFORM_REFORMER && g_instance.dms_cxt.dms_status == DMS_STATUS_IN && !SS_STANDBY_FAILOVER) {
|
||||
return GS_SUCCESS;
|
||||
}
|
||||
|
||||
BufferTag* tag = (BufferTag*)pageid;
|
||||
Buffer buffer;
|
||||
SegSpace *spc = NULL;
|
||||
|
|
@ -1304,7 +1305,7 @@ static int CBFlushCopy(void *db_handle, char *pageid)
|
|||
ErrorData* edata = CopyErrorData();
|
||||
FlushErrorState();
|
||||
FreeErrorData(edata);
|
||||
ereport(PANIC, (errmsg("[SS Flush Copy] Error happend, spc/db/rel/bucket fork-block: %u/%u/%u/%d %d-%u",
|
||||
ereport(PANIC, (errmsg("[SS flush copy] Error happend, spc/db/rel/bucket fork-block: %u/%u/%u/%d %d-%u",
|
||||
tag->rnode.spcNode, tag->rnode.dbNode, tag->rnode.relNode, tag->rnode.bucketNode,
|
||||
tag->forkNum, tag->blockNum)));
|
||||
}
|
||||
|
|
@ -1387,23 +1388,31 @@ static int CBGetDBPrimaryId(void *db_handle, unsigned int *primary_id)
|
|||
return GS_SUCCESS;
|
||||
}
|
||||
|
||||
/* Currently only used in SS switchover */
|
||||
/*
|
||||
* Currently only used in SS switchover. To prevent state machine misjudgement,
|
||||
* DSS status, dms_role, SSClusterState must be set atommically.
|
||||
* DSS recommends we retry dss_set_server_status if it failed.
|
||||
*/
|
||||
static void CBReformSetDmsRole(void *db_handle, unsigned int reformer_id)
|
||||
{
|
||||
ss_reform_info_t *reform_info = &g_instance.dms_cxt.SSReformInfo;
|
||||
reform_info->dms_role = reformer_id == (unsigned int)SS_MY_INST_ID ? DMS_ROLE_REFORMER : DMS_ROLE_PARTNER;
|
||||
if (reform_info->dms_role == DMS_ROLE_REFORMER) {
|
||||
/* since original primary must have demoted, it is safe to allow promting standby write */
|
||||
if (dss_set_server_status_wrapper() != GS_SUCCESS) {
|
||||
ereport(PANIC, (errmodule(MOD_DMS),
|
||||
errmsg("Could not set dssserver flag, vgname: \"%s\", socketpath: \"%s\"",
|
||||
g_instance.attr.attr_storage.dss_attr.ss_dss_vg_name,
|
||||
g_instance.attr.attr_storage.dss_attr.ss_dss_conn_path),
|
||||
errhint("Check vgname and socketpath and restart later.")));
|
||||
dms_role_t new_dms_role = reformer_id == (unsigned int)SS_MY_INST_ID ? DMS_ROLE_REFORMER : DMS_ROLE_PARTNER;
|
||||
if (new_dms_role == DMS_ROLE_REFORMER) {
|
||||
ereport(LOG, (errmodule(MOD_DMS), errmsg("[SS switchover]begin to set currrent DSS as primary")));
|
||||
while (dss_set_server_status_wrapper() != GS_SUCCESS) {
|
||||
pg_usleep(REFORM_WAIT_LONG);
|
||||
ereport(WARNING, (errmodule(MOD_DMS),
|
||||
errmsg("Failed to set DSS as primary, vgname: \"%s\", socketpath: \"%s\"",
|
||||
g_instance.attr.attr_storage.dss_attr.ss_dss_vg_name,
|
||||
g_instance.attr.attr_storage.dss_attr.ss_dss_conn_path),
|
||||
errhint("Check vgname and socketpath and restart later.")));
|
||||
}
|
||||
g_instance.dms_cxt.SSClusterState = NODESTATE_STANDBY_PROMOTING;
|
||||
}
|
||||
|
||||
reform_info->dms_role = new_dms_role;
|
||||
ereport(LOG, (errmodule(MOD_DMS),
|
||||
errmsg("[SS switchover]switching, updated inst:%d with role:%d success",
|
||||
errmsg("[SS switchover]role and lock switched, updated inst:%d with role:%d success",
|
||||
SS_MY_INST_ID, reform_info->dms_role)));
|
||||
}
|
||||
|
||||
|
|
@ -1417,6 +1426,7 @@ static void CBReformStartNotify(void *db_handle, dms_role_t role, unsigned char
|
|||
if (ss_reform_type == DMS_REFORM_TYPE_FOR_FAILOVER_OPENGAUSS) {
|
||||
g_instance.dms_cxt.SSRecoveryInfo.in_failover = true;
|
||||
if (role == DMS_ROLE_REFORMER) {
|
||||
g_instance.dms_cxt.dw_init = false;
|
||||
// variable set order: SharedRecoveryInProgress -> failover_triggered -> dms_role
|
||||
volatile XLogCtlData *xlogctl = t_thrd.shemem_ptr_cxt.XLogCtl;
|
||||
SpinLockAcquire(&xlogctl->info_lck);
|
||||
|
|
@ -1436,8 +1446,13 @@ static void CBReformStartNotify(void *db_handle, dms_role_t role, unsigned char
|
|||
ereport(LOG, (errmodule(MOD_DMS),
|
||||
errmsg("[SS reform] dms reform start, role:%d, reform type:%d", role, (int)ss_reform_type)));
|
||||
if (reform_info->dms_role == DMS_ROLE_REFORMER) {
|
||||
if (dss_set_server_status_wrapper() != GS_SUCCESS) {
|
||||
ereport(PANIC, (errmodule(MOD_DMS), errmsg("[SS reform] Could not set dssserver flag=read_write")));
|
||||
while (dss_set_server_status_wrapper() != GS_SUCCESS) {
|
||||
pg_usleep(REFORM_WAIT_LONG);
|
||||
ereport(WARNING, (errmodule(MOD_DMS),
|
||||
errmsg("Failed to set DSS as primary, vgname: \"%s\", socketpath: \"%s\"",
|
||||
g_instance.attr.attr_storage.dss_attr.ss_dss_vg_name,
|
||||
g_instance.attr.attr_storage.dss_attr.ss_dss_conn_path),
|
||||
errhint("Check vgname and socketpath and restart later.")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ bool SSRecoveryNodes()
|
|||
return result;
|
||||
}
|
||||
|
||||
bool SSRecoveryApplyDelay(const XLogReaderState *record)
|
||||
bool SSRecoveryApplyDelay()
|
||||
{
|
||||
if (!ENABLE_REFORM) {
|
||||
return false;
|
||||
|
|
@ -327,7 +327,6 @@ void ss_failover_dw_init()
|
|||
}
|
||||
}
|
||||
ckpt_shutdown_pagewriter();
|
||||
g_instance.dms_cxt.SSRecoveryInfo.in_flushcopy = false;
|
||||
ss_failover_dw_init_internal();
|
||||
g_instance.dms_cxt.dw_init = true;
|
||||
}
|
||||
|
|
@ -346,5 +345,6 @@ void ss_switchover_promoting_dw_init()
|
|||
dw_exit(false);
|
||||
dw_ext_init();
|
||||
dw_init();
|
||||
g_instance.dms_cxt.dw_init = true;
|
||||
ereport(LOG, (errmodule(MOD_DMS), errmsg("[SS switchover] dw init finished")));
|
||||
}
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
dms_commit_id=4dad7c5286ed4a1975f5e1e101b0c533cbb00880
|
||||
dss_commit_id=38705ea061f9f701c5dd930518edfb320c8bccce
|
||||
dms_commit_id=e3e57f04172da967232eb5ec593e5576ee1563a4
|
||||
dss_commit_id=2b1567f18e8d78c0473b781b97cae963a06d1735
|
||||
|
|
|
|||
|
|
@ -362,10 +362,10 @@ function Reg()
|
|||
log "can't find inst id. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
dsscmd reghl -i ${LOCAL_INSTANCE_ID} -D ${DSS_HOME} >> /dev/null 2>&1
|
||||
dsscmd reghl -D ${DSS_HOME} >> /dev/null 2>&1
|
||||
if [[ $? != 0 ]]
|
||||
then
|
||||
log "dsscmd reghl -i ${LOCAL_INSTANCE_ID} -D ${DSS_HOME} fail."
|
||||
log "dsscmd reghl -D ${DSS_HOME} fail."
|
||||
exit 1
|
||||
fi
|
||||
log "register success."
|
||||
|
|
@ -381,7 +381,7 @@ function Unreg()
|
|||
fi
|
||||
if [[ ${LOCAL_INSTANCE_ID} == ${INSTANCE_ID} ]]
|
||||
then
|
||||
dsscmd unreghl -i ${LOCAL_INSTANCE_ID} -D ${DSS_HOME} >> /dev/null 2>&1
|
||||
dsscmd unreghl -D ${DSS_HOME} >> /dev/null 2>&1
|
||||
else
|
||||
pid=$(program_pid dssserver ${DSS_HOME})
|
||||
if [[ -z ${pid} ]]
|
||||
|
|
@ -394,7 +394,7 @@ function Unreg()
|
|||
|
||||
if [[ $? != 0 ]]
|
||||
then
|
||||
log "dsscmd kickh -i ${INSTANCE_ID} -D ${DSS_HOME} fail, or dsscmd unreghl -i ${LOCAL_INSTANCE_ID} -D ${DSS_HOME} fail."
|
||||
log "dsscmd kickh -i ${INSTANCE_ID} -D ${DSS_HOME} fail, or dsscmd unreghl -D ${DSS_HOME} fail."
|
||||
exit 1
|
||||
fi
|
||||
log "unregister ${INSTANCE_ID} success."
|
||||
|
|
|
|||
|
|
@ -1440,7 +1440,7 @@ bool has_lossy_pages(RelOptInfo *baserel, const double &pages_fetched, double &l
|
|||
*/
|
||||
double heap_pages = Min(pages_fetched, baserel->pages);
|
||||
const long work_mem_size = u_sess->attr.attr_memory.work_mem * 1024L;
|
||||
long maxentries = tbm_calculate_entries(work_mem_size);
|
||||
long maxentries = tbm_calculate_entries(work_mem_size, false);
|
||||
if (maxentries >= heap_pages) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3037,11 +3037,13 @@ int PostmasterMain(int argc, char* argv[])
|
|||
}
|
||||
|
||||
if (SS_PRIMARY_MODE) {
|
||||
if (dss_set_server_status_wrapper() != GS_SUCCESS) {
|
||||
ereport(FATAL, (errmsg("Could not set dssserver flag, vgname: \"%s\", socketpath: \"%s\"",
|
||||
g_instance.attr.attr_storage.dss_attr.ss_dss_vg_name,
|
||||
g_instance.attr.attr_storage.dss_attr.ss_dss_conn_path),
|
||||
errhint("Check vgname and socketpath and restart later.")));
|
||||
while (dss_set_server_status_wrapper() != GS_SUCCESS) {
|
||||
pg_usleep(REFORM_WAIT_LONG);
|
||||
ereport(WARNING, (errmodule(MOD_DMS),
|
||||
errmsg("Failed to set DSS as primary, vgname: \"%s\", socketpath: \"%s\"",
|
||||
g_instance.attr.attr_storage.dss_attr.ss_dss_vg_name,
|
||||
g_instance.attr.attr_storage.dss_attr.ss_dss_conn_path),
|
||||
errhint("Check vgname and socketpath and restart later.")));
|
||||
}
|
||||
ereport(LOG, (errmsg("set dss server status as primary")));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6244,7 +6244,7 @@ ProcessUtilitySlow(Node *parse_tree,
|
|||
break;
|
||||
|
||||
case T_CreatePLangStmt:
|
||||
if (!IsInitdb)
|
||||
if (!IsInitdb && strncmp(((CreatePLangStmt*)parse_tree)->plname, "plpython", strlen("plpython")) != 0)
|
||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("new language is not yet supported.")));
|
||||
address = CreateProceduralLanguage((CreatePLangStmt*)parse_tree);
|
||||
#ifdef PGXC
|
||||
|
|
|
|||
|
|
@ -183,7 +183,6 @@ static void knl_g_dms_init(knl_g_dms_context *dms_cxt)
|
|||
dms_cxt->SSRecoveryInfo.recovery_pause_flag = true;
|
||||
dms_cxt->SSRecoveryInfo.failover_triggered = false;
|
||||
dms_cxt->SSRecoveryInfo.new_primary_reset_walbuf_flag = false;
|
||||
dms_cxt->SSRecoveryInfo.skip_redo_replay = false;
|
||||
dms_cxt->SSRecoveryInfo.ready_to_startup = false;
|
||||
dms_cxt->SSRecoveryInfo.startup_reform = true;
|
||||
dms_cxt->SSRecoveryInfo.restart_failover_flag = false;
|
||||
|
|
|
|||
|
|
@ -112,8 +112,10 @@ Node* MultiExecBitmapAnd(BitmapAndState* node)
|
|||
*/
|
||||
for (i = 0; i < nplans; i++) {
|
||||
PlanState* subnode = bitmapplans[i];
|
||||
subnode->hbktScanSlot.currSlot = node->ps.hbktScanSlot.currSlot;
|
||||
TIDBitmap* subresult = NULL;
|
||||
TBMHandler tbm_handler;
|
||||
|
||||
subnode->hbktScanSlot.currSlot = node->ps.hbktScanSlot.currSlot;
|
||||
|
||||
subresult = (TIDBitmap*)MultiExecProcNode(subnode);
|
||||
if (subresult == NULL || !IsA(subresult, TIDBitmap))
|
||||
|
|
@ -125,6 +127,8 @@ Node* MultiExecBitmapAnd(BitmapAndState* node)
|
|||
if (result == NULL) {
|
||||
result = subresult; /* first subplan */
|
||||
} else {
|
||||
/* get tbm handlers */
|
||||
tbm_handler = tbm_get_handler(result);
|
||||
/*
|
||||
* If the global tbm intersect with non-global tbm,
|
||||
* set the final result to non-global tbm.
|
||||
|
|
@ -137,7 +141,7 @@ Node* MultiExecBitmapAnd(BitmapAndState* node)
|
|||
tbm_set_global(result, false);
|
||||
}
|
||||
|
||||
tbm_intersect(result, subresult);
|
||||
tbm_handler._intersect(result, subresult);
|
||||
tbm_free(subresult);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -258,6 +258,7 @@ static TupleTableSlot* BitmapHeapTblNext(BitmapHeapScanState* node)
|
|||
ExprContext* econtext = NULL;
|
||||
TableScanDesc scan = NULL;
|
||||
TIDBitmap* tbm = NULL;
|
||||
TBMHandler tbm_handler;
|
||||
TBMIterator* tbmiterator = NULL;
|
||||
TBMIterateResult* tbmres = NULL;
|
||||
HBktTblScanDesc hpscan = NULL;
|
||||
|
|
@ -301,6 +302,7 @@ static TupleTableSlot* BitmapHeapTblNext(BitmapHeapScanState* node)
|
|||
*/
|
||||
if (tbm == NULL) {
|
||||
tbm = (TIDBitmap*)MultiExecProcNode(outerPlanState(node));
|
||||
tbm_handler = tbm_get_handler(tbm);
|
||||
|
||||
if (tbm == NULL || !IsA(tbm, TIDBitmap)) {
|
||||
ereport(ERROR,
|
||||
|
|
@ -310,12 +312,12 @@ static TupleTableSlot* BitmapHeapTblNext(BitmapHeapScanState* node)
|
|||
}
|
||||
|
||||
node->tbm = tbm;
|
||||
node->tbmiterator = tbmiterator = tbm_begin_iterate(tbm);
|
||||
node->tbmiterator = tbmiterator = tbm_handler._begin_iterate(tbm);
|
||||
node->tbmres = tbmres = NULL;
|
||||
|
||||
#ifdef USE_PREFETCH
|
||||
if (u_sess->storage_cxt.target_prefetch_pages > 0) {
|
||||
node->prefetch_iterator = prefetch_iterator = tbm_begin_iterate(tbm);
|
||||
node->prefetch_iterator = prefetch_iterator = tbm_handler._begin_iterate(tbm);
|
||||
node->prefetch_pages = 0;
|
||||
node->prefetch_target = -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,21 +34,6 @@
|
|||
#include "nodes/makefuncs.h"
|
||||
|
||||
static void ExecInitNextPartitionForBitmapIndexScan(BitmapIndexScanState* node);
|
||||
/* If bitmapscan uses global partition index, set tbm to global */
|
||||
static inline void GPIUpdateTbmType(BitmapIndexScanState* node, TIDBitmap* tbm)
|
||||
{
|
||||
if (RelationIsGlobalIndex(node->biss_RelationDesc)) {
|
||||
tbm_set_global(tbm, true);
|
||||
}
|
||||
}
|
||||
|
||||
/* if bitmapscan uses crossbucket index, set tbm->crossbucket to true */
|
||||
static inline void CBIUpdateTbmType(BitmapIndexScanState* node, TIDBitmap* tbm)
|
||||
{
|
||||
if (RelationIsCrossBucketIndex(node->biss_RelationDesc)) {
|
||||
tbm_set_crossbucket(tbm, true);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* MultiExecBitmapIndexScan(node)
|
||||
|
|
@ -98,13 +83,9 @@ Node* MultiExecBitmapIndexScan(BitmapIndexScanState* node)
|
|||
node->biss_result = NULL; /* reset for next time */
|
||||
} else {
|
||||
/* XXX should we use less than u_sess->attr.attr_memory.work_mem for this? */
|
||||
tbm = TbmCreate(u_sess->attr.attr_memory.work_mem * 1024L, isUstore);
|
||||
|
||||
/* If bitmapscan uses global partition index, set tbm to global. */
|
||||
GPIUpdateTbmType(node, tbm);
|
||||
|
||||
/* If bitmapscan uses crossbucket index, set tbm->crossbucket to true. */
|
||||
CBIUpdateTbmType(node, tbm);
|
||||
long maxbytes = u_sess->attr.attr_memory.work_mem * 1024L;
|
||||
tbm = tbm_create(maxbytes, RelationIsGlobalIndex(node->biss_RelationDesc),
|
||||
RelationIsCrossBucketIndex(node->biss_RelationDesc), isUstore);
|
||||
}
|
||||
|
||||
/* Cross-bucket index scan should not switch the index bucket. */
|
||||
|
|
|
|||
|
|
@ -126,15 +126,11 @@ Node* MultiExecBitmapOr(BitmapOrState* node)
|
|||
/* first subplan */
|
||||
if (result == NULL) {
|
||||
/* XXX should we use less than u_sess->attr.attr_memory.work_mem for this? */
|
||||
result = TbmCreate(u_sess->attr.attr_memory.work_mem * 1024L, isUstore);
|
||||
/* If bitmapscan uses global partition index, set tbm to global. */
|
||||
if (RelationIsGlobalIndex(((BitmapIndexScanState*)subnode)->biss_RelationDesc)) {
|
||||
tbm_set_global(result, true);
|
||||
}
|
||||
/* If bitmapscan uses crossbucket index, set tbm to crossbucket. */
|
||||
if (RelationIsCrossBucketIndex(((BitmapIndexScanState*)subnode)->biss_RelationDesc)) {
|
||||
tbm_set_crossbucket(result, true);
|
||||
}
|
||||
long maxbytes = u_sess->attr.attr_memory.work_mem * 1024L;
|
||||
result = tbm_create(maxbytes,
|
||||
RelationIsGlobalIndex(((BitmapIndexScanState *)subnode)->biss_RelationDesc),
|
||||
RelationIsCrossBucketIndex(((BitmapIndexScanState *)subnode)->biss_RelationDesc),
|
||||
isUstore);
|
||||
}
|
||||
|
||||
((BitmapIndexScanState*)subnode)->biss_result = result;
|
||||
|
|
@ -157,13 +153,14 @@ Node* MultiExecBitmapOr(BitmapOrState* node)
|
|||
if (result == NULL) {
|
||||
result = subresult; /* first subplan */
|
||||
} else {
|
||||
TBMHandler tbm_handler = tbm_get_handler(result);
|
||||
if (tbm_is_global(result) != tbm_is_global(subresult)) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNRECOGNIZED_NODE_TYPE),
|
||||
errmsg(
|
||||
"do not support bitmap index scan for global index and local index simultaneously.")));
|
||||
}
|
||||
tbm_union(result, subresult);
|
||||
tbm_handler._union(result, subresult);
|
||||
tbm_free(subresult);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,9 +148,6 @@ Node* MultiExecHash(HashState* node)
|
|||
}
|
||||
(void)pgstat_report_waitstatus(oldStatus);
|
||||
|
||||
/* analyze hash table information for unique sql hash state */
|
||||
UpdateUniqueSQLHashStats(hashtable, &start_time);
|
||||
|
||||
/* resize the hash table if needed (NTUP_PER_BUCKET exceeded) */
|
||||
if (hashtable->nbuckets != hashtable->nbuckets_optimal) {
|
||||
/* We never decrease the number of buckets. */
|
||||
|
|
@ -172,6 +169,9 @@ Node* MultiExecHash(HashState* node)
|
|||
if (hashtable->spaceUsed > hashtable->spacePeak)
|
||||
hashtable->spacePeak = hashtable->spaceUsed;
|
||||
|
||||
/* analyze hash table information for unique sql hash state */
|
||||
UpdateUniqueSQLHashStats(hashtable, &start_time);
|
||||
|
||||
/* must provide our own instrumentation support */
|
||||
if (node->ps.instrument) {
|
||||
InstrStopNode(node->ps.instrument, hashtable->totalTuples);
|
||||
|
|
|
|||
|
|
@ -178,10 +178,11 @@ int GinDataLeafPageGetItemsToTbm(Page page, TIDBitmap *tbm)
|
|||
|
||||
nitems = ginPostingListDecodeAllSegmentsToTbm(segment, len, tbm);
|
||||
} else {
|
||||
TBMHandler tbm_handler = tbm_get_handler(tbm);
|
||||
uncompressed = dataLeafPageGetUncompressed(page, &nitems);
|
||||
|
||||
if (nitems > 0)
|
||||
tbm_add_tuples(tbm, uncompressed, nitems, false);
|
||||
tbm_handler._add_tuples(tbm, uncompressed, nitems, false, InvalidOid, InvalidBktId);
|
||||
}
|
||||
|
||||
return nitems;
|
||||
|
|
|
|||
|
|
@ -132,10 +132,12 @@ static bool collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack, GinSca
|
|||
{
|
||||
OffsetNumber attnum;
|
||||
Form_pg_attribute attr;
|
||||
TBMHandler tbm_handler;
|
||||
|
||||
/* Initialize empty bitmap result */
|
||||
if (!isColStore) {
|
||||
scanEntry->matchBitmap = TbmCreate(u_sess->attr.attr_memory.work_mem * 1024L);
|
||||
scanEntry->matchBitmap = tbm_create(u_sess->attr.attr_memory.work_mem * 1024L);
|
||||
tbm_handler = tbm_get_handler(scanEntry->matchBitmap);
|
||||
}
|
||||
|
||||
/* Null query cannot partial-match anything */
|
||||
|
|
@ -280,7 +282,7 @@ static bool collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack, GinSca
|
|||
ipd = ginReadTuple(btree->ginstate, scanEntry->attnum, itup, &nipd);
|
||||
|
||||
if (!isColStore) {
|
||||
tbm_add_tuples(scanEntry->matchBitmap, ipd, nipd, false);
|
||||
tbm_handler._add_tuples(scanEntry->matchBitmap, ipd, nipd, false, InvalidOid, InvalidBktId);
|
||||
} else {
|
||||
if (scanEntry->matchList == NULL) {
|
||||
scanEntry->matchList = (ItemPointer)palloc(nipd * sizeof(ItemPointerData));
|
||||
|
|
@ -374,7 +376,8 @@ restartScanEntry:
|
|||
}
|
||||
|
||||
if (!isColStore && entry->matchBitmap && !tbm_is_empty(entry->matchBitmap)) {
|
||||
entry->matchIterator = tbm_begin_iterate(entry->matchBitmap);
|
||||
TBMHandler tbm_handler = tbm_get_handler(entry->matchBitmap);
|
||||
entry->matchIterator = tbm_handler._begin_iterate(entry->matchBitmap);
|
||||
entry->isFinished = false;
|
||||
}
|
||||
|
||||
|
|
@ -1569,6 +1572,7 @@ static void scanPendingInsert(IndexScanDesc scan, TIDBitmap *tbm, int64 *ntids)
|
|||
pendingPosition pos;
|
||||
Buffer metabuffer = ReadBuffer(scan->indexRelation, GIN_METAPAGE_BLKNO);
|
||||
BlockNumber blkno;
|
||||
TBMHandler tbm_handler = tbm_get_handler(tbm);
|
||||
Oid partHeapOid = IndexScanGetPartHeapOid(scan);
|
||||
|
||||
*ntids = 0;
|
||||
|
|
@ -1628,7 +1632,7 @@ static void scanPendingInsert(IndexScanDesc scan, TIDBitmap *tbm, int64 *ntids)
|
|||
MemoryContextReset(so->tempCtx);
|
||||
|
||||
if (match) {
|
||||
tbm_add_tuples(tbm, &pos.item, 1, recheck, partHeapOid);
|
||||
tbm_handler._add_tuples(tbm, &pos.item, 1, recheck, partHeapOid, InvalidBktId);
|
||||
(*ntids)++;
|
||||
}
|
||||
}
|
||||
|
|
@ -1652,6 +1656,7 @@ Datum gingetbitmap(PG_FUNCTION_ARGS)
|
|||
int64 ntids;
|
||||
ItemPointerData iptr;
|
||||
bool recheck = false;
|
||||
TBMHandler tbm_handler = tbm_get_handler(tbm);
|
||||
Oid partHeapOid = IndexScanGetPartHeapOid(scan);
|
||||
|
||||
/*
|
||||
|
|
@ -1691,9 +1696,9 @@ Datum gingetbitmap(PG_FUNCTION_ARGS)
|
|||
break;
|
||||
|
||||
if (ItemPointerIsLossyPage(&iptr))
|
||||
tbm_add_page(tbm, ItemPointerGetBlockNumber(&iptr), partHeapOid);
|
||||
tbm_handler._add_page(tbm, ItemPointerGetBlockNumber(&iptr), partHeapOid, InvalidBktId);
|
||||
else
|
||||
tbm_add_tuples(tbm, &iptr, 1, recheck, partHeapOid);
|
||||
tbm_handler._add_tuples(tbm, &iptr, 1, recheck, partHeapOid, InvalidBktId);
|
||||
ntids++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -361,9 +361,10 @@ int ginPostingListDecodeAllSegmentsToTbm(GinPostingList *ptr, int len, TIDBitmap
|
|||
{
|
||||
int ndecoded;
|
||||
ItemPointer items;
|
||||
TBMHandler tbm_handler = tbm_get_handler(tbm);
|
||||
|
||||
items = ginPostingListDecodeAllSegments(ptr, len, &ndecoded);
|
||||
tbm_add_tuples(tbm, items, ndecoded, false);
|
||||
tbm_handler._add_tuples(tbm, items, ndecoded, false, InvalidOid, InvalidBktId);
|
||||
pfree(items);
|
||||
return ndecoded;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -288,11 +288,12 @@ static void gistScanPage(IndexScanDesc scan, const GISTSearchItem *pageItem, con
|
|||
continue;
|
||||
|
||||
if (tbm && GistPageIsLeaf(page)) {
|
||||
TBMHandler tbm_handler = tbm_get_handler(tbm);
|
||||
/*
|
||||
* getbitmap scan, so just push heap tuple TIDs into the bitmap
|
||||
* without worrying about ordering
|
||||
*/
|
||||
tbm_add_tuples(tbm, &it->t_tid, 1, recheck, partHeapOid);
|
||||
tbm_handler._add_tuples(tbm, &it->t_tid, 1, recheck, partHeapOid, InvalidBktId);
|
||||
(*ntids)++;
|
||||
} else if (scan->numberOfOrderBys == 0 && GistPageIsLeaf(page)) {
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -357,8 +357,9 @@ Datum hashgetbitmap(PG_FUNCTION_ARGS)
|
|||
|
||||
/* Save tuple ID, and continue scanning */
|
||||
if (add_tuple) {
|
||||
TBMHandler tbm_handler = tbm_get_handler(tbm);
|
||||
/* Note we mark the tuple ID as requiring recheck */
|
||||
tbm_add_tuples(tbm, &(so->hashso_heappos), 1, true, partHeapOid);
|
||||
tbm_handler._add_tuples(tbm, &(so->hashso_heappos), 1, true, partHeapOid, InvalidBktId);
|
||||
ntids++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -320,6 +320,9 @@ int64 btgetbitmap_internal(IndexScanDesc scan, TIDBitmap *tbm)
|
|||
BTScanOpaque so = (BTScanOpaque)scan->opaque;
|
||||
int64 ntids = 0;
|
||||
ItemPointer heapTid;
|
||||
Oid currPartOid;
|
||||
int2 bucketid;
|
||||
TBMHandler tbm_handler = tbm_get_handler(tbm);
|
||||
|
||||
/*
|
||||
* If we have any array keys, initialize them.
|
||||
|
|
@ -339,9 +342,9 @@ int64 btgetbitmap_internal(IndexScanDesc scan, TIDBitmap *tbm)
|
|||
if (_bt_first(scan, ForwardScanDirection)) {
|
||||
/* Save tuple ID, and continue scanning */
|
||||
heapTid = &scan->xs_ctup.t_self;
|
||||
Oid currPartOid = so->currPos.items[so->currPos.itemIndex].partitionOid;
|
||||
int2 bucketid = so->currPos.items[so->currPos.itemIndex].bucketid;
|
||||
tbm_add_tuples(tbm, heapTid, 1, false, currPartOid, bucketid);
|
||||
currPartOid = so->currPos.items[so->currPos.itemIndex].partitionOid;
|
||||
bucketid = so->currPos.items[so->currPos.itemIndex].bucketid;
|
||||
tbm_handler._add_tuples(tbm, heapTid, 1, false, currPartOid, bucketid);
|
||||
ntids++;
|
||||
|
||||
for (;;) {
|
||||
|
|
@ -360,7 +363,7 @@ int64 btgetbitmap_internal(IndexScanDesc scan, TIDBitmap *tbm)
|
|||
heapTid = &so->currPos.items[so->currPos.itemIndex].heapTid;
|
||||
currPartOid = so->currPos.items[so->currPos.itemIndex].partitionOid;
|
||||
bucketid = so->currPos.items[so->currPos.itemIndex].bucketid;
|
||||
tbm_add_tuples(tbm, heapTid, 1, false, currPartOid, bucketid);
|
||||
tbm_handler._add_tuples(tbm, heapTid, 1, false, currPartOid, bucketid);
|
||||
ntids++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -489,8 +489,9 @@ static void spgWalk(Relation index, SpGistScanOpaque so, bool scanWholeIndex, st
|
|||
|
||||
/* storeRes subroutine for getbitmap case */
|
||||
static void storeBitmap(SpGistScanOpaque so, ItemPointer heapPtr, Datum leafValue, bool isnull, bool recheck)
|
||||
{
|
||||
tbm_add_tuples(so->tbm, heapPtr, 1, recheck, so->partHeapOid);
|
||||
{
|
||||
TBMHandler tbm_handler = tbm_get_handler(so->tbm);
|
||||
tbm_handler._add_tuples(so->tbm, heapPtr, 1, recheck, so->partHeapOid, InvalidBktId);
|
||||
so->ntids++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9866,7 +9866,9 @@ void StartupXLOG(void)
|
|||
* replay. This avoids as well any subsequent scans when doing recovery
|
||||
* of the on-disk two-phase data.
|
||||
*/
|
||||
restoreTwoPhaseData();
|
||||
if (!ENABLE_DMS || SS_PRIMARY_MODE) {
|
||||
restoreTwoPhaseData();
|
||||
}
|
||||
|
||||
StartupCSNLOG();
|
||||
|
||||
|
|
@ -9912,7 +9914,8 @@ void StartupXLOG(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (SSSKIP_REDO_REPLAY && t_thrd.xlog_cxt.InRecovery == true) {
|
||||
if (SS_STANDBY_MODE && t_thrd.xlog_cxt.InRecovery == true) {
|
||||
SSRecoveryApplyDelay();
|
||||
/* do not need replay anything in SS standby mode */
|
||||
ereport(LOG, (errmsg("[SS] Skip redo replay in standby mode")));
|
||||
t_thrd.xlog_cxt.InRecovery = false;
|
||||
|
|
@ -10324,7 +10327,7 @@ void StartupXLOG(void)
|
|||
CountRedoTime(t_thrd.xlog_cxt.timeCost[TIME_COST_STEP_2]);
|
||||
#endif
|
||||
|
||||
if (ENABLE_DMS && !SS_PERFORMING_SWITCHOVER && SSRecoveryApplyDelay(xlogreader)) {
|
||||
if (ENABLE_DMS && !SS_PERFORMING_SWITCHOVER && SSRecoveryApplyDelay()) {
|
||||
if (xlogctl->recoveryPause) {
|
||||
recoveryPausesHere();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -291,6 +291,8 @@ Datum ubtgetbitmap(PG_FUNCTION_ARGS)
|
|||
BTScanOpaque so = (BTScanOpaque)scan->opaque;
|
||||
int64 ntids = 0;
|
||||
ItemPointer heapTid;
|
||||
Oid currPartOid;
|
||||
TBMHandler tbm_handler = tbm_get_handler(tbm);
|
||||
|
||||
WHITEBOX_TEST_STUB("ubtgetbitmap", WhiteboxDefaultErrorEmit);
|
||||
|
||||
|
|
@ -312,8 +314,8 @@ Datum ubtgetbitmap(PG_FUNCTION_ARGS)
|
|||
if (UBTreeFirst(scan, ForwardScanDirection)) {
|
||||
/* Save tuple ID, and continue scanning */
|
||||
heapTid = &scan->xs_ctup.t_self;
|
||||
Oid currPartOid = so->currPos.items[so->currPos.itemIndex].partitionOid;
|
||||
tbm_add_tuples(tbm, heapTid, 1, scan->xs_recheck_itup, currPartOid);
|
||||
currPartOid = so->currPos.items[so->currPos.itemIndex].partitionOid;
|
||||
tbm_handler._add_tuples(tbm, heapTid, 1, scan->xs_recheck_itup, currPartOid, InvalidBktId);
|
||||
ntids++;
|
||||
|
||||
for (;;) {
|
||||
|
|
@ -331,7 +333,7 @@ Datum ubtgetbitmap(PG_FUNCTION_ARGS)
|
|||
/* Save tuple ID, and continue scanning */
|
||||
heapTid = &so->currPos.items[so->currPos.itemIndex].heapTid;
|
||||
currPartOid = so->currPos.items[so->currPos.itemIndex].partitionOid;
|
||||
tbm_add_tuples(tbm, heapTid, 1, scan->xs_recheck_itup, currPartOid);
|
||||
tbm_handler._add_tuples(tbm, heapTid, 1, scan->xs_recheck_itup, currPartOid, InvalidBktId);
|
||||
ntids++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2746,7 +2746,7 @@ static BufferDesc *BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumbe
|
|||
/* Pin the buffer and then release the buffer spinlock */
|
||||
PinBuffer_Locked(buf);
|
||||
|
||||
if (!SSPageCheckIfCanEliminate(buf)) {
|
||||
if (!SSHelpFlushBufferIfNeed(buf)) {
|
||||
// for dms this page cannot eliminate, get another one
|
||||
UnpinBuffer(buf, true);
|
||||
continue;
|
||||
|
|
@ -6350,6 +6350,7 @@ void CheckIOState(volatile void *buf_desc)
|
|||
bool StartBufferIO(BufferDesc *buf, bool for_input)
|
||||
{
|
||||
uint32 buf_state;
|
||||
bool dms_need_flush = false; // used in dms
|
||||
|
||||
Assert(!t_thrd.storage_cxt.InProgressBuf);
|
||||
|
||||
|
|
@ -6390,8 +6391,15 @@ bool StartBufferIO(BufferDesc *buf, bool for_input)
|
|||
WaitIO(buf);
|
||||
}
|
||||
|
||||
if (ENABLE_DMS) {
|
||||
dms_buf_ctrl_t *buf_ctrl = GetDmsBufCtrl(buf->buf_id);
|
||||
if (buf_ctrl->state & BUF_DIRTY_NEED_FLUSH) {
|
||||
dms_need_flush = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Once we get here, there is definitely no I/O active on this buffer */
|
||||
if (for_input ? (buf_state & BM_VALID) : !(buf_state & BM_DIRTY)) {
|
||||
if (for_input ? (buf_state & BM_VALID) : !(buf_state & BM_DIRTY) && !dms_need_flush) {
|
||||
/* someone else already did the I/O */
|
||||
UnlockBufHdr(buf, buf_state);
|
||||
LWLockRelease(buf->io_in_progress_lock);
|
||||
|
|
@ -6483,6 +6491,23 @@ static void TerminateBufferIO_common(BufferDesc *buf, bool clear_dirty, uint32 s
|
|||
if (ENABLE_INCRE_CKPT) {
|
||||
if (!XLogRecPtrIsInvalid(pg_atomic_read_u64(&buf->extra->rec_lsn))) {
|
||||
remove_dirty_page_from_queue(buf);
|
||||
} else if (ENABLE_DMS) {
|
||||
dms_buf_ctrl_t *buf_ctrl = GetDmsBufCtrl(buf->buf_id);
|
||||
if (!(buf_ctrl->state & BUF_DIRTY_NEED_FLUSH)) {
|
||||
ereport(PANIC, (errmodule(MOD_INCRE_CKPT), errcode(ERRCODE_INVALID_BUFFER),
|
||||
(errmsg("buffer is dirty but not in dirty page queue in TerminateBufferIO_common"))));
|
||||
}
|
||||
buf_ctrl->state &= ~BUF_DIRTY_NEED_FLUSH;
|
||||
XLogRecPtr pagelsn = BufferGetLSN(buf);
|
||||
bool in_flush_copy = SS_IN_FLUSHCOPY;
|
||||
bool in_recovery = !g_instance.dms_cxt.SSRecoveryInfo.recovery_pause_flag;
|
||||
ereport(LOG,
|
||||
(errmsg("[SS flush copy] finish flush buffer with need flush, "
|
||||
"spc/db/rel/bucket fork-block: %u/%u/%u/%d %d-%u, page lsn (0x%llx), seg info:%u-%u, reform phase "
|
||||
"is in flush_copy:%d, in recovery:%d",
|
||||
buf->tag.rnode.spcNode, buf->tag.rnode.dbNode, buf->tag.rnode.relNode, buf->tag.rnode.bucketNode,
|
||||
buf->tag.forkNum, buf->tag.blockNum, (unsigned long long)pagelsn,
|
||||
(unsigned int)buf->extra->seg_fileno, buf->extra->seg_blockno, in_flush_copy, in_recovery)));
|
||||
} else {
|
||||
ereport(PANIC, (errmodule(MOD_INCRE_CKPT), errcode(ERRCODE_INVALID_BUFFER),
|
||||
(errmsg("buffer is dirty but not in dirty page queue in TerminateBufferIO_common"))));
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ void AbortSegBufferIO(void)
|
|||
static bool SegStartBufferIO(BufferDesc *buf, bool forInput)
|
||||
{
|
||||
uint32 buf_state;
|
||||
bool dms_need_flush = false; // used in dms
|
||||
|
||||
SegmentCheck(!InProgressBuf);
|
||||
|
||||
|
|
@ -98,7 +99,14 @@ static bool SegStartBufferIO(BufferDesc *buf, bool forInput)
|
|||
WaitIO(buf);
|
||||
}
|
||||
|
||||
if (forInput ? (buf_state & BM_VALID) : !(buf_state & BM_DIRTY)) {
|
||||
if (ENABLE_DMS) {
|
||||
dms_buf_ctrl_t *buf_ctrl = GetDmsBufCtrl(buf->buf_id);
|
||||
if (buf_ctrl->state & BUF_DIRTY_NEED_FLUSH) {
|
||||
dms_need_flush = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (forInput ? (buf_state & BM_VALID) : !(buf_state & BM_DIRTY) && !dms_need_flush) {
|
||||
/* IO finished */
|
||||
UnlockBufHdr(buf, buf_state);
|
||||
LWLockRelease(buf->io_in_progress_lock);
|
||||
|
|
@ -128,6 +136,23 @@ void SegTerminateBufferIO(BufferDesc *buf, bool clear_dirty, uint32 set_flag_bit
|
|||
if (ENABLE_INCRE_CKPT) {
|
||||
if (!XLogRecPtrIsInvalid(pg_atomic_read_u64(&buf->extra->rec_lsn))) {
|
||||
remove_dirty_page_from_queue(buf);
|
||||
} else if (ENABLE_DMS) {
|
||||
dms_buf_ctrl_t *buf_ctrl = GetDmsBufCtrl(buf->buf_id);
|
||||
if (!(buf_ctrl->state & BUF_DIRTY_NEED_FLUSH)) {
|
||||
ereport(PANIC, (errmodule(MOD_INCRE_CKPT), errcode(ERRCODE_INVALID_BUFFER),
|
||||
(errmsg("buffer is dirty but not in dirty page queue in SegTerminateBufferIO"))));
|
||||
}
|
||||
buf_ctrl->state &= ~BUF_DIRTY_NEED_FLUSH;
|
||||
XLogRecPtr pagelsn = BufferGetLSN(buf);
|
||||
bool in_flush_copy = SS_IN_FLUSHCOPY;
|
||||
bool in_recovery = !g_instance.dms_cxt.SSRecoveryInfo.recovery_pause_flag;
|
||||
ereport(LOG,
|
||||
(errmsg("[SS flush copy] finish seg flush buffer with need flush, "
|
||||
"spc/db/rel/bucket fork-block: %u/%u/%u/%d %d-%u, page lsn (0x%llx), seg info:%u-%u, reform phase "
|
||||
"is in flush_copy:%d, in recovery:%d",
|
||||
buf->tag.rnode.spcNode, buf->tag.rnode.dbNode, buf->tag.rnode.relNode, buf->tag.rnode.bucketNode,
|
||||
buf->tag.forkNum, buf->tag.blockNum, (unsigned long long)pagelsn,
|
||||
(unsigned int)buf->extra->seg_fileno, buf->extra->seg_blockno, in_flush_copy, in_recovery)));
|
||||
} else {
|
||||
ereport(PANIC, (errmodule(MOD_INCRE_CKPT), errcode(ERRCODE_INVALID_BUFFER),
|
||||
(errmsg("buffer is dirty but not in dirty page queue in TerminateBufferIO_common"))));
|
||||
|
|
@ -704,7 +729,7 @@ BufferDesc *SegBufferAlloc(SegSpace *spc, RelFileNode rnode, ForkNumber forkNum,
|
|||
|
||||
SegPinBufferLocked(buf, &new_tag);
|
||||
|
||||
if (!SSPageCheckIfCanEliminate(buf)) {
|
||||
if (!SSHelpFlushBufferIfNeed(buf)) {
|
||||
SegUnpinBuffer(buf);
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -286,7 +286,13 @@ typedef struct st_dms_buf_ctrl {
|
|||
unsigned char seg_fileno;
|
||||
unsigned int seg_blockno;
|
||||
#endif
|
||||
}dms_buf_ctrl_t;
|
||||
} dms_buf_ctrl_t;
|
||||
|
||||
typedef struct st_dms_ctrl_info {
|
||||
dms_buf_ctrl_t ctrl;
|
||||
unsigned long long lsn;
|
||||
unsigned char is_dirty;
|
||||
} dms_ctrl_info_t;
|
||||
|
||||
typedef enum en_dms_page_latch_mode {
|
||||
DMS_PAGE_LATCH_MODE_S = 1,
|
||||
|
|
@ -301,7 +307,7 @@ typedef enum en_dms_page_latch_mode {
|
|||
#define DMS_ENTER_PAGE_TRY (unsigned char)8 // try to read from buffer, don't read from disk
|
||||
#define DMS_ENTER_PAGE_LRU_STATS_SCAN (unsigned char)0x10 // add to stats LRU list
|
||||
#define DMS_ENTER_PAGE_LRU_HIGH_AGE (unsigned char)0x20 // decrease possibility to be recycled of page
|
||||
#define DMS_ENTER_PAGE_LOCAL (unsigned char)0x40 // check local page without redo log
|
||||
#define DMS_ENTER_PAGE_LOCAL (unsigned char)0x40 // check local page without redo log, use carefully
|
||||
#define DMS_ENTER_PAGE_REMOTE (unsigned char)0x80 // remote access mode
|
||||
|
||||
// pack read page parameters together
|
||||
|
|
@ -486,6 +492,7 @@ typedef int(*dms_confirm_converting)(void *db_handle, char *pageid, unsigned cha
|
|||
typedef int(*dms_confirm_owner)(void *db_handle, char *pageid, unsigned char *lock_mode, unsigned char *is_edp,
|
||||
unsigned long long *lsn);
|
||||
typedef int(*dms_flush_copy)(void *db_handle, char *pageid);
|
||||
typedef int(*dms_need_flush)(void *db_handle, char *pageid);
|
||||
typedef int(*dms_edp_lsn)(void *db_handle, char *pageid, unsigned long long *lsn);
|
||||
typedef int(*dms_disk_lsn)(void *db_handle, char *pageid, unsigned long long *lsn);
|
||||
typedef int(*dms_recovery)(void *db_handle, void *recovery_list, int is_reformer);
|
||||
|
|
@ -573,7 +580,8 @@ typedef char *(*dms_display_pageid)(char *display_buf, unsigned int count, char
|
|||
typedef char *(*dms_display_xid)(char *display_buf, unsigned int count, char *xid);
|
||||
typedef char *(*dms_display_rowid)(char *display_buf, unsigned int count, char *rowid);
|
||||
typedef int (*dms_drc_buf_res_rebuild)(void *db_handle);
|
||||
typedef int (*dms_drc_buf_res_rebuild_parallel)(void *db_handle, unsigned char thread_index, unsigned char thread_num);
|
||||
typedef int (*dms_drc_buf_res_rebuild_parallel)(void *db_handle, unsigned char thread_index, unsigned char thread_num,
|
||||
unsigned char for_rebuild);
|
||||
typedef unsigned char(*dms_ckpt_session)(void *db_handle);
|
||||
typedef void (*dms_check_if_build_complete)(void *db_handle, unsigned int *build_complete);
|
||||
typedef int (*dms_db_is_primary)(void *db_handle);
|
||||
|
|
@ -622,6 +630,7 @@ typedef struct st_dms_callback {
|
|||
dms_confirm_owner confirm_owner;
|
||||
dms_confirm_converting confirm_converting;
|
||||
dms_flush_copy flush_copy;
|
||||
dms_need_flush need_flush;
|
||||
dms_edp_lsn edp_lsn;
|
||||
dms_disk_lsn disk_lsn;
|
||||
dms_recovery recovery;
|
||||
|
|
@ -803,7 +812,7 @@ typedef struct st_logger_param {
|
|||
#define DMS_LOCAL_MINOR_VER_WEIGHT 1000
|
||||
#define DMS_LOCAL_MAJOR_VERSION 0
|
||||
#define DMS_LOCAL_MINOR_VERSION 0
|
||||
#define DMS_LOCAL_VERSION 52
|
||||
#define DMS_LOCAL_VERSION 54
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,5 +77,6 @@ void BufValidateDrc(BufferDesc *buf_desc);
|
|||
bool SSPageCheckIfCanEliminate(BufferDesc* buf_desc);
|
||||
bool SSSegRead(SMgrRelation reln, ForkNumber forknum, char *buffer);
|
||||
bool DmsCheckBufAccessible();
|
||||
bool SSHelpFlushBufferIfNeed(BufferDesc* buf_desc);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@
|
|||
|
||||
#define RECOVERY_WAIT_TIME 10000
|
||||
#define SSFAILOVER_TRIGGER (ENABLE_DMS && g_instance.dms_cxt.SSRecoveryInfo.failover_triggered == true)
|
||||
#define SSSKIP_REDO_REPLAY (ENABLE_DMS && g_instance.dms_cxt.SSRecoveryInfo.skip_redo_replay == true)
|
||||
#define SS_BEFORE_RECOVERY (ENABLE_DMS && g_instance.dms_cxt.SSReformInfo.in_reform == true \
|
||||
&& g_instance.dms_cxt.SSRecoveryInfo.recovery_pause_flag == true)
|
||||
#define SS_IN_FAILOVER (ENABLE_DMS && g_instance.dms_cxt.SSRecoveryInfo.in_failover == true)
|
||||
|
|
@ -50,7 +49,6 @@ typedef struct ss_recovery_info {
|
|||
bool recovery_pause_flag;
|
||||
volatile bool failover_triggered;
|
||||
char recovery_xlogDir[MAXPGPATH];
|
||||
bool skip_redo_replay;
|
||||
LWLock* update_seg_lock;
|
||||
bool new_primary_reset_walbuf_flag;
|
||||
bool ready_to_startup; // when DB start (except failover), the flag will set true
|
||||
|
|
@ -68,7 +66,7 @@ extern int SSGetPrimaryInstId();
|
|||
extern void SSSavePrimaryInstId(int id);
|
||||
extern void SSReadControlFile(int id, bool updateDmsCtx = false);
|
||||
extern void SSWriteReformerControlPages(void);
|
||||
extern bool SSRecoveryApplyDelay(const XLogReaderState *record);
|
||||
extern bool SSRecoveryApplyDelay();
|
||||
extern void SShandle_promote_signal();
|
||||
extern void SSTriggerFailover();
|
||||
extern void ss_failover_dw_init();
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#define BAK_CTRL_FILE_NUM 2
|
||||
#define BIT_NUM_INT32 32
|
||||
#define REFORM_WAIT_TIME 10000 /* 0.01 sec */
|
||||
#define REFORM_WAIT_LONG 100000 /* 0.1 sec */
|
||||
#define WAIT_REFORM_CTRL_REFRESH_TRIES 1000
|
||||
|
||||
typedef struct SSBroadcastCancelTrx {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -28,8 +28,8 @@
|
|||
* Actual bitmap representation is private to tidbitmap.c. Callers can
|
||||
* do IsA(x, TIDBitmap) on it, but nothing else.
|
||||
*/
|
||||
typedef struct TIDBitmap TIDBitmap;
|
||||
|
||||
typedef struct TIDBitmap TIDBitmap;
|
||||
/* Likewise, TBMIterator is private */
|
||||
typedef struct TBMIterator TBMIterator;
|
||||
|
||||
|
|
@ -44,27 +44,47 @@ typedef struct {
|
|||
OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER];
|
||||
} TBMIterateResult;
|
||||
|
||||
/*
|
||||
* We want the caller to choose between their own best hash between
|
||||
* dynamic hash and a more cache-friendly simple simple hash table.
|
||||
* Therefore a set of handler is required to avoid all kinds of
|
||||
* unnecessary branches inside this performance-critical area.
|
||||
*
|
||||
* All handlers defined here can be templated base on the hash
|
||||
* table the caller used.And the caller can invoke the handler
|
||||
* with little to no overheads.
|
||||
*
|
||||
* Most of external use of tbm related functions are exposed by
|
||||
* this handler interface.Some of others like tbm_oterate does
|
||||
* not templated like handlers are not included.
|
||||
*/
|
||||
typedef struct TMBHandler {
|
||||
/* page generic handlers */
|
||||
void (*_add_tuples)(TIDBitmap*, const ItemPointer, int, bool, Oid, int2);
|
||||
void (*_add_page)(TIDBitmap*, BlockNumber, Oid, int2);
|
||||
|
||||
/* page operator handlers */
|
||||
void (*_union)(TIDBitmap*, const TIDBitmap*);
|
||||
void (*_intersect)(TIDBitmap*, const TIDBitmap*);
|
||||
|
||||
/* iterator handlers */
|
||||
TBMIterator* (*_begin_iterate)(TIDBitmap*);
|
||||
} TBMHandler;
|
||||
|
||||
/* function prototypes in nodes/tidbitmap.c */
|
||||
extern TIDBitmap* TbmCreate(long maxbytes, bool is_ustore = false);
|
||||
extern TIDBitmap* tbm_create(long maxbytes, bool is_global_part = true, bool is_crossbucket =true, bool is_ustore = false);
|
||||
extern void tbm_free(TIDBitmap* tbm);
|
||||
extern long tbm_calculate_entries(double maxbytes);
|
||||
extern long tbm_calculate_entries(double maxbytes, bool complex_key);
|
||||
|
||||
extern void tbm_add_tuples(
|
||||
TIDBitmap* tbm, const ItemPointer tids, int ntids, bool recheck, Oid partitionOid = InvalidOid,
|
||||
int2 bucketid = InvalidBktId);
|
||||
extern void tbm_add_page(TIDBitmap* tbm, BlockNumber pageno, Oid partitionOid = InvalidOid,
|
||||
int2 bucketid = InvalidBktId);
|
||||
|
||||
extern void tbm_union(TIDBitmap* a, const TIDBitmap* b);
|
||||
extern void tbm_intersect(TIDBitmap* a, const TIDBitmap* b);
|
||||
|
||||
extern bool tbm_is_empty(const TIDBitmap* tbm);
|
||||
|
||||
extern TBMIterator* tbm_begin_iterate(TIDBitmap* tbm);
|
||||
/* iterator prototypes in nodes/tidbitmap.c */
|
||||
extern TBMIterateResult* tbm_iterate(TBMIterator* iterator);
|
||||
extern void tbm_end_iterate(TBMIterator* iterator);
|
||||
|
||||
/* function prototypes for TIDBitmap member checks */
|
||||
extern void tbm_set_global(TIDBitmap* tbm, bool val);
|
||||
extern bool tbm_is_global(const TIDBitmap* tbm);
|
||||
extern void tbm_set_global(TIDBitmap* tbm, bool isGlobal);
|
||||
extern bool tbm_is_empty(const TIDBitmap* tbm);
|
||||
extern bool tbm_is_crossbucket(const TIDBitmap* tbm);
|
||||
extern void tbm_set_crossbucket(TIDBitmap* tbm, bool crossbucket);
|
||||
extern TBMHandler tbm_get_handler(TIDBitmap* tbm);
|
||||
|
||||
#endif /* TIDBITMAP_H */
|
||||
|
|
|
|||
|
|
@ -129,6 +129,21 @@ static inline int pg_rightmost_one_pos64(uint64 word)
|
|||
#endif /* HAVE__BUILTIN_CTZ */
|
||||
}
|
||||
|
||||
static inline uint64 pg_nextpower2_64(uint64 num)
|
||||
{
|
||||
Assert(num > 0 && num <= PG_UINT64_MAX / 2 + 1);
|
||||
|
||||
/*
|
||||
* A power 2 number has only 1 bit set. Subtracting 1 from such a number
|
||||
* will turn on all previous bits resulting in no common bits being set
|
||||
* between num and num-1.
|
||||
*/
|
||||
if ((num & (num - 1)) == 0)
|
||||
return num; /* already power 2 */
|
||||
|
||||
return ((uint64) 1) << (pg_leftmost_one_pos64(num) + 1);
|
||||
}
|
||||
|
||||
/* Count the number of one-bits in a uint32 or uint64 */
|
||||
extern int (*pg_popcount32)(uint32 word);
|
||||
extern int (*pg_popcount64)(uint64 word);
|
||||
|
|
|
|||
|
|
@ -42,4 +42,10 @@ static inline uint32 murmurhash32(uint32 data)
|
|||
return h;
|
||||
}
|
||||
|
||||
static inline uint32 hash_combine(uint32 a, uint32 b)
|
||||
{
|
||||
a ^= b + 0x9e3779b9 + (a << 6) + (a >> 2);
|
||||
return a;
|
||||
}
|
||||
|
||||
#endif /* HASHUTILS_H */
|
||||
|
|
|
|||
|
|
@ -72,6 +72,8 @@ extern THR_LOCAL PGDLLIMPORT MemoryContext TopMemoryContext;
|
|||
#define MemoryContextAllocZero(context, size) MemoryContextAllocZeroDebug(context, size, __FILE__, __LINE__)
|
||||
#define MemoryContextAllocZeroAligned(context, size) \
|
||||
MemoryContextAllocZeroAlignedDebug(context, size, __FILE__, __LINE__)
|
||||
#define MemoryContextAllocExtended(context, size, flags) \
|
||||
MemoryContextAllocExtendedDebug(context, size, flags, __FILE__, __LINE__)
|
||||
#define MemoryContextStrdup(context, size) MemoryContextStrdupDebug(context, size, __FILE__, __LINE__)
|
||||
#define repalloc(pointer, size) repallocDebug(pointer, size, __FILE__, __LINE__)
|
||||
#define repalloc_noexcept(pointer, size) repalloc_noexcept_Debug(pointer, size, __FILE__, __LINE__)
|
||||
|
|
@ -90,6 +92,7 @@ extern void* MemoryContextAllocHugeDebug(MemoryContext context, Size size, const
|
|||
extern void* repallocHugeDebug(void* pointer, Size size, const char* file, int line);
|
||||
extern void* MemoryContextAllocZeroDebug(MemoryContext context, Size size, const char* file, int line);
|
||||
extern void* MemoryContextAllocZeroAlignedDebug(MemoryContext context, Size size, const char* file, int line);
|
||||
extern void* MemoryContextAllocExtendedDebug(MemoryContext context, Size size, int flags, const char* file, int line);
|
||||
extern char* MemoryContextStrdupDebug(MemoryContext context, const char* string, const char* file, int line);
|
||||
extern void* MemoryContextMemalignAllocDebug(MemoryContext context, Size align, Size size, const char* file, int line);
|
||||
extern void MemoryContextMemalignFree(MemoryContext context, void* pointer);
|
||||
|
|
|
|||
|
|
@ -36,4 +36,20 @@ CREATE TABLE CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_5
|
|||
ID NUMBER(20) not null,
|
||||
VARCHAR2_1 VARCHAR2(40)
|
||||
)with(INIT_TD=10,STORAGE_TYPE=USTORE);
|
||||
DROP SCHEMA CREATE_TBL_INIT_TD_CHECK;
|
||||
|
||||
set enable_default_ustore_table = on;
|
||||
DROP TABLE IF EXISTS CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_7;
|
||||
CREATE TABLE CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_7
|
||||
(
|
||||
ID NUMBER(20) not null,
|
||||
VARCHAR2_1 VARCHAR2(40)
|
||||
)with(INIT_TD=10);
|
||||
|
||||
set enable_default_ustore_table = off;
|
||||
DROP TABLE IF EXISTS CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_6;
|
||||
CREATE TABLE CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_6
|
||||
(
|
||||
ID NUMBER(20) not null,
|
||||
VARCHAR2_1 VARCHAR2(40)
|
||||
)with(INIT_TD=10);
|
||||
DROP SCHEMA CREATE_TBL_INIT_TD_CHECK CASCADE;
|
||||
|
|
@ -25,6 +25,7 @@ EXPLAIN (analyze on, costs off, timing off) SELECT count(*) FROM bmscantest WHER
|
|||
Aggregate (actual rows=1 loops=1)
|
||||
-> Bitmap Heap Scan on bmscantest (actual rows=20 loops=1)
|
||||
Recheck Cond: ((b = 1) AND (a = 1))
|
||||
Rows Removed by Index Recheck: 1257
|
||||
--? Heap Blocks: exact=.*
|
||||
-> BitmapAnd (actual rows=0 loops=1)
|
||||
-> Bitmap Index Scan on i_bmtest_b (actual rows=1051 loops=1)
|
||||
|
|
@ -32,7 +33,7 @@ EXPLAIN (analyze on, costs off, timing off) SELECT count(*) FROM bmscantest WHER
|
|||
-> Bitmap Index Scan on i_bmtest_a (actual rows=1170 loops=1)
|
||||
Index Cond: (a = 1)
|
||||
--?.*
|
||||
(10 rows)
|
||||
(11 rows)
|
||||
|
||||
SELECT count(*) FROM bmscantest WHERE a = 1 AND b = 1;
|
||||
count
|
||||
|
|
@ -47,7 +48,7 @@ EXPLAIN (analyze on, costs off, timing off) SELECT count(*) FROM bmscantest WHER
|
|||
Aggregate (actual rows=1 loops=1)
|
||||
-> Bitmap Heap Scan on bmscantest (actual rows=2201 loops=1)
|
||||
Recheck Cond: ((a = 1) OR (b = 1))
|
||||
Rows Removed by Index Recheck: 14419
|
||||
Rows Removed by Index Recheck: 17287
|
||||
--? Heap Blocks: exact=.* lossy=.*
|
||||
-> BitmapOr (actual rows=0 loops=1)
|
||||
-> Bitmap Index Scan on i_bmtest_a (actual rows=1170 loops=1)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
-- A typical wrong case
|
||||
CREATE SCHEMA CREATE_TBL_INIT_TD_CHECK;
|
||||
DROP TABLE IF EXISTS CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_1;
|
||||
--?.*
|
||||
NOTICE: table "t_init_td_1" does not exist, skipping
|
||||
CREATE TABLE CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_1
|
||||
(
|
||||
ID NUMBER(20) NOT NULL,
|
||||
|
|
@ -10,7 +10,7 @@ VARCHAR2_1 VARCHAR2(40)
|
|||
ERROR: Un-support feature
|
||||
DETAIL: Forbid to set option "init_td" for relations except for ustore relation
|
||||
DROP TABLE IF EXISTS CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_2;
|
||||
--?.*
|
||||
NOTICE: table "t_init_td_2" does not exist, skipping
|
||||
CREATE TABLE CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_2
|
||||
(
|
||||
ID NUMBER(20) NOT NULL,
|
||||
|
|
@ -19,7 +19,7 @@ VARCHAR2_1 VARCHAR2(40)
|
|||
ERROR: Un-support feature
|
||||
DETAIL: Forbid to set option "init_td" for relations except for ustore relation
|
||||
DROP TABLE IF EXISTS CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_3;
|
||||
--?.*
|
||||
NOTICE: table "t_init_td_3" does not exist, skipping
|
||||
CREATE TABLE CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_3
|
||||
(
|
||||
ID NUMBER(20) NOT NULL,
|
||||
|
|
@ -29,21 +29,39 @@ ERROR: Un-support feature
|
|||
DETAIL: Forbid to set option "init_td" for relations except for ustore relation
|
||||
-- right cases
|
||||
DROP TABLE IF EXISTS CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_4;
|
||||
--?.*
|
||||
NOTICE: table "t_init_td_4" does not exist, skipping
|
||||
CREATE TABLE CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_4
|
||||
(
|
||||
ID NUMBER(20) NOT NULL,
|
||||
VARCHAR2_1 VARCHAR2(40)
|
||||
)WITH(ORIENTATION=ROW,STORAGE_TYPE=USTORE, INIT_TD=10);
|
||||
DROP TABLE IF EXISTS CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_5;
|
||||
--?.*
|
||||
NOTICE: table "t_init_td_5" does not exist, skipping
|
||||
CREATE TABLE CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_5
|
||||
(
|
||||
ID NUMBER(20) not null,
|
||||
VARCHAR2_1 VARCHAR2(40)
|
||||
)with(INIT_TD=10,STORAGE_TYPE=USTORE);
|
||||
DROP SCHEMA CREATE_TBL_INIT_TD_CHECK;
|
||||
ERROR: cannot drop schema create_tbl_init_td_check because other objects depend on it
|
||||
DETAIL: table create_tbl_init_td_check.t_init_td_4 depends on schema create_tbl_init_td_check
|
||||
table create_tbl_init_td_check.t_init_td_5 depends on schema create_tbl_init_td_check
|
||||
HINT: Use DROP ... CASCADE to drop the dependent objects too.
|
||||
set enable_default_ustore_table = on;
|
||||
DROP TABLE IF EXISTS CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_7;
|
||||
NOTICE: table "t_init_td_7" does not exist, skipping
|
||||
CREATE TABLE CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_7
|
||||
(
|
||||
ID NUMBER(20) not null,
|
||||
VARCHAR2_1 VARCHAR2(40)
|
||||
)with(INIT_TD=10);
|
||||
set enable_default_ustore_table = off;
|
||||
DROP TABLE IF EXISTS CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_6;
|
||||
NOTICE: table "t_init_td_6" does not exist, skipping
|
||||
CREATE TABLE CREATE_TBL_INIT_TD_CHECK.T_INIT_TD_6
|
||||
(
|
||||
ID NUMBER(20) not null,
|
||||
VARCHAR2_1 VARCHAR2(40)
|
||||
)with(INIT_TD=10);
|
||||
ERROR: Un-support feature
|
||||
DETAIL: Forbid to set option "init_td" for relations except for ustore relation
|
||||
DROP SCHEMA CREATE_TBL_INIT_TD_CHECK CASCADE;
|
||||
NOTICE: drop cascades to 3 other objects
|
||||
DETAIL: drop cascades to table create_tbl_init_td_check.t_init_td_4
|
||||
drop cascades to table create_tbl_init_td_check.t_init_td_5
|
||||
drop cascades to table create_tbl_init_td_check.t_init_td_7
|
||||
|
|
|
|||
|
|
@ -1479,6 +1479,9 @@ SERIALIZABLEXIDTAG
|
|||
SERVICE_STATUS
|
||||
SERVICE_STATUS_HANDLE
|
||||
SERVICE_TABLE_ENTRY
|
||||
SH_TYPE
|
||||
SH_ITERATOR
|
||||
SH_STATUS
|
||||
SHA1_CTX
|
||||
SHA224_CTX
|
||||
SHA256_CTX
|
||||
|
|
|
|||
Loading…
Reference in New Issue