Commit 06f7a176 authored by John Esmet's avatar John Esmet Committed by Yoni Fogel

close[t:5128] updating a descriptor now has two parts: user API that passes a...

close[t:5128] updating a descriptor now has two parts: user API that passes a FT and descriptor, and a low layer API that takes those two plus an explicit descriptor. we use the low layer one for deserialization code that wants to upgrade a descriptor for an FT that is not fully opened yet (and thus whose FT does not have a valid cachefile yet). this seems to be a clean enough solution, since it helps some upgrade code do non-standard stuff.

most importantly, loader-stress-test3 no longer fails by segfaulting on ft->cf->fd


git-svn-id: file:///svn/toku/tokudb@44839 c7de825b-a66e-492c-adef-691d508d4ae1
parent a13668ea
......@@ -332,7 +332,7 @@ deserialize_ft_versioned(int fd, struct rbuf *rb, FT *ftp, uint32_t version)
// version if it gets written out, we need to write the descriptor in
// the new format (without those bytes) before that happens.
if (version <= FT_LAYOUT_VERSION_13) {
toku_ft_update_descriptor(ft, &ft->cmp_descriptor);
toku_ft_update_descriptor_with_fd(ft, &ft->cmp_descriptor, fd);
}
r = 0;
exit:
......
......@@ -914,13 +914,26 @@ toku_ft_stat64 (FT ft, struct ftstat64_s *s) {
void
toku_ft_update_descriptor(FT ft, DESCRIPTOR d)
// Effect: Changes the descriptor in a tree (log the change, make sure it makes it to disk eventually).
// requires: updates do not happen in parallel for an FT (ydb layer uses a row lock to enforce this)
// requires: the ft is fully user-opened with a valid cachefile.
// descriptor updates cannot happen in parallel for an FT
// (ydb layer uses a row lock to enforce this)
{
assert(ft->cf);
int fd = toku_cachefile_get_fd(ft->cf);
toku_ft_update_descriptor_with_fd(ft, d, fd);
}
// upadate the descriptor for an ft and serialize it using
// the given descriptor instead of reading the descriptor
// from the ft's cachefile. we do this so serialize code can
// update a descriptor before the ft is fully opened and has
// a valid cachefile.
void
toku_ft_update_descriptor_with_fd(FT ft, DESCRIPTOR d, int fd) {
// the checksum is four bytes, so that's where the magic number comes from
// make space for the new descriptor and write it out to disk
DISKOFF offset, size;
size = toku_serialize_descriptor_size(d) + 4;
int fd = toku_cachefile_get_fd(ft->cf);
toku_realloc_descriptor_on_disk(ft->blocktable, size, &offset, ft, fd);
toku_serialize_descriptor_contents_to_fd(fd, d, offset);
......
......@@ -82,6 +82,10 @@ void toku_ft_stat64 (FT h, struct ftstat64_s *s);
// see toku_ft_change_descriptor(), which is the transactional version
// used by the ydb layer. it better describes the client contract.
void toku_ft_update_descriptor(FT ft, DESCRIPTOR d);
// use this version if the FT is not fully user-opened with a valid cachefile.
// this is a clean hack to get deserialization code to update a descriptor
// while the FT and cf are in the process of opening, for upgrade purposes
void toku_ft_update_descriptor_with_fd(FT ft, DESCRIPTOR d, int fd);
void toku_ft_update_cmp_descriptor(FT ft);
// get the descriptor for a ft. safe to read as long as clients honor the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment