summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahooinc.com>2022-06-21 09:19:20 +0000
committerArne H Juul <arnej@yahooinc.com>2022-06-21 09:23:37 +0000
commit23bb4a910a0c12b7204b3fb29deea43abd514007 (patch)
tree02bc26452489249af25815bbf18678a3c3c23465 /searchcore
parentc0c7d649f1340adc8e614db8f7156e89b7f95314 (diff)
probe base directory
* this is mainly useful for the case where the filesystem with our data is mounted read-only because the OS detected that something was bad.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp
index ff5924fa6bc..00447fc9ba1 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp
@@ -149,8 +149,21 @@ const vespalib::string CUSTOM_COMPONENT_API_PATH = "/state/v1/custom/component";
VESPA_THREAD_STACK_TAG(proton_initialize_executor)
VESPA_THREAD_STACK_TAG(proton_close_executor)
+void ensureWritableDir(const vespalib::string &dirName) {
+ int pidnum = ::getpid();
+ int secnum = ::time(0);
+ auto pidstr = std::to_string(pidnum);
+ auto secstr = std::to_string(secnum);
+ auto filename = dirName + "/tmp.file." + pidstr + "." + secstr;
+ vespalib::File probe(filename);
+ probe.open(vespalib::File::CREATE);
+ probe.write("probe\n", 6, 0);
+ probe.close();
+ probe.unlink();
}
+} // namespace <unnamed>
+
Proton::ProtonFileHeaderContext::ProtonFileHeaderContext(const vespalib::string &creator)
: _hostName(),
_creator(creator),
@@ -278,6 +291,7 @@ Proton::init(const BootstrapConfig::SP & configSnapshot)
{
assert( _initStarted && ! _initComplete );
const ProtonConfig &protonConfig = configSnapshot->getProtonConfig();
+ ensureWritableDir(protonConfig.basedir);
const HwInfo & hwInfo = configSnapshot->getHwInfo();
_hw_info = hwInfo;