10000 Non block modify (#9963) · distrubuted/arangodb@3d2952b · GitHub
[go: up one dir, main page]

Skip to content

Commit 3d2952b

Browse files
graetzerjsteemann
authored andcommitted
Non block modify (arangodb#9963)
1 parent 7d53136 commit 3d2952b

18 files changed

+536
-557
lines changed

arangod/Aql/ShortestPathNode.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include "Graph/ShortestPathOptions.h"
3838
#include "Graph/ShortestPathResult.h"
3939
#include "Indexes/Index.h"
40-
#include "Utils/CollectionNameResolver.h"
4140
#include "VocBase/LogicalCollection.h"
4241

4342
#include <velocypack/Iterator.h>

arangod/Cluster/ClusterMethods.cpp

Lines changed: 198 additions & 203 deletions
Large diffs are not rendered by default.

arangod/Cluster/ClusterMethods.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ int selectivityEstimatesOnCoordinator(std::string const& dbname, std::string con
110110

111111
futures::Future<OperationResult> createDocumentOnCoordinator(transaction::Methods const& trx,
112112
LogicalCollection&,
113-
OperationOptions const& options,
114-
VPackSlice slice);
113+
VPackSlice const slice,
114+
OperationOptions const& options);
115115

116116
////////////////////////////////////////////////////////////////////////////////
117117
/// @brief delete a document in a coordinator
@@ -219,12 +219,10 @@ int getFilteredEdgesOnCoordinator(transaction::Methods const& trx,
219219
/// @brief modify a document in a coordinator
220220
////////////////////////////////////////////////////////////////////////////////
221221

222-
int modifyDocumentOnCoordinator(
223-
transaction::Methods& trx, std::string const& collname,
222+
futures::Future<OperationResult> modifyDocumentOnCoordinator(
223+
transaction::Methods& trx, LogicalCollection& coll,
224224
arangodb::velocypack::Slice const& slice, OperationOptions const& options,
225-
bool isPatch, std::unique_ptr<std::unordered_map<std::string, std::string>>& headers,
226-
arangodb::rest::ResponseCode& responseCode, std::unordered_map<int, size_t>& errorCounter,
227-
std::shared_ptr<arangodb::velocypack::Builder>& resultBody);
225+
bool isPatch);
228226

229227
////////////////////////////////////////////////////////////////////////////////
230228
/// @brief truncate a cluster collection on a coordinator

arangod/GeneralServer/VstCommTask.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ bool VstCommTask<T>::readCallback(asio_ns::error_code ec) {
9393
using namespace fuerte;
9494
if (ec) {
9595
if (ec != asio_ns::error::misc_errors::eof) {
96-
LOG_TOPIC("495fe", DEBUG, Logger::REQUESTS)
96+
LOG_TOPIC("495fe", INFO, Logger::REQUESTS)
9797
<< "Error while reading from socket: '" << ec.message() << "'";
9898
}
9999
this->close();
@@ -240,6 +240,13 @@ bool VstCommTask<T>::processMessage(velocypack::Buffer<uint8_t> buffer,
240240
this->_auth->userManager()->refreshUser(this->_authToken._username);
241241
}
242242

243+
LOG_TOPIC("92fd6", DEBUG, Logger::REQUESTS)
244+
<< "\"vst-request-begin\",\"" << (void*)this << "\",\""
245+
<< this->_connectionInfo.clientAddress << "\",\""
246+
<< VstRequest::translateMethod(req->requestType()) << "\",\""
247+
<< (Logger::logRequestParameters() ? req->fullUrl() : req->requestPath())
248+
<< "\"";
249+
243250
CommTask::Flow cont = this->prepareExecution(*req.get());
244251
if (cont == CommTask::Flow::Continue) {
245252
auto resp = std::make_unique<VstResponse>(rest::ResponseCode::SERVER_ERROR, messageId);
@@ -282,9 +289,8 @@ void VstCommTask<T>::sendResponse(std::unique_ptr<GeneralResponse> baseRes, Requ
282289
resItem->metadata, payload,
283290
resItem->buffers);
284291

285-
if (stat != nullptr &&
286-
arangodb::Logger::isEnabled(arangodb::LogLevel::TRACE, Logger::REQUESTS)) {
287-
LOG_TOPIC("cf80d", DEBUG, Logger::REQUESTS)
292+
if (stat != nullptr) {
293+
LOG_TOPIC("cf80d", TRACE, Logger::REQUESTS)
288294
<< "\"vst-request-statistics\",\"" << (void*)this << "\",\""
289295
<< static_cast<int>(response.responseCode()) << ","
290296
<< this->_connectionInfo.clientAddress << "\"," << stat->timingsCsv();
@@ -346,7 +352,7 @@ void VstCommTask<T>::doWrite() {
346352
size_t transferred) {
347353
auto* thisPtr = static_cast<VstCommTask<T>*>(self.get());
348354
if (ec) {
349-
LOG_TOPIC("5c6b4", DEBUG, arangodb::Logger::REQUESTS)
355+
LOG_TOPIC("5c6b4", INFO, arangodb::Logger::REQUESTS)
350356
<< "asio write error: '" << ec.message() << "'";
351357
thisPtr->close();
352358
} else {

arangod/IResearch/IResearchViewCoordinator.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include "RestServer/ViewTypesFeature.h"
4040
#include "Transaction/Methods.h"
4141
#include "Transaction/StandaloneContext.h"
42-
#include "Utils/CollectionNameResolver.h"
4342
#include "Utils/ExecContext.h"
4443
#include "VocBase/LogicalCollection.h"
4544
#include "VocBase/Methods/Indexes.h"

arangod/MMFiles/MMFilesCollection.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
#include "Transaction/Hints.h"
6161
#include "Transaction/Methods.h"
6262
#include "Transaction/StandaloneContext.h"
63-
#include "Utils/CollectionNameResolver.h"
6463
#include "Utils/Events.h"
6564
#include "Utils/OperationOptions.h"
6665
#include "Utils/SingleCollectionTransaction.h"

arangod/MMFiles/MMFilesEdgeIndex.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "Transaction/Context.h"
3737
#include "Transaction/Helpers.h"
3838
#include "Transaction/Methods.h"
39-
#include "Utils/CollectionNameResolver.h"
4039
#include "VocBase/LogicalCollection.h"
4140

4241
#include <velocypack/Iterator.h>

arangod/MMFiles/MMFilesRestReplicationHandler.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include "Transaction/StandaloneContext.h"
4040
#include "Utils/CollectionGuard.h"
4141
#include "Utils/CollectionKeysRepository.h"
42-
#include "Utils/CollectionNameResolver.h"
4342
#include "Utils/ExecContext.h"
4443
#include "Utils/OperationOptions.h"
4544
#include "VocBase/LogicalCollection.h"

arangod/Network/Methods.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ class RequestsState final : public std::enable_shared_from_this<RequestsState> {
254254
}
255255

256256
default: // a "proper error" which has to be returned to the client
257-
TRI_ASSERT(res == nullptr);
258257
callResponse(err, std::move(res));
259258
break;
260259
}

arangod/Network/Utils.cpp

Lines changed: 55 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -92,39 +92,6 @@ int resolveDestination(DestinationId const& dest, std::string& endpoint) {
9292
return TRI_ERROR_NO_ERROR;
9393
}
9494

95-
OperationResult opResultFromBody(arangodb::velocypack::Buffer<uint8_t> const& body,
96-
int defaultErrorCode) {
97-
if (body.size() > 0) {
98-
return opResultFromBody(VPackSlice(body.data()), defaultErrorCode);
99-
}
100-
return OperationResult(defaultErrorCode);
101-
}
102-
103-
OperationResult opResultFromBody(std::shared_ptr<VPackBuilder> const& body, int defaultErrorCode) {
104-
if (body) {
105-
return opResultFromBody(body->slice(), defaultErrorCode);
106-
}
107-
return OperationResult(defaultErrorCode);
108-
}
109-
110-
OperationResult opResultFromBody(VPackSlice body, int defaultErrorCode) {
111-
// read the error number from the response and use it if present
112-
if (body.isObject()) {
113-
VPackSlice num = body.get(StaticStrings::ErrorNum);
114-
VPackSlice msg = body.get(StaticStrings::ErrorMessage);
115-
if (num.isNumber()) {
116-
if (msg.isString()) {
117-
// found an error number and an error message, so let's use it!
118-
return OperationResult(Result(num.getNumericValue<int>(), msg.copyString()));
119-
}
120-
// we found an error number, so let's use it!
121-
return OperationResult(num.getNumericValue<int>());
122-
}
123-
}
124-
125-
return OperationResult(defaultErrorCode);
126-
}
127-
12895
/// @brief extract the error code form the body
12996
int errorCodeFromBody(arangodb::velocypack::Slice body) {
13097
if (body.isObject()) {
@@ -137,6 +104,15 @@ int errorCodeFromBody(arangodb::velocypack::Slice body) {
137104
return TRI_ERROR_ILLEGAL_NUMBER;
138105
}
139106

107+
Result resultFromBody(std::shared_ptr<arangodb::velocypack::Buffer<uint8_t>> const& body,
108+
int defaultError) {
109+
// read the error number from the response and use it if present
110+
if (body && !body->empty()) {
111+
return resultFromBody(VPackSlice(body->data()), defaultError);
112+
}
113+
return Result(defaultError);
114+
}
115+
140116
Result resultFromBody(std::shared_ptr<arangodb::velocypack::Builder> const& body,
141117
int defaultError) {
142118

@@ -191,8 +167,13 @@ void errorCodesFromHeaders(network::Headers headers,
191167
}
192168
}
193169
}
194-
170+
195171
int fuerteToArangoErrorCode(network::Response const& res) {
172+
return fuerteToArangoErrorCode(res.error);
173+
}
174+
175+
int fuerteToArangoErrorCode(fuerte::Error err) {
176+
196177
// This function creates an error code from a ClusterCommResult,
197178
// but only if it is a communication error. If the communication
198179
// was successful and there was an HTTP error code, this function
@@ -201,8 +182,9 @@ int fuerteToArangoErrorCode(network::Response const& res) {
201182
// and .answer can safely be inspected.
202183

203184

204-
LOG_TOPIC_IF("abcde", ERR, Logger::CLUSTER, res.error != fuerte::Error::NoError) << fuerte::to_string(res.error);
205-
switch (res.error) {
185+
// LOG_TOPIC_IF("abcde", ERR, Logger::CLUSTER, res.error != fuerte::Error::NoError) << fuerte::to_string(res.error);
186+
187+
switch (err) {
206188
case fuerte::Error::NoError:
207189
return TRI_ERROR_NO_ERROR;
208190

@@ -234,23 +216,23 @@ OperationResult clusterResultInsert(arangodb::fuerte::StatusCode code,
234216
std::unordered_map<int, size_t> const& errorCounter) {
235217
switch (code) {
236218
case fuerte::StatusAccepted:
237-
return OperationResult(Result(), std::move(body), nullptr, options, errorCounter);
219+
return OperationResult(Result(), std::move(body), options, errorCounter);
238220
case fuerte::StatusCreated: {
239221
OperationOptions copy = options;
240222
copy.waitForSync = true; // wait for sync is abused herea
241223
// operationResult should get a return code.
242-
return OperationResult(Result(), std::move(body), nullptr, copy, errorCounter);
224+
return OperationResult(Result(), std::move(body), copy, errorCounter);
243225
}
244226
case fuerte::StatusPreconditionFailed:
245-
return network::opResultFromBody(*body, TRI_ERROR_ARANGO_CONFLICT);
227+
return network::opResultFromBody(body, TRI_ERROR_ARANGO_CONFLICT);
246228
case fuerte::StatusBadRequest:
247-
return network::opResultFromBody(*body, TRI_ERROR_INTERNAL);
229+
return network::opResultFromBody(body, TRI_ERROR_INTERNAL);
248230
case fuerte::StatusNotFound:
249-
return network::opResultFromBody(*body, TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
231+
return network::opResultFromBody(body, TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
250232
case fuerte::StatusConflict:
251-
return network::opResultFromBody(*body, TRI_ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED);
233+
return network::opResultFromBody(body, TRI_ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED);
252234
default:
253-
return network::opResultFromBody(*body, TRI_ERROR_INTERNAL);
235+
return network::opResultFromBody(body, TRI_ERROR_INTERNAL);
254236
}
255237
}
256238

@@ -261,14 +243,40 @@ OperationResult clusterResultDocument(arangodb::fuerte::StatusCode code,
261243
std::unordered_map<int, size_t> const& errorCounter) {
262244
switch (code) {
263245
case fuerte::StatusOK:
264-
return OperationResult(Result(), std::move(body), nullptr, options, errorCounter);
246+
return OperationResult(Result(), std::move(body), options, errorCounter);
265247
case fuerte::StatusPreconditionFailed:
266248
return OperationResult(Result(TRI_ERROR_ARANGO_CONFLICT), std::move(body),
267-
nullptr, options, errorCounter);
249+
options, errorCounter);
268250
case fuerte::StatusNotFound:
269-
return network::opResultFromBody(*body, TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND);
251+
return network::opResultFromBody(body, TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND);
270252
default:
271-
return network::opResultFromBody(*body, TRI_ERROR_INTERNAL);
253+
return network::opResultFromBody(body, TRI_ERROR_INTERNAL);
254+
}
255+
}
256+
257+
/// @brief Create Cluster Communication result for modify
258+
OperationResult clusterResultModify(arangodb::fuerte::StatusCode code,
259+
std::shared_ptr<VPackBuffer<uint8_t>> body,
260+
OperationOptions const& options,
261+
std::unordered_map<int, size_t> const& errorCounter) {
262+
switch (code) {
263+
case fuerte::StatusAccepted:
264+
case fuerte::StatusCreated: {
265+
OperationOptions options;
266+
options.waitForSync = (code == fuerte::StatusCreated);
267+
return OperationResult(Result(), std::move(body), options, errorCounter);
268+
}
269+
case fuerte::StatusConflict:
270+
return OperationResult(network::resultFromBody(body, TRI_ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED),
271+
body, options, errorCounter);
272+
case fuerte::StatusPreconditionFailed:
273+
return OperationResult(network::resultFromBody(body, TRI_ERROR_ARANGO_CONFLICT),
274+
body, options, errorCounter);
275+
case fuerte::StatusNotFound:
276+
return network::opResultFromBody(body, TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND);
277+
default: {
278+
return network::opResultFromBody(body, TRI_ERROR_INTERNAL);
279+
}
272280
}
273281
}
274282
} // namespace network

0 commit comments

Comments
 (0)
0