| 1767 | TraceEvent("KVWriterDestroyed", dbgid).log(); |
| 1768 | } |
| 1769 | void init() override { |
| 1770 | if (checkAllChecksumsOnOpen) { |
| 1771 | if (conn.checkAllPageChecksums() != 0) { |
| 1772 | // It's not strictly necessary to discard the file immediately if a page checksum error is found |
| 1773 | // because most of the file could be valid and bad pages will be detected if they are read. |
| 1774 | // However, we shouldn't use the file unless we absolutely have to because some range(s) of keys |
| 1775 | // have effectively lost a replica. |
| 1776 | throw file_corrupt(); |
| 1777 | } |
| 1778 | } |
| 1779 | conn.open(true); |
| 1780 | kvs->dbFile = conn.dbFile; |
| 1781 | kvs->walFile = conn.walFile; |
| 1782 | |
| 1783 | // If a wal file fails during the commit process before finishing a checkpoint, then it is possible that our |
| 1784 | // wal file will be non-empty when we reload it. We execute a checkpoint here to remedy that situation. |
| 1785 | // This call must come before before creating a cursor because it will fail if there are any outstanding |
| 1786 | // transactions. |
| 1787 | fullCheckpoint(); |
| 1788 | |
| 1789 | cursor = new Cursor(conn, true); |
| 1790 | |
| 1791 | if (checkIntegrityOnOpen || EXPENSIVE_VALIDATION) { |
| 1792 | if (conn.check(false) != 0) { |
| 1793 | // A corrupt btree structure must not be used. |
| 1794 | if (g_network->isSimulated() && VFSAsyncFile::checkInjectedError()) { |
| 1795 | throw file_corrupt().asInjectedFault(); |
| 1796 | } else { |
| 1797 | throw file_corrupt(); |
| 1798 | } |
| 1799 | } |
| 1800 | } |
| 1801 | } |
| 1802 | |
| 1803 | struct InitAction final : TypedAction<Writer, InitAction>, FastAllocated<InitAction> { |
| 1804 | ThreadReturnPromise<Void> result; |
nothing calls this directly
no test coverage detected