| 7771 | } |
| 7772 | |
| 7773 | ACTOR void shutdown(KeyValueStoreRedwood* self, bool dispose) { |
| 7774 | TraceEvent(SevInfo, "RedwoodShutdown").detail("Filename", self->m_filename).detail("Dispose", dispose); |
| 7775 | |
| 7776 | // In simulation, if the instance is being disposed of then sometimes run destructive sanity check. |
| 7777 | if (g_network->isSimulated() && dispose && BUGGIFY) { |
| 7778 | // Only proceed if the last commit is a success, but don't throw if it's not because shutdown |
| 7779 | // should not throw. |
| 7780 | wait(ready(self->m_lastCommit)); |
| 7781 | if (!self->m_lastCommit.isError()) { |
| 7782 | // Run the destructive sanity check, but don't throw. |
| 7783 | ErrorOr<Void> err = wait(errorOr(self->m_tree->clearAllAndCheckSanity())); |
| 7784 | // If the test threw an error, it must be an injected fault or something has gone wrong. |
| 7785 | ASSERT(!err.isError() || err.getError().isInjectedFault()); |
| 7786 | } |
| 7787 | } else { |
| 7788 | // The KVS user shouldn't be holding a commit future anymore so self shouldn't either. |
| 7789 | self->m_lastCommit = Void(); |
| 7790 | } |
| 7791 | |
| 7792 | if (self->m_error.canBeSet()) { |
| 7793 | self->m_error.sendError(actor_cancelled()); // Ideally this should be shutdown_in_progress |
| 7794 | } |
| 7795 | self->m_init.cancel(); |
| 7796 | Future<Void> closedFuture = self->m_tree->onClosed(); |
| 7797 | if (dispose) |
| 7798 | self->m_tree->dispose(); |
| 7799 | else |
| 7800 | self->m_tree->close(); |
| 7801 | wait(closedFuture); |
| 7802 | self->m_closed.send(Void()); |
| 7803 | TraceEvent(SevInfo, "RedwoodShutdownComplete").detail("Filename", self->m_filename).detail("Dispose", dispose); |
| 7804 | delete self; |
| 7805 | } |
| 7806 | |
| 7807 | void close() override { shutdown(this, false); } |
| 7808 |
nothing calls this directly
no test coverage detected