mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 12:06:01 +01:00
BasicClientConnection::queryPathInfo(): Don't throw exception for invalid paths
This caused RemoteStore::queryPathInfoUncached() to mark the
connection as invalid (see
RemoteStore::ConnectionHandle::~ConnectionHandle()), causing it to
disconnect and reconnect after every lookup of an invalid path. This
caused huge slowdowns in conjunction with
19f89eb684 and lazy-trees.
This commit is contained in:
parent
48b600d995
commit
c82b67fa05
3 changed files with 12 additions and 10 deletions
|
|
@ -109,7 +109,8 @@ struct WorkerProto::BasicClientConnection : WorkerProto::BasicConnection
|
|||
const StorePathSet & paths,
|
||||
SubstituteFlag maybeSubstitute);
|
||||
|
||||
UnkeyedValidPathInfo queryPathInfo(const StoreDirConfig & store, bool * daemonException, const StorePath & path);
|
||||
std::optional<UnkeyedValidPathInfo>
|
||||
queryPathInfo(const StoreDirConfig & store, bool * daemonException, const StorePath & path);
|
||||
|
||||
void putBuildDerivationRequest(
|
||||
const StoreDirConfig & store,
|
||||
|
|
|
|||
|
|
@ -259,13 +259,14 @@ void RemoteStore::queryPathInfoUncached(
|
|||
const StorePath & path, Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept
|
||||
{
|
||||
try {
|
||||
std::shared_ptr<const ValidPathInfo> info;
|
||||
{
|
||||
auto info = ({
|
||||
auto conn(getConnection());
|
||||
info = std::make_shared<ValidPathInfo>(
|
||||
StorePath{path}, conn->queryPathInfo(*this, &conn.daemonException, path));
|
||||
}
|
||||
callback(std::move(info));
|
||||
conn->queryPathInfo(*this, &conn.daemonException, path);
|
||||
});
|
||||
if (!info)
|
||||
callback(nullptr);
|
||||
else
|
||||
callback(std::make_shared<ValidPathInfo>(StorePath{path}, *info));
|
||||
} catch (...) {
|
||||
callback.rethrow();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ void WorkerProto::BasicServerConnection::postHandshake(const StoreDirConfig & st
|
|||
WorkerProto::write(store, *this, info);
|
||||
}
|
||||
|
||||
UnkeyedValidPathInfo WorkerProto::BasicClientConnection::queryPathInfo(
|
||||
std::optional<UnkeyedValidPathInfo> WorkerProto::BasicClientConnection::queryPathInfo(
|
||||
const StoreDirConfig & store, bool * daemonException, const StorePath & path)
|
||||
{
|
||||
to << WorkerProto::Op::QueryPathInfo << store.printStorePath(path);
|
||||
|
|
@ -253,14 +253,14 @@ UnkeyedValidPathInfo WorkerProto::BasicClientConnection::queryPathInfo(
|
|||
} catch (Error & e) {
|
||||
// Ugly backwards compatibility hack.
|
||||
if (e.msg().find("is not valid") != std::string::npos)
|
||||
throw InvalidPath(std::move(e.info()));
|
||||
return std::nullopt;
|
||||
throw;
|
||||
}
|
||||
if (GET_PROTOCOL_MINOR(protoVersion) >= 17) {
|
||||
bool valid;
|
||||
from >> valid;
|
||||
if (!valid)
|
||||
throw InvalidPath("path '%s' is not valid", store.printStorePath(path));
|
||||
return std::nullopt;
|
||||
}
|
||||
return WorkerProto::Serialise<UnkeyedValidPathInfo>::read(store, *this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue