MCPcopy Create free account
hub / github.com/apple/foundationdb / sync_impl

Method sync_impl

fdbrpc/sim2.actor.cpp:768–810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

766
767 // Simulated sync does not actually do anything besides wait a random amount of time
768 ACTOR static Future<Void> sync_impl(SimpleFile* self) {
769 state UID opId = deterministicRandom()->randomUniqueID();
770 if (randLog)
771 fprintf(randLog,
772 "SFC1 %s %s %s\n",
773 self->dbgId.shortString().c_str(),
774 self->filename.c_str(),
775 opId.shortString().c_str());
776
777 if (self->delayOnWrite)
778 wait(waitUntilDiskReady(self->diskParameters, 0, true));
779
780 if (self->flags & OPEN_ATOMIC_WRITE_AND_CREATE) {
781 self->flags &= ~OPEN_ATOMIC_WRITE_AND_CREATE;
782 auto& machineCache = g_simulator.getCurrentProcess()->machine->openFiles;
783 std::string sourceFilename = self->filename + ".part";
784
785 if (machineCache.count(sourceFilename)) {
786 TraceEvent("SimpleFileRename")
787 .detail("From", sourceFilename)
788 .detail("To", self->filename)
789 .detail("SourceCount", machineCache.count(sourceFilename))
790 .detail("FileCount", machineCache.count(self->filename));
791 renameFile(sourceFilename.c_str(), self->filename.c_str());
792
793 machineCache[self->filename] = machineCache[sourceFilename];
794 machineCache.erase(sourceFilename);
795 self->actualFilename = self->filename;
796 }
797 }
798
799 if (randLog)
800 fprintf(randLog,
801 "SFC2 %s %s %s\n",
802 self->dbgId.shortString().c_str(),
803 self->filename.c_str(),
804 opId.shortString().c_str());
805
806 INJECT_FAULT(io_timeout, "SimpleFile::sync"); // SimpleFile::sync inject io_timeout
807 INJECT_FAULT(io_error, "SimpleFile::sync"); // SimpleFile::sync inject io_errot
808
809 return Void();
810 }
811
812 ACTOR static Future<int64_t> size_impl(SimpleFile const* self) {
813 state UID opId = deterministicRandom()->randomUniqueID();

Callers

nothing calls this directly

Calls 13

deterministicRandomFunction · 0.85
fprintfFunction · 0.85
waitUntilDiskReadyFunction · 0.85
TraceEventClass · 0.85
renameFileFunction · 0.85
randomUniqueIDMethod · 0.80
shortStringMethod · 0.80
getCurrentProcessMethod · 0.80
detailMethod · 0.80
VoidClass · 0.70
countMethod · 0.65
c_strMethod · 0.45

Tested by

no test coverage detected