Select the types of activity you want to include in your feed.
chunk deletes for delete-account
things blew up (in c++ with a very unhelpful error abort) when an apparently very-large (spam probably) account was deleted. the batch it was writing to grew to over 1GiB.
···521521 };
522522 self.delete_did_id_value(batch, did);
523523524524- for (i, (record_link_key, links)) in self.iter_links_for_did_id(&did_id).enumerate() {
525525- self.delete_record_link(batch, &record_link_key); // _could_ use delete range here instead of individual deletes, but since we have to scan anyway it's not obvious if it's better
524524+ // use a separate batch for all their links, since it can be a lot and make us crash at around 1GiB batch size.
525525+ // this should still hopefully be crash-safe: as long as we don't actually delete the DidId entry until after all links are cleared.
526526+ // the above .delete_did_id_value is batched, so it shouldn't be written until we've returned from this fn successfully
527527+ // TODO: queue a background delete task or whatever
528528+ // TODO: test delete account with more links than chunk size
529529+ let stuff: Vec<_> = self.iter_links_for_did_id(&did_id).collect();
530530+ for chunk in stuff.chunks(1024) {
531531+ let mut mini_batch = WriteBatch::default();
526532527527- for (j, RecordLinkTarget(path, target_link_id)) in links.0.iter().enumerate() {
528528- self.update_target_linkers(batch, target_link_id, |mut linkers| {
529529- if !linkers.remove_last_linker(&did_id) {
530530- eprintln!(
531531- "DELETING ACCOUNT: blowing up: missing linker entry in linked target."
532532- );
533533- eprintln!("account: {did:?}");
534534- eprintln!("did_id: {did_id:?}, was active? {active:?}");
535535- eprintln!("with links: {links:?}");
536536- eprintln!("and linkers: {linkers:?}");
537537- eprintln!(
538538- "working on #{i}.#{j}: {:?} / {path:?} / {target_link_id:?}",
539539- record_link_key.collection()
540540- );
541541- eprintln!("from record link key {record_link_key:?}");
542542- eprintln!("but could not find this link :/");
543543- eprintln!("checking for did_id dups...");
544544- self.check_for_did_dups(&did_id);
545545- eprintln!("ok so what the heck. did_id again, for did {did:?}:");
546546- let did_id_again = self
547547- .did_id_table
548548- .get_id_val(&self.db, did)
549549- .unwrap()
550550- .unwrap();
551551- eprintln!("did_id_value (again): {did_id_again:?}");
552552- panic!("ohnoooo");
553553- }
554554- Some(linkers)
555555- })
556556- .unwrap();
533533+ for (i, (record_link_key, links)) in chunk.iter().enumerate() {
534534+ self.delete_record_link(&mut mini_batch, &record_link_key); // _could_ use delete range here instead of individual deletes, but since we have to scan anyway it's not obvious if it's better
535535+536536+ for (j, RecordLinkTarget(path, target_link_id)) in links.0.iter().enumerate() {
537537+ self.update_target_linkers(&mut mini_batch, target_link_id, |mut linkers| {
538538+ if !linkers.remove_last_linker(&did_id) {
539539+ eprintln!(
540540+ "DELETING ACCOUNT: blowing up: missing linker entry in linked target."
541541+ );
542542+ eprintln!("account: {did:?}");
543543+ eprintln!("did_id: {did_id:?}, was active? {active:?}");
544544+ eprintln!("with links: {links:?}");
545545+ eprintln!("and linkers: {linkers:?}");
546546+ eprintln!(
547547+ "working on #{i}.#{j}: {:?} / {path:?} / {target_link_id:?}",
548548+ record_link_key.collection()
549549+ );
550550+ eprintln!("from record link key {record_link_key:?}");
551551+ eprintln!("but could not find this link :/");
552552+ eprintln!("checking for did_id dups...");
553553+ self.check_for_did_dups(&did_id);
554554+ eprintln!("ok so what the heck. did_id again, for did {did:?}:");
555555+ let did_id_again = self
556556+ .did_id_table
557557+ .get_id_val(&self.db, did)
558558+ .unwrap()
559559+ .unwrap();
560560+ eprintln!("did_id_value (again): {did_id_again:?}");
561561+ panic!("ohnoooo");
562562+ }
563563+ Some(linkers)
564564+ })
565565+ .unwrap();
566566+ }
557567 }
568568+569569+ self.db.write(mini_batch).unwrap(); // todo
558570 }
559571 }
560572}