diff --git a/Common/sources/storage-fs.js b/Common/sources/storage-fs.js index 5c0a299f6..7f08c35a2 100644 --- a/Common/sources/storage-fs.js +++ b/Common/sources/storage-fs.js @@ -151,7 +151,11 @@ async function getSignedUrl(ctx, storageCfg, baseUrl, strPath, urlType, optFilen } else if (ctx.wopiSrc) { wopiSrcCached = ctx.wopiSrc; url += `&${constants.SHARD_KEY_WOPI_NAME}=${encodeURIComponent(ctx.wopiSrc)}`; + } else if (process.env.DEFAULT_SHARD_KEY) { + //Set DEFAULT_SHARD_KEY from environment as shardkey in case of integrator did not pass this param + url += `&${constants.SHARD_KEY_API_NAME}=${encodeURIComponent(process.env.DEFAULT_SHARD_KEY)}`; } else if (shardKeyCached) { + //Add stubs for shardkey params until integrators pass these parameters to all requests url += `&${constants.SHARD_KEY_API_NAME}=${encodeURIComponent(shardKeyCached)}`; } else if (wopiSrcCached) { url += `&${constants.SHARD_KEY_WOPI_NAME}=${encodeURIComponent(wopiSrcCached)}`; diff --git a/DocService/sources/DocsCoServer.js b/DocService/sources/DocsCoServer.js index 548754064..32cff9130 100644 --- a/DocService/sources/DocsCoServer.js +++ b/DocService/sources/DocsCoServer.js @@ -836,7 +836,8 @@ function* setForceSave(ctx, docId, forceSave, cmd, success, url) { convertInfo.setResponseKey(undefined); convertInfo.setFormData(undefined); if (convertInfo.getForceSave()) { - convertInfo.getForceSave().setType(undefined); + //type must be saved to distinguish c_oAscForceSaveTypes.Form + //convertInfo.getForceSave().setType(undefined); convertInfo.getForceSave().setAuthorUserId(undefined); convertInfo.getForceSave().setAuthorUserIndex(undefined); } @@ -884,7 +885,13 @@ async function applyForceSaveCache(ctx, docId, forceSave, type, opt_userConnecti let forceSaveCache = await checkForceSaveCache(ctx, forceSave.convertInfo); if (forceSaveCache.hasCache || forceSave.ended) { if (commonDefines.c_oAscForceSaveTypes.Form === type || commonDefines.c_oAscForceSaveTypes.Internal === type || !forceSave.ended) { - if (forceSaveCache.hasValidCache) { + //c_oAscForceSaveTypes.Form has uniqueue options {'documentLayout': {'isPrint': true}}; dont use it for other types + let forceSaveCached = forceSaveCache.cmd?.getForceSave()?.getType(); + let cacheHasSameOptions = (commonDefines.c_oAscForceSaveTypes.Form === type && + commonDefines.c_oAscForceSaveTypes.Form === forceSaveCached) || + (commonDefines.c_oAscForceSaveTypes.Form !== type && + commonDefines.c_oAscForceSaveTypes.Form !== forceSaveCached) + if (forceSaveCache.hasValidCache && cacheHasSameOptions) { let cmd = forceSaveCache.cmd; cmd.setUserConnectionDocId(opt_userConnectionDocId); cmd.setUserConnectionId(opt_userConnectionId); @@ -899,7 +906,7 @@ async function applyForceSaveCache(ctx, docId, forceSave, type, opt_userConnecti await canvasService.commandSfcCallback(ctx, cmd, true, false); res.ok = true; } else { - await editorData.checkAndSetForceSave(ctx, docId, forceSave.getTime(), forceSave.getIndex(), false, false, null); + await editorData.checkAndSetForceSave(ctx, docId, forceSave.time, forceSave.index, false, false, null); res.startedForceSave = await editorData.checkAndStartForceSave(ctx, docId); res.ok = !!res.startedForceSave; } @@ -4316,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) { diff --git a/DocService/sources/converterservice.js b/DocService/sources/converterservice.js index 2cf7781fc..7574c0667 100644 --- a/DocService/sources/converterservice.js +++ b/DocService/sources/converterservice.js @@ -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;