Remove transaction inheritance
Transaction inheritance causes issues such as: 1. higher fragmentation in the db file, causing storage inefficiencies. 2. stale transactions holding an old view of the database, causing notes to be unavailable in certain scenarios This should be safe because direct access to transactions is hidden within the NostrDB Swift modules behind safe interfaces that prevent direct access, thus reducing or eliminating the chance of accidentally starting two transactions within the same thread (which would cause a deadlock). Closes: https://github.com/damus-io/damus/issues/3681 Changelog-Fixed: Disabled transaction inhe Signed-off-by: Daniel D’Aquino <daniel@daquino.me> Co-Authored-By: alltheseas <alltheseas@users.noreply.github.com>
This commit is contained in:
co-authored by
alltheseas
parent
0a801b01cb
commit
c1fb8b592f
@@ -164,25 +164,6 @@ final class NdbTests: XCTestCase {
|
||||
let testNote = NdbNote.owned_from_json(json: testJSONWithEscapedSlashes)!
|
||||
XCTAssertEqual(testNote.content, "https://cdn.nostr.build/i/5c1d3296f66c2630131bf123106486aeaf051ed8466031c0e0532d70b33cddb2.jpg")
|
||||
}
|
||||
|
||||
func test_inherited_transactions() throws {
|
||||
let ndb = Ndb(path: db_dir)!
|
||||
do {
|
||||
guard let txn1 = NdbTxn(ndb: ndb) else { return XCTAssert(false) }
|
||||
|
||||
let ntxn = (Thread.current.threadDictionary.value(forKey: "ndb_txn") as? ndb_txn)!
|
||||
XCTAssertEqual(txn1.txn.lmdb, ntxn.lmdb)
|
||||
XCTAssertEqual(txn1.txn.mdb_txn, ntxn.mdb_txn)
|
||||
|
||||
guard let txn2 = NdbTxn(ndb: ndb) else { return XCTAssert(false) }
|
||||
|
||||
XCTAssertEqual(txn1.inherited, false)
|
||||
XCTAssertEqual(txn2.inherited, true)
|
||||
}
|
||||
|
||||
let ndb_txn = Thread.current.threadDictionary.value(forKey: "ndb_txn")
|
||||
XCTAssertNil(ndb_txn)
|
||||
}
|
||||
|
||||
func test_decode_perf() throws {
|
||||
// This is an example of a performance test case.
|
||||
|
||||
Reference in New Issue
Block a user