| 594 | } |
| 595 | |
| 596 | ACTOR static void shutdown(RawDiskQueue_TwoFiles* self, bool deleteFiles) { |
| 597 | // Wait for all reads and writes on the file, and all actors referencing self, to be finished |
| 598 | state Error error = success(); |
| 599 | try { |
| 600 | wait(success(errorOr(self->lastCommit))); |
| 601 | // Wait for the pending operations (e.g., read) to finish before we destroy the DiskQueue, because |
| 602 | // tLog, instead of DiskQueue, hold the future of the pending operations. |
| 603 | wait(self->onSafeToDestruct()); |
| 604 | |
| 605 | for (int i = 0; i < 2; i++) |
| 606 | self->files[i].f.clear(); |
| 607 | |
| 608 | if (deleteFiles) { |
| 609 | TraceEvent("DiskQueueShutdownDeleting", self->dbgid) |
| 610 | .detail("File0", self->filename(0)) |
| 611 | .detail("File1", self->filename(1)); |
| 612 | wait(IAsyncFileSystem::filesystem()->incrementalDeleteFile(self->filename(0), false)); |
| 613 | wait(IAsyncFileSystem::filesystem()->incrementalDeleteFile(self->filename(1), true)); |
| 614 | } |
| 615 | TraceEvent("DiskQueueShutdownComplete", self->dbgid) |
| 616 | .detail("DeleteFiles", deleteFiles) |
| 617 | .detail("File0", self->filename(0)); |
| 618 | } catch (Error& e) { |
| 619 | TraceEvent(SevError, "DiskQueueShutdownError", self->dbgid) |
| 620 | .errorUnsuppressed(e) |
| 621 | .detail("Reason", e.code() == error_code_platform_error ? "could not delete database" : "unknown"); |
| 622 | error = e; |
| 623 | } |
| 624 | |
| 625 | if (error.code() != error_code_actor_cancelled) { |
| 626 | if (self->stopped.canBeSet()) |
| 627 | self->stopped.send(Void()); |
| 628 | if (self->error.canBeSet()) |
| 629 | self->error.send(Never()); |
| 630 | delete self; |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | // Return the most recently written page, the page with largest seq number |
| 635 | ACTOR static UNCANCELLABLE Future<Standalone<StringRef>> readFirstAndLastPages(RawDiskQueue_TwoFiles* self, |
no test coverage detected