MCPcopy Index your code
hub / github.com/questdb/questdb / reportCrashFiles

Method reportCrashFiles

core/src/main/java/io/questdb/Bootstrap.java:270–303  ·  view source on GitHub ↗
(CairoConfiguration cairoConfiguration, Log log)

Source from the content-addressed store, hash-verified

268 }
269
270 public static void reportCrashFiles(CairoConfiguration cairoConfiguration, Log log) {
271 final CharSequence dbRoot = cairoConfiguration.getDbRoot();
272 final FilesFacade ff = cairoConfiguration.getFilesFacade();
273 final int maxFiles = cairoConfiguration.getMaxCrashFiles();
274 DirectUtf8StringZ name = new DirectUtf8StringZ();
275 try (Path path = new Path(); Path other = new Path()) {
276 path.of(dbRoot).slash();
277 other.of(dbRoot).slash();
278
279 int plen = path.size();
280 AtomicInteger counter = new AtomicInteger(0);
281 FilesFacadeImpl.INSTANCE.iterateDir(path.$(), (pUtf8NameZ, type) -> {
282 if (Files.notDots(pUtf8NameZ)) {
283 name.of(pUtf8NameZ);
284 if (Utf8s.startsWithAscii(name, cairoConfiguration.getOGCrashFilePrefix()) && type == Files.DT_FILE) {
285 path.trimTo(plen).concat(pUtf8NameZ).$();
286 boolean shouldRename = false;
287 do {
288 other.trimTo(plen).concat(cairoConfiguration.getArchivedCrashFilePrefix()).put(counter.getAndIncrement()).put(".log").$();
289 if (!ff.exists(other.$())) {
290 shouldRename = counter.get() <= maxFiles;
291 break;
292 }
293 } while (counter.get() < maxFiles);
294 if (shouldRename && ff.rename(path.$(), other.$()) == 0) {
295 log.critical().$("found crash file [path=").$(other).I$();
296 } else {
297 log.critical().$("could not rename crash file [path=").$(path).$(", errno=").$(ff.errno()).$(", index=").$(counter.get()).$(", max=").$(maxFiles).I$();
298 }
299 }
300 }
301 });
302 }
303 }
304
305 public void extractSite() throws IOException {
306 final byte[] buffer = new byte[1024 * 1024];

Callers 2

testReportCrashFilesMethod · 0.95
BootstrapMethod · 0.95

Calls 15

notDotsMethod · 0.95
ofMethod · 0.95
startsWithAsciiMethod · 0.95
existsMethod · 0.95
renameMethod · 0.95
errnoMethod · 0.95
slashMethod · 0.80
getOGCrashFilePrefixMethod · 0.80
concatMethod · 0.80
I$Method · 0.80
getDbRootMethod · 0.65

Tested by 1

testReportCrashFilesMethod · 0.76