niupre/TestDeferredDropAndCleanup
Nitish Upreti 2022-08-31 10:12:30 -07:00
parent 40664743e6
commit c40761f07c
2 changed files with 30 additions and 10 deletions

View File

@ -15,12 +15,14 @@
#include "access/genam.h" #include "access/genam.h"
#include "access/xact.h" #include "access/xact.h"
#include "catalog/namespace.h" #include "catalog/namespace.h"
#include "commands/dbcommands.h"
#include "commands/sequence.h" #include "commands/sequence.h"
#include "postmaster/postmaster.h" #include "postmaster/postmaster.h"
#include "nodes/makefuncs.h" #include "nodes/makefuncs.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/fmgroids.h" #include "utils/fmgroids.h"
#include "distributed/citus_safe_lib.h"
#include "distributed/listutils.h" #include "distributed/listutils.h"
#include "distributed/coordinator_protocol.h" #include "distributed/coordinator_protocol.h"
#include "distributed/metadata_cache.h" #include "distributed/metadata_cache.h"
@ -657,17 +659,35 @@ GetNextOperationId()
return operationdId; return operationdId;
} }
/* token location, or -1 if unknown */ /* Generate sequence using a subtransaction. else we can hold replication slot creation for operations */
const int location = -1; StringInfo nextValueCommand = makeStringInfo();
RangeVar *sequenceName = makeRangeVar(PG_CATALOG, appendStringInfo(nextValueCommand, "SELECT nextval(%s);", OPERATIONID_SEQUENCE_NAME);
OPERATIONID_SEQUENCE_NAME,
location);
bool missingOK = false; int connectionFlag = FORCE_NEW_CONNECTION;
Oid sequenceId = RangeVarGetRelid(sequenceName, NoLock, missingOK); MultiConnection *connection = GetNodeUserDatabaseConnection(connectionFlag,
LocalHostName,
PostPortNumber,
CitusExtensionOwnerName(),
get_database_name(
MyDatabaseId));
bool checkPermissions = false; PGresult *result = NULL;
operationdId = nextval_internal(sequenceId, checkPermissions); int queryResult = ExecuteOptionalRemoteCommand(connection, nextValueCommand->data,
&result);
if (queryResult != RESPONSE_OKAY || !IsResponseOK(result) || PQntuples(result) != 1 ||
PQnfields(result) != 1)
{
PQclear(result);
ForgetResults(connection);
CloseConnection(connection);
ereport(ERROR, (errcode(ERRCODE_CONNECTION_FAILURE),
errmsg(
"Could not generate next operation id while executing shard splits.")));
}
operationdId = SafeStringToUint64(PQgetvalue(result, 0, 0 /* nodeId column*/));
CloseConnection(connection);
return operationdId; return operationdId;
} }

View File

@ -47,7 +47,7 @@
#include "postmaster/postmaster.h" #include "postmaster/postmaster.h"
/* declarations for dynamic loading */ /* declarations for dynamic loading */
bool DeferShardDeleteOnSplit = false; bool DeferShardDeleteOnSplit = true;
/* /*
* Entry for map that tracks ShardInterval -> Placement Node * Entry for map that tracks ShardInterval -> Placement Node