Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle swap blob metadata correctly #173

Merged
merged 1 commit into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/buffer_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,8 @@ api::Status PlaceBlob(SharedMemoryContext *context, RpcContext *rpc,
HERMES_END_TIMED_BLOCK();

// NOTE(chogan): Update all metadata associated with this Put
AttachBlobToBucket(context, rpc, name.c_str(), bucket_id, buffer_ids);
AttachBlobToBucket(context, rpc, name.c_str(), bucket_id, buffer_ids,
false, called_from_buffer_organizer);
} else {
if (called_from_buffer_organizer) {
result = PLACE_SWAP_BLOB_TO_BUF_FAILED;
Expand Down
18 changes: 17 additions & 1 deletion src/metadata_management.cc
Original file line number Diff line number Diff line change
Expand Up @@ -619,12 +619,28 @@ BufferIdArray GetBufferIdsFromBlobId(Arena *arena,
void AttachBlobToBucket(SharedMemoryContext *context, RpcContext *rpc,
const char *blob_name, BucketID bucket_id,
const std::vector<BufferID> &buffer_ids,
bool is_swap_blob) {
bool is_swap_blob, bool called_from_buffer_organizer) {
MetadataManager *mdm = GetMetadataManagerFromContext(context);

std::string internal_name = MakeInternalBlobName(blob_name, bucket_id);
int target_node = HashString(mdm, rpc, internal_name.c_str());

BlobID blob_id = {};
if (called_from_buffer_organizer) {
blob_id = GetBlobId(context, rpc, blob_name, bucket_id);

if (!IsNullBlobId(blob_id)) {
// Remove old BlobID from the bucket's list of Blobs
RemoveBlobFromBucketInfo(context, rpc, bucket_id, blob_id);

// Release the IDs that represented the SwapBlob info
FreeBufferIdList(context, rpc, blob_id);
} else {
LOG(WARNING) << "Expected to find BlobID " << blob_id.as_int
<< " in Map but didn't." << std::endl;
}
}

// NOTE(chogan): A negative node_id indicates a swap blob
blob_id.bits.node_id = is_swap_blob ? -target_node : target_node;
blob_id.bits.buffer_ids_offset = AllocateBufferIdList(context, rpc,
Expand Down
9 changes: 8 additions & 1 deletion src/metadata_management.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ VBucketID GetOrCreateVBucketId(SharedMemoryContext *context, RpcContext *rpc,
void AttachBlobToBucket(SharedMemoryContext *context, RpcContext *rpc,
const char *blob_name, BucketID bucket_id,
const std::vector<BufferID> &buffer_ids,
bool is_swap_blob = false);
bool is_swap_blob = false,
bool called_from_buffer_organizer = false);

/**
*
Expand Down Expand Up @@ -343,6 +344,12 @@ void AttachBlobToVBucket(SharedMemoryContext *context, RpcContext *rpc,
const char *blob_name, const char *bucket_name,
VBucketID vbucket_id);

/**
*
*/
void RemoveBlobFromBucketInfo(SharedMemoryContext *context, RpcContext *rpc,
BucketID bucket_id, BlobID blob_id);

/**
*
*/
Expand Down