From: Michael Adam Date: Tue, 6 May 2008 08:06:34 +0000 (+0200) Subject: registry: add comment explaining workflow to make store_keys safe w/o transactions X-Git-Tag: samba-4.0.0alpha6~801^2~1469 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=01e640f6ea609ec2235543d69b1715a1be7d09b3;p=thirdparty%2Fsamba.git registry: add comment explaining workflow to make store_keys safe w/o transactions /* * Make the store operation as safe as possible without transactions: * * (1) For each subkey removed from ctr compared with old_subkeys: * * (a) First delete the value db entry. * * (b) Next delete the secdesc db record. * * (c) Then delete the subkey list entry. * * (2) Now write the list of subkeys of the parent key, * deleting removed entries and adding new ones. * * (3) Finally create the subkey list entries for the added keys. * * This way if we crash half-way in between deleting the subkeys * and storing the parent's list of subkeys, no old data can pop up * out of the blue when re-adding keys later on. */ The workflow is going to be modified to meet this agendain the next commits. Michael (This used to be commit 55dd9bdd148fc942e15aacfe9f6b38b1a5c53158) --- diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c index 50fc20ea82f..87837448d91 100644 --- a/source3/registry/reg_backend_db.c +++ b/source3/registry/reg_backend_db.c @@ -636,6 +636,27 @@ bool regdb_store_keys(const char *key, REGSUBKEY_CTR *ctr) regdb_fetch_keys(key, old_subkeys); + /* + * Make the store operation as safe as possible without transactions: + * + * (1) For each subkey removed from ctr compared with old_subkeys: + * + * (a) First delete the value db entry. + * + * (b) Next delete the secdesc db record. + * + * (c) Then delete the subkey list entry. + * + * (2) Now write the list of subkeys of the parent key, + * deleting removed entries and adding new ones. + * + * (3) Finally create the subkey list entries for the added keys. + * + * This way if we crash half-way in between deleting the subkeys + * and storing the parent's list of subkeys, no old data can pop up + * out of the blue when re-adding keys later on. + */ + /* store the subkey list for the parent */ if (!regdb_store_keys_internal(key, ctr) ) {