/* * __wt_bloom_insert -- * Adds the given key to the Bloom filter. */ int __wt_bloom_insert(WT_BLOOM *bloom, WT_ITEM *key) { uint64_t h1, h2; uint32_t i; h1 = __wt_hash_fnv64(key->data, key->size); h2 = __wt_hash_city64(key->data, key->size); for (i = 0; i < bloom->k; i++, h1 += h2) { __bit_set(bloom->bitstring, h1 % bloom->m); } return (0); }
/* * __txn_rollback_to_stable_btree -- * Called for each open handle - choose to either skip or wipe the commits */ static int __txn_rollback_to_stable_btree( WT_SESSION_IMPL *session, const char *cfg[]) { WT_DECL_RET; WT_DECL_TIMESTAMP(rollback_timestamp) WT_BTREE *btree; WT_TXN_GLOBAL *txn_global; WT_UNUSED(cfg); btree = S2BT(session); txn_global = &S2C(session)->txn_global; /* * Immediately durable files don't get their commits wiped. This case * mostly exists to support the semantic required for the oplog in * MongoDB - updates that have been made to the oplog should not be * aborted. It also wouldn't be safe to roll back updates for any * table that had it's records logged, since those updates would be * recovered after a crash making them inconsistent. */ if (__wt_btree_immediately_durable(session)) { /* * Add the btree ID to the bitstring, so we can exclude any * lookaside entries for this btree. */ __bit_set( S2C(session)->stable_rollback_bitstring, btree->id); return (0); } /* There is never anything to do for checkpoint handles */ if (session->dhandle->checkpoint != NULL) return (0); /* There is nothing to do on an empty tree. */ if (btree->root.page == NULL) return (0); if (btree->type != BTREE_ROW) WT_RET_MSG(session, EINVAL, "rollback_to_stable " "is only supported for row store btrees"); /* * Copy the stable timestamp, otherwise we'd need to lock it each time * it's accessed. Even though the stable timestamp isn't supposed to be * updated while rolling back, accessing it without a lock would * violate protocol. */ __wt_readlock(session, &txn_global->rwlock); __wt_timestamp_set(&rollback_timestamp, &txn_global->stable_timestamp); __wt_readunlock(session, &txn_global->rwlock); /* * Ensure the eviction server is out of the file - we don't * want it messing with us. This step shouldn't be required, but * it simplifies some of the reasoning about what state trees can * be in. */ WT_RET(__wt_evict_file_exclusive_on(session)); ret = __txn_rollback_to_stable_btree_walk( session, &rollback_timestamp); __wt_evict_file_exclusive_off(session); return (ret); }