From 796e8652a89ec2c87c172d0e84a7cf09223042a9 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 21 Dec 2023 07:28:41 -0600 Subject: [PATCH 1/3] Revert "Potential fix for world gen lockup if files system fails" This reverts commit f65b4205c3949428b42de69de16ba6a0822d1b79. --- .../GeneratedFullDataFileHandler.java | 33 +++++-------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataFileHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataFileHandler.java index cd8215bfa..1fc114b3e 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataFileHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataFileHandler.java @@ -271,33 +271,16 @@ public class GeneratedFullDataFileHandler extends FullDataFileHandler else if (genTaskResult.success) { // generation completed, update the files and listener(s) + this.flushAndSaveAsync(pos).join(); - try + // FIXME this is a bad fix to prevent full data sources saving incomplete, causing holes in the world after generation. + // The problem appears to be that the save may be happening too quickly, + // potentially happening before the meta file has the newly generated data added to it. + CHUNK_GEN_FINISHED_TIMER.schedule(new TimerTask() { - // timeout necessary in case the flush gets stuck or there are issues down stream - // otherwise the world gen might get stuck and never finish - this.flushAndSaveAsync(pos).get(10_000, TimeUnit.MILLISECONDS); - - - // FIXME this is a bad fix to prevent full data sources saving incompletely, causing holes in the world after generation. - // The problem appears to be that the save may be happening too quickly, - // potentially happening before the meta file has the newly generated data added to it. - CHUNK_GEN_FINISHED_TIMER.schedule(new TimerTask() - { - @Override - public void run() { GeneratedFullDataFileHandler.this.flushAndSaveAsync(pos); } - }, 4_000L); - - } - catch (InterruptedException | TimeoutException e) - { - LOGGER.warn("Unable to flush and save after waiting [10] seconds. Error: "+e.getMessage(), e); - } - catch (ExecutionException e) - { - LOGGER.error("Unexpected issue saving world gen result. Error: "+e.getMessage(), e); - } - + @Override + public void run() { GeneratedFullDataFileHandler.this.flushAndSaveAsync(pos).join(); } + }, 4000L); this.fireOnGenPosSuccessListeners(pos); return; From c6ff1b60bb4b8fb2e1e875d7cb95df536bb8f04d Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 21 Dec 2023 07:36:27 -0600 Subject: [PATCH 2/3] Improve fullData logging --- .../sources/HighDetailIncompleteFullDataSource.java | 10 ++++------ .../core/file/fullDatafile/FullDataMetaFile.java | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/HighDetailIncompleteFullDataSource.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/HighDetailIncompleteFullDataSource.java index ec579a6f9..9a3b3ef5e 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/HighDetailIncompleteFullDataSource.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/HighDetailIncompleteFullDataSource.java @@ -149,29 +149,27 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo int dataDetailLevel = inputStream.readShort(); if (dataDetailLevel != dataFile.baseMetaData.dataDetailLevel) { - throw new IOException(LodUtil.formatLog("Data level mismatch: {} != {}", dataDetailLevel, dataFile.baseMetaData.dataDetailLevel)); + throw new IOException("Data level mismatch: ["+dataDetailLevel+"] != ["+dataFile.baseMetaData.dataDetailLevel+"]"); } // confirm that the detail level is correct int sparseDetail = inputStream.readShort(); if (sparseDetail != SPARSE_UNIT_DETAIL) { - throw new IOException((LodUtil.formatLog("Unexpected sparse detail level: {} != {}", - sparseDetail, SPARSE_UNIT_DETAIL))); + throw new IOException("Unexpected sparse detail level: ["+sparseDetail+"] != ["+SPARSE_UNIT_DETAIL+"]"); } // confirm the scale of the data points is correct int sectionSize = inputStream.readInt(); if (sectionSize != SECTION_SIZE) { - throw new IOException(LodUtil.formatLog( - "Section size mismatch: {} != {} (Currently only 1 section size is supported)", sectionSize, SECTION_SIZE)); + throw new IOException("Section size mismatch: ["+sectionSize+"] != ["+SECTION_SIZE+"] (Currently only 1 section size is supported)"); } int minY = inputStream.readInt(); if (minY != level.getMinY()) { - LOGGER.warn("Data minY mismatch: " + minY + " != " + level.getMinY() + ". Will ignore data's y level"); + LOGGER.warn("Data minY mismatch: [" + minY + "] != [" + level.getMinY() + "]. Will ignore data's y level"); } EDhApiWorldGenerationStep worldGenStep = EDhApiWorldGenerationStep.fromValue(inputStream.readByte()); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataMetaFile.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataMetaFile.java index 9a2c9f74a..46e95c3ac 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataMetaFile.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataMetaFile.java @@ -299,7 +299,7 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile implements I } catch (Exception ex) { - LOGGER.error("Full Data Load error: "+ ex.getMessage(), ex); + LOGGER.error("Full Data Load error for pos ["+this.pos+"], error: "+ ex.getMessage(), ex); dataSourceLoadFuture.completeExceptionally(ex); dataSourceLoadFutureRef.set(null); From 47b6730f63496435915ba84793abdf72aaa166b1 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 21 Dec 2023 07:48:18 -0600 Subject: [PATCH 3/3] disable full data file pooling (temporary fix) --- .../core/file/fullDatafile/FullDataMetaFile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataMetaFile.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataMetaFile.java index 46e95c3ac..52f7ae1f9 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataMetaFile.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataMetaFile.java @@ -178,7 +178,7 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile implements I - public CompletableFuture getDataSourceWithoutCachingAsync() { return this.getOrLoadCachedDataSourceAsync(false); } + public CompletableFuture getDataSourceWithoutCachingAsync() { return this.getOrLoadCachedDataSourceAsync(true); } public CompletableFuture getOrLoadCachedDataSourceAsync() { return this.getOrLoadCachedDataSourceAsync(true); } /** * Synchronized to help prevent issues where multiple threads try to read as cached and un-cached at the same time.