mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
A sprint over 10,000 cards was refused at start and close. With the snapshot rows already outside the sprint document, the rest now is too: - The rollover plan of a close goes to its own collection, scrumRolloverRows, in chunks bounded by rows and bytes; the sprint keeps only rolloverPending: true. A chunk is applied, its cards read at once, and removed; the mark is cleared when none is left. A plan kept in the sprint document before this is still finished as it was. - A Scrum History batch too large for one row is recorded as several rows sharing a batchId, each at most 1,000 records and 3 MB a side. A record is in exactly one row, and undo and redo walk the whole batch, with or without a request ID, so one undo still reverses a whole close. - Daily burndown observations keep their rows in scrumSnapshotRows too. - No 10,000-card limit is left: snapshot inputs, daily capture, scope replay, the daily report and the transfer read every card. Undoing a batch re-hashed its whole History row and sent its whole plan as a selector before every record write, so a 1,500-card undo took four minutes. The row is now checked whole when the operation begins and by its identity fields after that, and the worker check uses the plan's identity and the worker's random id - nothing ever rewrites a pending plan. A 10,500-card sprint closes in 8 s and undoes in 44 s. Thanks to xet7 !
36 lines
2.0 KiB
JavaScript
36 lines
2.0 KiB
JavaScript
const { calculateObjectSize } = require('bson');
|
|
const { historyDocument } = require('../../models/lib/scrumHistory');
|
|
|
|
// Reserve 1 MiB below MongoDB's document ceiling for History/journal envelope
|
|
// fields, revision arrays and schema defaults. Count BSON bytes, not characters.
|
|
const SCRUM_DOCUMENT_BUDGET = 15 * 1024 * 1024;
|
|
function fits(document, label) {
|
|
if (calculateObjectSize(document) > SCRUM_DOCUMENT_BUDGET) {
|
|
const error = new Error(`Scrum ${label} exceeds the document size budget; reduce the sprint scope before retrying`);
|
|
error.code = 'scrum-document-too-large';
|
|
throw error;
|
|
}
|
|
}
|
|
function assertScrumLifecycleSize(before, after) {
|
|
fits(after, 'sprint/rollover plan');
|
|
const entry = (type, id, document) => ({ type, id, document });
|
|
const previousContent = { records: [entry('scrum-sprint', before._id, historyDocument('scrum-sprint', before))] };
|
|
const newContent = { records: [entry('scrum-sprint', after._id, historyDocument('scrum-sprint', after))] };
|
|
// A plan in the sprint document is the form before 2026-10-03; a plan now
|
|
// lives in its own chunks (scrumRolloverStore.js) and its History is split
|
|
// into rows of bounded size (models/lib/scrumHistory.js historyParts).
|
|
for (const card of Array.isArray(after.rolloverPending) ? after.rolloverPending : []) {
|
|
previousContent.records.push(entry('card', card.cardId,
|
|
{ _id: card.cardId, boardId: after.boardId, scrum: card.before }));
|
|
newContent.records.push(entry('card', card.cardId,
|
|
{ _id: card.cardId, boardId: after.boardId, scrum: card.after }));
|
|
}
|
|
fits({ previousContent, newContent }, 'compound History');
|
|
// Restore can displace another snapshot as large as either side. Its pending
|
|
// journal and timeline both store two sides, so reserve room for that too.
|
|
const largest = calculateObjectSize(previousContent) > calculateObjectSize(newContent)
|
|
? previousContent : newContent;
|
|
fits({ previousContent: largest, newContent: largest }, 'History recovery');
|
|
}
|
|
module.exports = { assertScrumLifecycleSize, SCRUM_DOCUMENT_BUDGET };
|