mirror of https://github.com/citusdata/citus.git
Fix hang
parent
40664743e6
commit
c40761f07c
|
@ -15,12 +15,14 @@
|
|||
#include "access/genam.h"
|
||||
#include "access/xact.h"
|
||||
#include "catalog/namespace.h"
|
||||
#include "commands/dbcommands.h"
|
||||
#include "commands/sequence.h"
|
||||
#include "postmaster/postmaster.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/fmgroids.h"
|
||||
|
||||
#include "distributed/citus_safe_lib.h"
|
||||
#include "distributed/listutils.h"
|
||||
#include "distributed/coordinator_protocol.h"
|
||||
#include "distributed/metadata_cache.h"
|
||||
|
@ -657,17 +659,35 @@ GetNextOperationId()
|
|||
return operationdId;
|
||||
}
|
||||
|
||||
/* token location, or -1 if unknown */
|
||||
const int location = -1;
|
||||
RangeVar *sequenceName = makeRangeVar(PG_CATALOG,
|
||||
OPERATIONID_SEQUENCE_NAME,
|
||||
location);
|
||||
/* Generate sequence using a subtransaction. else we can hold replication slot creation for operations */
|
||||
StringInfo nextValueCommand = makeStringInfo();
|
||||
appendStringInfo(nextValueCommand, "SELECT nextval(%s);", OPERATIONID_SEQUENCE_NAME);
|
||||
|
||||
bool missingOK = false;
|
||||
Oid sequenceId = RangeVarGetRelid(sequenceName, NoLock, missingOK);
|
||||
int connectionFlag = FORCE_NEW_CONNECTION;
|
||||
MultiConnection *connection = GetNodeUserDatabaseConnection(connectionFlag,
|
||||
LocalHostName,
|
||||
PostPortNumber,
|
||||
CitusExtensionOwnerName(),
|
||||
get_database_name(
|
||||
MyDatabaseId));
|
||||
|
||||
bool checkPermissions = false;
|
||||
operationdId = nextval_internal(sequenceId, checkPermissions);
|
||||
PGresult *result = NULL;
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#include "postmaster/postmaster.h"
|
||||
|
||||
/* declarations for dynamic loading */
|
||||
bool DeferShardDeleteOnSplit = false;
|
||||
bool DeferShardDeleteOnSplit = true;
|
||||
|
||||
/*
|
||||
* Entry for map that tracks ShardInterval -> Placement Node
|
||||
|
|
Loading…
Reference in New Issue