brion added a comment.
Regarding transactional nature:
Assuming the backing blob storage continues to work on the model of the
current `text` table blobs with external storage backing, the "easy way" is to
allow extra backend blobs to leak in case of transaction rollback, and let them
be garbage-collected.
If you want to get *fancy* you can do explicit cleanup after a rollback that
happens in PHP-land (say after catching an exception, aborting the transaction,
and then re-throwing the exception). But this will fail in the case of a fatal
error that can't be caught, or the process being killed, leading to leaks again.
In MediaWiki in general we're pretty lax about allowing unused data to
accumulate in places like that, as long as its presence isn't harmful. Not the
best practice but it has plenty of precedent. :)
So an update pseudocode might look like:
$plu = $something->getPageLookupService();
$ps = $plu->getPageStore($title);
$initialRevId = $ps->getCurrentRevisionId();
$rs = $ps->getRevisionStore();
$rb = $rs->getRevisionBuilder( $initialRevId );
$rb->setUser($context->getUser());
$rb->setComment("awesome sauce");
$rb->updateSlot('main', $updatedTextContent);
$rb->updateSlot('script', $updatedScriptData);
$rs->apply( $rb );
where inside the RevisionStore\commit method there's something like:
$dbw->start();
$bs = $this->blobStore();
$addedBlobs = [];
if ($previousRevision) {
$slots = $previousRevision->getSlots();
} else {
$slots = [];
}
try {
foreach( $this->slotUpdates as $su ) {
$blob = $bs->saveDataBlob( $su->getData() );
$addedBlobs[] = $blob;
$slots[$su->getName()] = $this->saveRevisionSlot( $blob );
}
$this->saveRevisionRecord( $blah1, $blah2, $slots );
$dbw->commit();
} catch (Exception $e) {
// If update failed, clean up any newly added backing blobs, which
// may be in external databases, filesystems, or services.
try {
foreach( $addedBlobs as $blob ) {
$blob->delete();
}
} catch (Exception $e2) {
// if we can't get in to delete them, let them leak. they're safe.
}
try {
$dbw->rollback();
} catch (Exception $e3) {
// that probably means the db connection died.
}
throw $e;
}
TASK DETAIL
https://phabricator.wikimedia.org/T107595
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: daniel, brion
Cc: JJMC89, RobLa-WMF, Yurik, ArielGlenn, APerson, TomT0m, Krenair, intracer,
Tgr, Tobi_WMDE_SW, Addshore, Lydia_Pintscher, cscott, PleaseStand, awight,
Ricordisamoa, GWicke, MarkTraceur, waldyrious, Legoktm, Aklapper,
Jdforrester-WMF, Ltrlg, brion, Spage, MZMcBride, daniel, D3r1ck01, Izno,
Luke081515, Wikidata-bugs, aude, jayvdb, fbstj, Mbch331, Jay8g, bd808
_______________________________________________
Wikidata-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs