mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-17 06:44:30 +00: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 VERBOSE_LOGGING = process.env.VERBOSE_LOGGING === 'true'
|
||||||
const WRITE_CONCURRENCY = parseInt(process.env.WRITE_CONCURRENCY, 10) || 10
|
const WRITE_CONCURRENCY = parseInt(process.env.WRITE_CONCURRENCY, 10) || 10
|
||||||
const BATCH_SIZE = parseInt(process.env.BATCH_SIZE, 10) || 100
|
const BATCH_SIZE = parseInt(process.env.BATCH_SIZE, 10) || 100
|
||||||
|
@ -68,13 +68,16 @@ async function processProject(project) {
|
||||||
if (INTERRUPT) {
|
if (INTERRUPT) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// skip safety check if we want to retry failed upgrades
|
if (project.overleaf && project.overleaf.history) {
|
||||||
if (!RETRY_FAILED) {
|
// projects we're upgrading like this should never have a history id
|
||||||
if (project.overleaf && project.overleaf.history) {
|
if (project.overleaf.history.id) {
|
||||||
if (
|
return
|
||||||
project.overleaf.history.conversionFailed ||
|
}
|
||||||
project.overleaf.history.upgradeFailed
|
if (
|
||||||
) {
|
project.overleaf.history.conversionFailed ||
|
||||||
|
project.overleaf.history.upgradeFailed
|
||||||
|
) {
|
||||||
|
if (!RETRY_FAILED) {
|
||||||
// we don't want to attempt upgrade on projects
|
// we don't want to attempt upgrade on projects
|
||||||
// that have been previously attempted and failed
|
// that have been previously attempted and failed
|
||||||
return
|
return
|
||||||
|
@ -174,7 +177,11 @@ async function main() {
|
||||||
}
|
}
|
||||||
await batchedUpdate(
|
await batchedUpdate(
|
||||||
'projects',
|
'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,
|
processBatch,
|
||||||
projection,
|
projection,
|
||||||
options
|
options
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const SCRIPT_VERSION = 2
|
const SCRIPT_VERSION = 3
|
||||||
const VERBOSE_LOGGING = process.env.VERBOSE_LOGGING === 'true'
|
const VERBOSE_LOGGING = process.env.VERBOSE_LOGGING === 'true'
|
||||||
const WRITE_CONCURRENCY = parseInt(process.env.WRITE_CONCURRENCY, 10) || 10
|
const WRITE_CONCURRENCY = parseInt(process.env.WRITE_CONCURRENCY, 10) || 10
|
||||||
const BATCH_SIZE = parseInt(process.env.BATCH_SIZE, 10) || 100
|
const BATCH_SIZE = parseInt(process.env.BATCH_SIZE, 10) || 100
|
||||||
|
@ -69,15 +69,26 @@ async function processProject(project) {
|
||||||
if (INTERRUPT) {
|
if (INTERRUPT) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!RETRY_FAILED) {
|
// If upgradeFailed, skip unless we're explicitly retrying failed upgrades
|
||||||
if (
|
if (
|
||||||
project.overleaf &&
|
project.overleaf &&
|
||||||
project.overleaf.history &&
|
project.overleaf.history &&
|
||||||
project.overleaf.history.upgradeFailed
|
project.overleaf.history.upgradeFailed
|
||||||
) {
|
) {
|
||||||
|
if (RETRY_FAILED) {
|
||||||
|
return await doUpgradeForNoneWithoutConversion(project)
|
||||||
|
} else {
|
||||||
return
|
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)
|
const anyDocHistory = await anyDocHistoryExists(project)
|
||||||
if (anyDocHistory) {
|
if (anyDocHistory) {
|
||||||
return
|
return
|
||||||
|
@ -187,7 +198,11 @@ async function main() {
|
||||||
}
|
}
|
||||||
await batchedUpdate(
|
await batchedUpdate(
|
||||||
'projects',
|
'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,
|
processBatch,
|
||||||
projection,
|
projection,
|
||||||
options
|
options
|
||||||
|
|
Loading…
Reference in a new issue