MCPcopy Create free account
hub / github.com/bytedance/bolt / initializeCheckpoint

Method initializeCheckpoint

bolt/common/caching/SsdFile.cpp:776–815  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

774void SsdFile::initializeCheckpoint() {
775 if (checkpointIntervalBytes_ == 0) {
776 return;
777 }
778 bool hasCheckpoint = true;
779 std::ifstream state(fileName_ + kCheckpointExtension);
780 if (!state.is_open()) {
781 hasCheckpoint = false;
782 ++stats_.openCheckpointErrors;
783 BOLT_SSD_CACHE_LOG(INFO)
784 << "Starting shard " << shardId_ << " without checkpoint";
785 }
786 const auto logPath = fileName_ + kLogExtension;
787 evictLogFd_ = ::open(logPath.c_str(), O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
788 if (evictLogFd_ < 0) {
789 ++stats_.openLogErrors;
790 // Failure to open the log at startup is a process terminating error.
791 BOLT_FAIL(
792 "Could not open evict log {}, rc {}: {}",
793 logPath,
794 evictLogFd_,
795 folly::errnoStr(errno));
796 }
797
798 try {
799 if (hasCheckpoint) {
800 state.exceptions(std::ifstream::failbit);
801 readCheckpoint(state);
802 }
803 } catch (const std::exception& e) {
804 ++stats_.readCheckpointErrors;
805 try {
806 BOLT_SSD_CACHE_LOG(ERROR) << "Error recovering from checkpoint "
807 << e.what() << ": Starting without checkpoint";
808 entries_.clear();
809 deleteCheckpoint(true);
810 } catch (const std::exception&) {
811 }
812 }
813}
814
815bool SsdFile::testingIsCowDisabled() const {
816#ifdef linux
817 int attr{0};
818 const auto res = ioctl(fd_, FS_IOC_GETFLAGS, &attr);

Callers

nothing calls this directly

Calls 2

whatMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected