Code - improving unique key fix for history database handler (#2402)

* improving unique key fix

* also bump timestamp along 1 sec
This commit is contained in:
dgtlmoon
2024-06-06 22:59:04 +02:00
committed by GitHub
parent 6aded50aca
commit de48892243
2 changed files with 3 additions and 4 deletions

View File

@@ -333,7 +333,9 @@ class model(dict):
# Small hack so that we sleep just enough to allow 1 second between history snapshots
# this is because history.txt indexes/keys snapshots by epoch seconds and we dont want dupe keys
if self.__newest_history_key and int(timestamp) == int(self.__newest_history_key):
time.sleep(timestamp - self.__newest_history_key)
logger.warning(f"Timestamp {timestamp} already exists, waiting 1 seconds so we have a unique key in history.txt")
timestamp = str(int(timestamp) + 1)
time.sleep(1)
threshold = int(os.getenv('SNAPSHOT_BROTLI_COMPRESSION_THRESHOLD', 1024))
skip_brotli = strtobool(os.getenv('DISABLE_BROTLI_TEXT_SNAPSHOT', 'False'))