MCPcopy Create free account
hub / github.com/couchbase/forestdb / _fdb_commit_and_remove_pending

Function _fdb_commit_and_remove_pending

src/forestdb.cc:3910–4046  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3908}
3909
3910static fdb_status _fdb_commit_and_remove_pending(fdb_kvs_handle *handle,
3911 struct filemgr *old_file,
3912 struct filemgr *new_file)
3913{
3914 // Note: new_file == handle->file
3915
3916 fdb_txn *earliest_txn;
3917 bool wal_flushed = false;
3918 bid_t dirty_idtree_root, dirty_seqtree_root;
3919 union wal_flush_items flush_items;
3920 fdb_status status = FDB_RESULT_SUCCESS;
3921 struct filemgr *very_old_file;
3922
3923 btreeblk_end(handle->bhandle);
3924
3925 // sync dirty root nodes
3926 filemgr_get_dirty_root(new_file, &dirty_idtree_root, &dirty_seqtree_root);
3927 if (dirty_idtree_root != BLK_NOT_FOUND) {
3928 handle->trie->root_bid = dirty_idtree_root;
3929 }
3930 if (handle->config.seqtree_opt == FDB_SEQTREE_USE &&
3931 dirty_seqtree_root != BLK_NOT_FOUND) {
3932 if (handle->kvs) {
3933 handle->seqtrie->root_bid = dirty_seqtree_root;
3934 } else {
3935 btree_init_from_bid(handle->seqtree,
3936 handle->seqtree->blk_handle,
3937 handle->seqtree->blk_ops,
3938 handle->seqtree->kv_ops,
3939 handle->seqtree->blksize,
3940 dirty_seqtree_root);
3941 }
3942 }
3943
3944 wal_commit(&new_file->global_txn, new_file, NULL, &handle->log_callback);
3945 if (wal_get_num_flushable(new_file)) {
3946 // flush wal if not empty
3947 wal_flush(new_file, (void *)handle,
3948 _fdb_wal_flush_func, _fdb_wal_get_old_offset, &flush_items);
3949 wal_set_dirty_status(new_file, FDB_WAL_CLEAN);
3950 wal_flushed = true;
3951 } else if (wal_get_size(new_file) == 0) {
3952 // empty WAL
3953 wal_set_dirty_status(new_file, FDB_WAL_CLEAN);
3954 }
3955
3956 // Note: Appending KVS header must be done after flushing WAL
3957 // because KVS stats info is updated during WAL flushing.
3958 if (handle->kvs) {
3959 // multi KV instance mode .. append up-to-date KV header
3960 handle->kv_info_offset = fdb_kvs_header_append(handle);
3961 }
3962
3963 fdb_gather_stale_blocks(handle, filemgr_get_header_revnum(new_file)+1);
3964 handle->last_hdr_bid = filemgr_get_next_alloc_block(new_file);
3965 if (wal_get_dirty_status(new_file) == FDB_WAL_CLEAN) {
3966 earliest_txn = wal_earliest_txn(new_file,
3967 &new_file->global_txn);

Callers 1

_fdb_compact_fileFunction · 0.85

Calls 15

btreeblk_endFunction · 0.85
filemgr_get_dirty_rootFunction · 0.85
btree_init_from_bidFunction · 0.85
wal_commitFunction · 0.85
wal_get_num_flushableFunction · 0.85
wal_flushFunction · 0.85
wal_set_dirty_statusFunction · 0.85
wal_get_sizeFunction · 0.85
fdb_kvs_header_appendFunction · 0.85
fdb_gather_stale_blocksFunction · 0.85

Tested by

no test coverage detected