mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #6025 from overleaf/tm-history-upgrade-fix-retry-failed
Fix for None without conversion to correctly retry failed upgrades and speed up mongo queries GitOrigin-RevId: 22d2b936f478ee8395775ed258095f1bf647c88f
This commit is contained in:
parent
affe266609
commit
abbacd71b7
2 changed files with 39 additions and 17 deletions
|
@ -1,4 +1,4 @@
|
|||
const SCRIPT_VERSION = 2
|
||||
const SCRIPT_VERSION = 3
|
||||
const VERBOSE_LOGGING = process.env.VERBOSE_LOGGING === 'true'
|
||||
const WRITE_CONCURRENCY = parseInt(process.env.WRITE_CONCURRENCY, 10) || 10
|
||||
const BATCH_SIZE = parseInt(process.env.BATCH_SIZE, 10) || 100
|
||||
|
@ -68,13 +68,16 @@ async function processProject(project) {
|
|||
if (INTERRUPT) {
|
||||
return
|
||||
}
|
||||
// skip safety check if we want to retry failed upgrades
|
||||
if (!RETRY_FAILED) {
|
||||
if (project.overleaf && project.overleaf.history) {
|
||||
// projects we're upgrading like this should never have a history id
|
||||
if (project.overleaf.history.id) {
|
||||
return
|
||||
}
|
||||
if (
|
||||
project.overleaf.history.conversionFailed ||
|
||||
project.overleaf.history.upgradeFailed
|
||||
) {
|
||||
if (!RETRY_FAILED) {
|
||||
// we don't want to attempt upgrade on projects
|
||||
// that have been previously attempted and failed
|
||||
return
|
||||
|
@ -174,7 +177,11 @@ async function main() {
|
|||
}
|
||||
await batchedUpdate(
|
||||
'projects',
|
||||
{ 'overleaf.history.id': { $exists: false } },
|
||||
// we originally used
|
||||
// 'overleaf.history.id': { $exists: false }
|
||||
// but display false is indexed and contains all the above,
|
||||
// it can be faster to skip projects with a history ID than to use a query
|
||||
{ 'overleaf.history.display': { $ne: true } },
|
||||
processBatch,
|
||||
projection,
|
||||
options
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const SCRIPT_VERSION = 2
|
||||
const SCRIPT_VERSION = 3
|
||||
const VERBOSE_LOGGING = process.env.VERBOSE_LOGGING === 'true'
|
||||
const WRITE_CONCURRENCY = parseInt(process.env.WRITE_CONCURRENCY, 10) || 10
|
||||
const BATCH_SIZE = parseInt(process.env.BATCH_SIZE, 10) || 100
|
||||
|
@ -69,15 +69,26 @@ async function processProject(project) {
|
|||
if (INTERRUPT) {
|
||||
return
|
||||
}
|
||||
if (!RETRY_FAILED) {
|
||||
// If upgradeFailed, skip unless we're explicitly retrying failed upgrades
|
||||
if (
|
||||
project.overleaf &&
|
||||
project.overleaf.history &&
|
||||
project.overleaf.history.upgradeFailed
|
||||
) {
|
||||
if (RETRY_FAILED) {
|
||||
return await doUpgradeForNoneWithoutConversion(project)
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
// Skip any projects with a history ID, these are v1
|
||||
if (
|
||||
project.overleaf &&
|
||||
project.overleaf.history &&
|
||||
project.overleaf.history.id
|
||||
) {
|
||||
return
|
||||
}
|
||||
const anyDocHistory = await anyDocHistoryExists(project)
|
||||
if (anyDocHistory) {
|
||||
return
|
||||
|
@ -187,7 +198,11 @@ async function main() {
|
|||
}
|
||||
await batchedUpdate(
|
||||
'projects',
|
||||
{ 'overleaf.history.id': { $exists: false } },
|
||||
// we originally used
|
||||
// 'overleaf.history.id': { $exists: false }
|
||||
// but display false is indexed and contains all the above,
|
||||
// plus we want to be able to retry failed upgrades with a history id
|
||||
{ 'overleaf.history.display': { $ne: true } },
|
||||
processBatch,
|
||||
projection,
|
||||
options
|
||||
|
|
Loading…
Reference in a new issue