fix: harden exception handling, break ARC cycles, sync license/client
CI / test (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
CI / test (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
Replace bare except: with CatchableError across storage, query, Raft, backup, and protocol code so Defects are not swallowed. Break uncollectable ARC cycles in server shard/gossip callbacks via Server-owned refs and cursor locals. Align package license with LICENSE (BSD-3-Clause), sync README version, and point test_all at the canonical clients/nim baradb client (parseConnectionString + aliases).
This commit is contained in:
@@ -58,7 +58,7 @@ proc rebuildFromLSM*(cs: CompactionStrategy, db: LSMTree) =
|
||||
cs.clear()
|
||||
cs.dataDir = db.dir
|
||||
for sst in db.sstables:
|
||||
let size = try: int(getFileSize(sst.path)) except: sst.entryCount * 64
|
||||
let size = try: int(getFileSize(sst.path)) except CatchableError: sst.entryCount * 64
|
||||
cs.addTable(SSTableMeta(
|
||||
path: sst.path,
|
||||
level: sst.level,
|
||||
@@ -143,7 +143,7 @@ proc compact*(cs: CompactionStrategy, level: int): CompactionResult =
|
||||
var sst = writeSSTable(final, outputPath, level + 1)
|
||||
|
||||
# Use actual file size instead of rough guess
|
||||
let actualSize = try: getFileSize(outputPath) except: final.len * 64
|
||||
let actualSize = try: getFileSize(outputPath) except CatchableError: final.len * 64
|
||||
|
||||
let outputMeta = SSTableMeta(
|
||||
path: outputPath,
|
||||
@@ -159,7 +159,7 @@ proc compact*(cs: CompactionStrategy, level: int): CompactionResult =
|
||||
let (ok, msg) = verifySSTable(outputPath)
|
||||
if not ok:
|
||||
echo "[ERROR] Compaction output verification failed: ", msg
|
||||
try: removeFile(outputPath) except: discard
|
||||
try: removeFile(outputPath) except CatchableError: discard
|
||||
return CompactionResult()
|
||||
|
||||
# Remove old SSTable files
|
||||
|
||||
@@ -18,13 +18,15 @@ var
|
||||
|
||||
proc initStorageGate*() =
|
||||
## Idempotent when called from a single thread at startup.
|
||||
## Must run before multi-threaded accept (HTTP workers / TCP).
|
||||
if not gInited:
|
||||
initLock(gGate)
|
||||
gInited = true
|
||||
|
||||
proc acquireStorageGate*() {.inline.} =
|
||||
## Prefer calling initStorageGate() once at process start (main).
|
||||
## Lazy-init is allowed for unit tests (single-threaded).
|
||||
## Lazy-init is only safe for single-threaded unit tests — concurrent
|
||||
## first-time init races on gInited / initLock.
|
||||
if not gInited:
|
||||
initStorageGate()
|
||||
acquire(gGate)
|
||||
|
||||
@@ -473,7 +473,7 @@ proc listLegacySSTables*(dir: string): seq[(string, uint32)] =
|
||||
let sst = loadSSTable(path)
|
||||
if sst.fileVersion < SSTableVersion:
|
||||
result.add((path, sst.fileVersion))
|
||||
except:
|
||||
except CatchableError:
|
||||
discard
|
||||
|
||||
proc migrateSSTable*(path: string): bool =
|
||||
@@ -595,7 +595,7 @@ proc checkStorageConsistency*(db: LSMTree): seq[string] =
|
||||
let j = parseJson(readFile(manifestPath))
|
||||
for node in j{"sstables"}:
|
||||
manifestPaths.add(node{"path"}.getStr())
|
||||
except:
|
||||
except CatchableError:
|
||||
result.add("MANIFEST is corrupt or unreadable")
|
||||
return
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ proc parseWalSequence*(filename: string): int64 =
|
||||
result = parseBiggestInt(numStr)
|
||||
else:
|
||||
result = 0
|
||||
except:
|
||||
except CatchableError:
|
||||
result = 0
|
||||
|
||||
proc listWalArchive*(dir: string): seq[WalSegment] =
|
||||
@@ -90,7 +90,7 @@ proc listWalArchive*(dir: string): seq[WalSegment] =
|
||||
if kind == pcFile and path.endsWith(".log"):
|
||||
let seqNum = parseWalSequence(extractFilename(path))
|
||||
if seqNum > 0:
|
||||
let size = try: getFileSize(path) except: 0
|
||||
let size = try: getFileSize(path) except CatchableError: 0
|
||||
result.add(WalSegment(sequence: seqNum, path: path, size: size))
|
||||
result.sort(proc(a, b: WalSegment): int = cmp(a.sequence, b.sequence))
|
||||
|
||||
@@ -140,7 +140,7 @@ proc maybeRotate*(wal: var WriteAheadLog) =
|
||||
## Rotate if current WAL exceeds max segment size.
|
||||
if wal.maxSegmentSize <= 0:
|
||||
return
|
||||
let currentSize = try: getFileSize(wal.path) except: 0
|
||||
let currentSize = try: getFileSize(wal.path) except CatchableError: 0
|
||||
if currentSize >= wal.maxSegmentSize:
|
||||
wal.rotate()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user