| 897 | } |
| 898 | |
| 899 | void CCH_fetch_page(thread_db* tdbb, WIN* window, const bool read_shadow) |
| 900 | { |
| 901 | /************************************** |
| 902 | * |
| 903 | * C C H _ f e t c h _ p a g e |
| 904 | * |
| 905 | ************************************** |
| 906 | * |
| 907 | * Functional description |
| 908 | * Fetch a specific page. If it's already in cache, |
| 909 | * so much the better. When "compute_checksum" is 1, compute |
| 910 | * the checksum of the page. When it is 2, compute |
| 911 | * the checksum only when the page type is nonzero. |
| 912 | * |
| 913 | **************************************/ |
| 914 | SET_TDBB(tdbb); |
| 915 | Database* dbb = tdbb->getDatabase(); |
| 916 | BufferDesc* bdb = window->win_bdb; |
| 917 | BufferControl* bcb = bdb->bdb_bcb; |
| 918 | |
| 919 | FbStatusVector* const status = tdbb->tdbb_status_vector; |
| 920 | |
| 921 | pag* page = bdb->bdb_buffer; |
| 922 | bdb->bdb_incarnation = ++bcb->bcb_page_incarnation; |
| 923 | |
| 924 | tdbb->bumpStats(RuntimeStatistics::PAGE_READS); |
| 925 | |
| 926 | PageSpace* pageSpace = dbb->dbb_page_manager.findPageSpace(bdb->bdb_page.getPageSpaceID()); |
| 927 | fb_assert(pageSpace); |
| 928 | |
| 929 | jrd_file* file = pageSpace->file; |
| 930 | const bool isTempPage = pageSpace->isTemporary(); |
| 931 | |
| 932 | /* |
| 933 | We will read a page, and if there is an I/O error we will try to |
| 934 | use the shadow file, and try reading again, for a maximum of |
| 935 | 3 tries, before it gives up. |
| 936 | |
| 937 | The read_shadow flag is set to false only in the call to |
| 938 | FETCH_NO_SHADOW, which is only called from validate |
| 939 | code. |
| 940 | |
| 941 | read_shadow = false -> IF an I/O error occurs give up (exit |
| 942 | the loop, clean up, and return). So the caller, |
| 943 | validate in most cases, can know about it and attempt |
| 944 | to remedy the situation. |
| 945 | |
| 946 | read_shadow = true -> IF an I/O error occurs attempt |
| 947 | to rollover to the shadow file. If the I/O error is |
| 948 | persistant (more than 3 times) error out of the routine by |
| 949 | calling CCH_unwind, and eventually punting out. |
| 950 | */ |
| 951 | |
| 952 | class Pio : public CryptoManager::IOCallback |
| 953 | { |
| 954 | public: |
| 955 | Pio(jrd_file* f, BufferDesc* b, bool tp, bool rs, PageSpace* ps) |
| 956 | : file(f), bdb(b), isTempPage(tp), |
no test coverage detected