Skip to content

Commit 2cb2913

Browse files
committed
42/161 drop temp index
1 parent 8937e40 commit 2cb2913

File tree

4 files changed

+80
-40
lines changed

4 files changed

+80
-40
lines changed

contrib/mmts/multimaster--1.0.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ CREATE FUNCTION mtm.inject_2pc_error(stage integer) RETURNS void
6969
AS 'MODULE_PATHNAME','mtm_inject_2pc_error'
7070
LANGUAGE C;
7171

72-
CREATE TABLE IF NOT EXISTS mtm.ddl_log (issued timestamp with time zone not null, query text);
72+
CREATE TABLE IF NOT EXISTS public.ddl_log (issued timestamp with time zone not null, query text);
7373

7474
CREATE TABLE IF NOT EXISTS mtm.local_tables(rel_schema text, rel_name text, primary key(rel_schema, rel_name));
7575

contrib/mmts/multimaster.c

Lines changed: 75 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
#include "catalog/indexing.h"
5757
#include "catalog/namespace.h"
5858
#include "pglogical_output/hooks.h"
59+
#include "parser/analyze.h"
60+
#include "parser/parse_relation.h"
5961

6062
#include "multimaster.h"
6163
#include "ddd.h"
@@ -148,6 +150,7 @@ static void MtmShmemStartup(void);
148150
static BgwPool* MtmPoolConstructor(void);
149151
static bool MtmRunUtilityStmt(PGconn* conn, char const* sql, char **errmsg);
150152
static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError);
153+
static bool MtmProcessDDLCommand(char const* queryString);
151154

152155
MtmState* Mtm;
153156

@@ -176,7 +179,8 @@ static TransactionManager MtmTM = {
176179
MtmGetTransactionStateSize,
177180
MtmSerializeTransactionState,
178181
MtmDeserializeTransactionState,
179-
MtmInitializeSequence
182+
// MtmInitializeSequence
183+
PgInitializeSequence
180184
};
181185

182186
char const* const MtmNodeStatusMnem[] =
@@ -208,6 +212,8 @@ int MtmHeartbeatRecvTimeout;
208212
bool MtmUseRaftable;
209213
bool MtmUseDtm;
210214

215+
// static int reset_wrokers = 0;
216+
211217
static char* MtmConnStrs;
212218
static int MtmQueueSize;
213219
static int MtmWorkers;
@@ -229,8 +235,8 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
229235
ProcessUtilityContext context, ParamListInfo params,
230236
DestReceiver *dest, char *completionTag);
231237

232-
static StringInfo MtmGUCBuffer;
233-
static bool MtmGUCBufferAllocated = false;
238+
// static StringInfo MtmGUCBuffer;
239+
// static bool MtmGUCBufferAllocated = false;
234240

235241
/*
236242
* -------------------------------------------
@@ -615,7 +621,7 @@ MtmXactCallback(XactEvent event, void *arg)
615621
{
616622
switch (event)
617623
{
618-
case XACT_EVENT_START:
624+
case XACT_EVENT_START:
619625
MtmBeginTransaction(&MtmTx);
620626
break;
621627
case XACT_EVENT_PRE_PREPARE:
@@ -1150,8 +1156,8 @@ void MtmHandleApplyError(void)
11501156
case ERRCODE_OUT_OF_MEMORY:
11511157
elog(WARNING, "Node is excluded from cluster because of non-recoverable error %d, %s, pid=%u",
11521158
edata->sqlerrcode, edata->message, getpid());
1153-
MtmSwitchClusterMode(MTM_OUT_OF_SERVICE);
1154-
kill(PostmasterPid, SIGQUIT);
1159+
// MtmSwitchClusterMode(MTM_OUT_OF_SERVICE);
1160+
// kill(PostmasterPid, SIGQUIT);
11551161
break;
11561162
}
11571163
FreeErrorData(edata);
@@ -2913,13 +2919,13 @@ static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
29132919
{
29142920
if (conns[i])
29152921
{
2916-
if (MtmGUCBufferAllocated && !MtmRunUtilityStmt(conns[i], MtmGUCBuffer->data, &utility_errmsg) && !ignoreError)
2917-
{
2918-
errorMsg = "Failed to set GUC variables at node %d";
2919-
elog(WARNING, "%s", utility_errmsg);
2920-
failedNode = i;
2921-
break;
2922-
}
2922+
// if (MtmGUCBufferAllocated && !MtmRunUtilityStmt(conns[i], MtmGUCBuffer->data, &utility_errmsg) && !ignoreError)
2923+
// {
2924+
// errorMsg = "Failed to set GUC variables at node %d";
2925+
// elog(WARNING, "%s", utility_errmsg);
2926+
// failedNode = i;
2927+
// break;
2928+
// }
29232929
if (!MtmRunUtilityStmt(conns[i], "BEGIN TRANSACTION", &utility_errmsg) && !ignoreError)
29242930
{
29252931
errorMsg = "Failed to start transaction at node %d";
@@ -2983,7 +2989,7 @@ static bool MtmProcessDDLCommand(char const* queryString)
29832989
bool nulls[Natts_mtm_ddl_log];
29842990
TimestampTz ts = GetCurrentTimestamp();
29852991

2986-
rv = makeRangeVar(MULTIMASTER_SCHEMA_NAME, MULTIMASTER_DDL_TABLE, -1);
2992+
rv = makeRangeVar("public", MULTIMASTER_DDL_TABLE, -1);
29872993
rel = heap_openrv_extended(rv, RowExclusiveLock, true);
29882994

29892995
if (rel == NULL) {
@@ -3120,18 +3126,18 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
31203126
break;
31213127
case T_DiscardStmt:
31223128
{
3123-
//DiscardStmt *stmt = (DiscardStmt *) parsetree;
3124-
//skipCommand = stmt->target == DISCARD_TEMP;
3129+
DiscardStmt *stmt = (DiscardStmt *) parsetree;
3130+
skipCommand = stmt->target == DISCARD_TEMP;
31253131

3126-
skipCommand = true;
3132+
// skipCommand = true;
31273133

3128-
if (MtmGUCBufferAllocated)
3129-
{
3130-
// XXX: move allocation somewhere to backend startup and check
3131-
// where buffer is empty in send routines.
3132-
MtmGUCBufferAllocated = false;
3133-
pfree(MtmGUCBuffer);
3134-
}
3134+
// if (MtmGUCBufferAllocated)
3135+
// {
3136+
// // XXX: move allocation somewhere to backend startup and check
3137+
// // where buffer is empty in send routines.
3138+
// MtmGUCBufferAllocated = false;
3139+
// pfree(MtmGUCBuffer);
3140+
// }
31353141

31363142
}
31373143
break;
@@ -3143,22 +3149,31 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
31433149

31443150
/* Prevent SET TRANSACTION from replication */
31453151
if (stmt->kind == VAR_SET_MULTI)
3146-
break;
3152+
// break;
3153+
skipCommand = true;
31473154

