# HG changeset patch # User Josef 'Jeff' Sipek # Date 1671238083 18000 # Node ID 77fd01b82fd703446ad3052cbbb4b313482e92b5 # Parent 5427f4e9dcb6a475638cc52a33c469de6329f355 objstore: direct page lookup fills to the correct objver mid-txn When we are in the middle of a transaction and get a page_lookup with a PG_FILL, we need to (1) use the correct objver, and (2) zero-fill as necessary. Signed-off-by: Josef 'Jeff' Sipek diff -r 5427f4e9dcb6 -r 77fd01b82fd7 src/objstore/cache.c --- a/src/objstore/cache.c Fri Dec 16 19:46:24 2022 -0500 +++ b/src/objstore/cache.c Fri Dec 16 19:48:03 2022 -0500 @@ -167,16 +167,30 @@ * (2) all pages before the shortest truncation must be * read in from disk * - * The shortest truncation point takes care of all cases - - * including those where we extend the file after truncating - * it. + * Note that if we tried to look up a page that was modified + * by a previous write in the same transaction, that page is + * still in memory and we would have returned it earlier in + * this function. */ + struct objver *readver; + uint64_t size; int ret; - if (pgno < (p2roundup(ver->attrs.size, PAGE_SIZE) / PAGE_SIZE)) { + if (ver->txn.txn) { + /* this objver belongs to a txn */ + readver = ver->txn.prev_ver ? ver->txn.prev_ver : ver; + size = ver->txn.min_data_size; + } else { + /* non-txn lookup */ + readver = ver; + size = ver->attrs.size; + } + + if (pgno < (p2roundup(size, PAGE_SIZE) / PAGE_SIZE)) { /* existed before */ - ret = ver->obj->ops->read_page(ver, page->ptr, pgno); + ret = readver->obj->ops->read_page(readver, page->ptr, + pgno); if (ret) { free_page(page); return ERR_PTR(ret);