From 3ac8d64e641fa9cd6a5235a3ab01dccb1c1d43a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=84=9E?= Date: Sat, 7 Dec 2024 19:29:17 +0800 Subject: [PATCH] Update WALFileStream.java --- rxlib/src/main/java/org/rx/io/WALFileStream.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rxlib/src/main/java/org/rx/io/WALFileStream.java b/rxlib/src/main/java/org/rx/io/WALFileStream.java index fd024c7d..518398a8 100644 --- a/rxlib/src/main/java/org/rx/io/WALFileStream.java +++ b/rxlib/src/main/java/org/rx/io/WALFileStream.java @@ -346,17 +346,17 @@ public void write(ByteBuf src, int length) { } private void ensureWrite(BiAction action) { - long logPosition = meta.logPos; + long logPos = meta.logPos; lock.writeInvoke(() -> { - if (logPosition != meta.logPos) { - throw new InvalidException("Concurrent error"); -// log.warn("Fallback lock"); -// lock.writeInvoke(() -> innerWrite(meta.getLogPosition(), action)); -// return; + if (logPos != meta.logPos) { +// throw new InvalidException("Concurrent error"); + log.warn("Fallback to global lock <- pos:{}", logPos); + lock.writeInvoke(() -> innerWrite(meta.logPos, action)); + return; } - innerWrite(logPosition, action); - }, logPosition); + innerWrite(logPos, action); + }, logPos); } void innerWrite(long logPosition, BiAction action) {