3148-
if (!MtmGUCBufferAllocated)
3149-
{
3150-
MemoryContext oldcontext;
3155+
// if (!MtmGUCBufferAllocated)
3156+
// {
3157+
// MemoryContext oldcontext;
31513158

3152-
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
3153-
MtmGUCBuffer = makeStringInfo();
3154-
MemoryContextSwitchTo(oldcontext);
3155-
MtmGUCBufferAllocated = true;
3156-
}
3159+
// oldcontext = MemoryContextSwitchTo(TopMemoryContext);
3160+
// MtmGUCBuffer = makeStringInfo();
3161+
// MemoryContextSwitchTo(oldcontext);
3162+
// MtmGUCBufferAllocated = true;
3163+
// }
31573164

3158-
appendStringInfoString(MtmGUCBuffer, queryString);
3165+
// appendStringInfoString(MtmGUCBuffer, queryString);
31593166

31603167
// sometimes there is no ';' char at the end.
3161-
appendStringInfoString(MtmGUCBuffer, ";");
3168+
// appendStringInfoString(MtmGUCBuffer, ";");
3169+
}
3170+
break;
3171+
case T_CreateTableAsStmt:
3172+
{
3173+
/* Do not replicate temp tables */
3174+
CreateTableAsStmt *stmt = (CreateTableAsStmt *) parsetree;
3175+
skipCommand = stmt->into->rel->relpersistence == RELPERSISTENCE_TEMP ||
3176+
(stmt->into->rel->schemaname && strcmp(stmt->into->rel->schemaname, "pg_temp") == 0);
31623177
}
31633178
break;
31643179
case T_CreateStmt:
@@ -3169,6 +3184,18 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
31693184
(stmt->relation->schemaname && strcmp(stmt->relation->schemaname, "pg_temp") == 0);
31703185
}
31713186
break;
3187+
case T_ViewStmt:
3188+
{
3189+
ViewStmt *stmt = (ViewStmt *) parsetree;
3190+
Query *viewParse;
3191+
3192+
viewParse = parse_analyze((Node *) copyObject(stmt->query),
3193+
queryString, NULL, 0);
3194+
skipCommand = isQueryUsingTempRelation(viewParse);
3195+
// ||
3196+
// (stmt->relation->schemaname && strcmp(stmt->relation->schemaname, "pg_temp") == 0);
3197+
}
3198+
break;
31723199
case T_IndexStmt:
31733200
{
31743201
Oid relid;
@@ -3207,6 +3234,19 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
32073234
heap_close(rel, ShareLock);
32083235
}
32093236
}
3237+
else if (stmt->removeType == OBJECT_INDEX)
3238+
{
3239+
RangeVar *rv = makeRangeVarFromNameList(
3240+
(List *) lfirst(list_head(stmt->objects)));
3241+
Oid relid = RelnameGetRelid(rv->relname);
3242+
3243+
if (OidIsValid(relid))
3244+
{
3245+
Relation irel = index_open(relid, ShareLock);
3246+
skipCommand = irel->rd_rel->relpersistence == RELPERSISTENCE_TEMP;
3247+
index_close(irel, ShareLock);
3248+
}
3249+
}
32103250
}
32113251
break;
32123252
case T_CopyStmt:

contrib/mmts/tests/postgresql.conf.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,11 +641,11 @@
641641
log_checkpoints = on
642642
log_autovacuum_min_duration = 0
643643

644-
multimaster.workers = 4
644+
multimaster.workers = 1
645645
multimaster.use_raftable = true
646646
multimaster.queue_size=52857600
647647
multimaster.ignore_tables_without_pk = 1
648648
multimaster.heartbeat_recv_timeout = 1000
649649
multimaster.heartbeat_send_timeout = 250
650-
multimaster.twopc_min_timeout = 40000
650+
multimaster.twopc_min_timeout = 400000
651651

contrib/mmts/tests/reinit-mm.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ do
4343
pg_ctl -w -D node$i -l node$i.log start
4444
done
4545

46-
# sleep 5
47-
# psql -c "create extension multimaster;" postgres
46+
sleep 10
47+
psql postgres < ../../../regress.sql
4848

4949
echo Done

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy