-- test_abort_unlocked.lua -- -- gl_abort_transaction only removes the stage of the context holding the -- scope's lock. A context whose gl_init_stage_context lost the race (or -- never began) used to wipe the stage anyway, i.e. the running -- transaction of whoever DID hold the lock. local glacier = require("glacier_ffi") local h = require("test_helpers") h.reset_glacier_root() local uid = 1001 io.write("== test_abort_unlocked (uid " .. uid .. ") ==\n") glacier.lib.gl_init_user(uid, false) local ctx1 = glacier.new_context() local st1 = glacier.lib.gl_init_stage_context(ctx1, glacier.SCOPE_USR, uid) h.check(tonumber(st1) == 0, "first stage context acquires the lock: " .. glacier.txn_name(st1)) local stage = "/glacier/usr/" .. uid .. "/stage" h.check(h.exists(stage .. "/index"), "the first context's stage exists") local ctx2 = glacier.new_context() local st2 = glacier.lib.gl_init_stage_context(ctx2, glacier.SCOPE_USR, uid) h.check(tonumber(st2) == 1, "second context is refused the lock: " .. glacier.txn_name(st2)) local ab = glacier.lib.gl_abort_transaction(ctx2) h.check(tonumber(ab) == 7, "aborting without the lock is GL_TXN_ERR_NO_TXN: " .. glacier.txn_name(ab)) h.check(h.exists(stage .. "/index"), "...and leaves the lock holder's stage alone") glacier.lib.gl_abort_transaction(ctx1) h.check(not h.exists(stage), "the lock holder's own abort removes it") h.summary()