+ break; // success
+ }
+
+ map_val_t value = update->value;
+
+ // collect some garbage
+ version_t min_active_version = UNDETERMINED_VERSION;
+ update_t *next_update = NULL;
+ if (IS_TAGGED(update->next, TAG2)) {
+ next_update = (update_t *)STRIP_TAG(update->next, TAG2);
+ min_active_version = (version_t)sl_min_key(active_);
+ if (next_update->version < min_active_version) {
+ // <next_update> (and all update records following it [execpt if it is aborted]) is old enough that it is
+ // not visible to any active transaction. We can safely free it.
+
+ // Skip over aborted versions to look for more recent updates
+ update_t *temp = next_update;
+ while (temp->version == ABORTED_VERSION) {
+ assert(!IS_TAGGED(temp->version, TAG1));
+ map_val_t next = next_update->next;
+ if (!IS_TAGGED(next, TAG2))
+ break;
+
+ temp = (update_t *)STRIP_TAG(next, TAG2);
+ if (temp->version >= min_active_version)
+ return value;
+ }
+
+ // free <next> and all the update records following it
+ temp = next_update;
+ while (1) {
+ map_val_t next = SYNC_SWAP(&temp->next, DOES_NOT_EXIST);
+
+ // if we find ourself in a race just back off and let the other thread take care of it
+ if (next == DOES_NOT_EXIST)
+ return value;
+
+ if (!IS_TAGGED(next, TAG2))
+ break;
+
+ temp = (update_t *)STRIP_TAG(next, TAG2);
+ nbd_free(update);
+ }
+ }