Bug fix: Killing a machine process would not wait for AsyncFileNonDurable close operations to finish, causing a later reopen of the same file in a new process to hang forever. Renamed AsyncFileNonDurable::deleteFile to closeFile for clarity. Renamed Machine deletingFiles to deletingOrClosingFiles for clarity. ()

This commit is contained in:
Steve Atherton 2022-04-29 14:01:18 -07:00 committed by GitHub
parent 504400c1b3
commit 338d2304d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 6 deletions

View File

@ -276,7 +276,7 @@ public:
if (delref_no_destroy()) {
if (filesBeingDeleted.count(filename) == 0) {
//TraceEvent("AsyncFileNonDurable_StartDelete", id).detail("Filename", filename);
Future<Void> deleteFuture = deleteFile(this);
Future<Void> deleteFuture = closeFile(this);
if (!deleteFuture.isReady())
filesBeingDeleted[filename] = deleteFuture;
}
@ -824,11 +824,13 @@ private:
}
// Finishes all outstanding actors on an AsyncFileNonDurable and then deletes it
ACTOR Future<Void> deleteFile(AsyncFileNonDurable* self) {
ACTOR Future<Void> closeFile(AsyncFileNonDurable* self) {
state ISimulator::ProcessInfo* currentProcess = g_simulator.getCurrentProcess();
state TaskPriority currentTaskID = g_network->getCurrentTask();
state std::string filename = self->filename;
g_simulator.getMachineByNetworkAddress(self->openedAddress)->deletingOrClosingFiles.insert(self->getFilename());
wait(g_simulator.onMachine(currentProcess));
try {
// Make sure all writes have gone through.
@ -853,7 +855,8 @@ private:
// Remove this file from the filesBeingDeleted map so that new files can be created with this filename
g_simulator.getMachineByNetworkAddress(self->openedAddress)->closingFiles.erase(self->getFilename());
g_simulator.getMachineByNetworkAddress(self->openedAddress)->deletingFiles.erase(self->getFilename());
g_simulator.getMachineByNetworkAddress(self->openedAddress)
->deletingOrClosingFiles.erase(self->getFilename());
AsyncFileNonDurable::filesBeingDeleted.erase(self->filename);
//TraceEvent("AsyncFileNonDurable_FinishDelete", self->id).detail("Filename", self->filename);

View File

@ -1147,7 +1147,7 @@ public:
// for the existence of a non-durably deleted file BEFORE a reboot will show that it apparently doesn't exist.
if (g_simulator.getCurrentProcess()->machine->openFiles.count(filename)) {
g_simulator.getCurrentProcess()->machine->openFiles.erase(filename);
g_simulator.getCurrentProcess()->machine->deletingFiles.insert(filename);
g_simulator.getCurrentProcess()->machine->deletingOrClosingFiles.insert(filename);
}
if (mustBeDurable || deterministicRandom()->random01() < 0.5) {
state ISimulator::ProcessInfo* currentProcess = g_simulator.getCurrentProcess();

View File

@ -203,7 +203,7 @@ public:
// A map from filename to file handle for all open files on a machine
std::map<std::string, UnsafeWeakFutureReference<IAsyncFile>> openFiles;
std::set<std::string> deletingFiles;
std::set<std::string> deletingOrClosingFiles;
std::set<std::string> closingFiles;
Optional<Standalone<StringRef>> machineId;

View File

@ -901,7 +901,7 @@ ACTOR Future<Void> simulatedMachine(ClusterConnectionString connStr,
ASSERT(it.second.get().canGet());
}
for (auto it : g_simulator.getMachineById(localities.machineId())->deletingFiles) {
for (auto it : g_simulator.getMachineById(localities.machineId())->deletingOrClosingFiles) {
filenames.insert(it);
closingStr += it + ", ";
}