[bug] Enforce request without shardkey to run synchronously in sharded cluster

This commit is contained in:
Sergey Konovalov
2024-06-21 20:37:15 +03:00
parent cae5264796
commit c31c50e466
2 changed files with 11 additions and 1 deletions

View File

@ -4323,6 +4323,9 @@ exports.commandFromServer = function (req, res) {
output.error = validateInputParams(ctx, authRes, params);
if (output.error === commonDefines.c_oAscServerCommandErrors.NoError) {
ctx.logger.debug('commandFromServer: c = %s', params.c);
if (params.key && !req.query[constants.SHARD_KEY_API_NAME] && !req.query[constants.SHARD_KEY_WOPI_NAME] && process.env.DEFAULT_SHARD_KEY) {
ctx.logger.warn('commandFromServer. Pass query string parameter "%s" to correctly process commands with "key" in sharded cluster', constants.SHARD_KEY_API_NAME);
}
yield *commandHandle(ctx, params, req, output);
}
} catch (err) {

View File

@ -386,7 +386,10 @@ function convertRequest(req, res, isJson) {
cmd.setTitle(path.basename(params.title, path.extname(params.title)) + '.' + outputExt);
}
var async = (typeof params.async === 'string') ? 'true' == params.async : params.async;
if (async && !req.query[constants.SHARD_KEY_API_NAME] && !req.query[constants.SHARD_KEY_WOPI_NAME] && process.env.DEFAULT_SHARD_KEY) {
ctx.logger.warn('convertRequest set async=false. Pass query string parameter "%s" to correctly process request in sharded cluster', constants.SHARD_KEY_API_NAME);
async = false;
}
if (constants.AVS_OFFICESTUDIO_FILE_UNKNOWN !== cmd.getOutputFormat()) {
let fileTo = constants.OUTPUT_NAME + '.' + outputExt;
var status = yield* convertByCmd(ctx, cmd, async, fileTo, undefined, undefined, undefined, undefined, true);
@ -466,6 +469,10 @@ function builderRequest(req, res) {
yield* docsCoServer.addTask(queueData, constants.QUEUE_PRIORITY_LOW);
}
let async = (typeof params.async === 'string') ? 'true' === params.async : params.async;
if (async && !req.query[constants.SHARD_KEY_API_NAME] && !req.query[constants.SHARD_KEY_WOPI_NAME] && process.env.DEFAULT_SHARD_KEY) {
ctx.logger.warn('builderRequest set async=false. Pass query string parameter "%s" to correctly process request in sharded cluster', constants.SHARD_KEY_API_NAME);
async = false;
}
let status = yield* convertByCmd(ctx, cmd, async, undefined, undefined, constants.QUEUE_PRIORITY_LOW);
end = status.end;
error = status.err;