mirror of
https://gitlab.nic.cz/knot/knot-dns.git
synced 2026-02-03 18:49:28 -05:00
redis: remove empty diff formed by add/rem canceling
This commit is contained in:
parent
0b9ab4de1c
commit
523da287cd
2 changed files with 23 additions and 1 deletions
|
|
@ -874,14 +874,22 @@ static exception_t upd_add_rem(RedisModuleCtx *ctx, const arg_dname_t *origin,
|
|||
} else {
|
||||
RedisModule_Assert(RedisModule_ModuleTypeGetType(diff_key) == rdb_diff_t);
|
||||
}
|
||||
RedisModule_FreeString(ctx, diff_keystr);
|
||||
|
||||
ret = cb(diff, data, ttl);
|
||||
if (ret == KNOT_EEXIST) {
|
||||
RedisModule_FreeString(ctx, diff_keystr);
|
||||
RedisModule_CloseKey(diff_key);
|
||||
throw(KNOT_EEXIST, RDB_EEXIST);
|
||||
}
|
||||
|
||||
if (diff->add_rrs.count == 0 && diff->rem_rrs.count == 0) {
|
||||
index_k diff_index_key = get_upd_index(ctx, origin, txn, id, REDISMODULE_READ | REDISMODULE_WRITE);
|
||||
RedisModule_ZsetRem(diff_index_key, diff_keystr, NULL);
|
||||
RedisModule_CloseKey(diff_index_key);
|
||||
RedisModule_DeleteKey(diff_key);
|
||||
}
|
||||
|
||||
RedisModule_FreeString(ctx, diff_keystr);
|
||||
RedisModule_CloseKey(diff_key);
|
||||
return_ok;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -450,6 +450,20 @@ def test_upd_commit():
|
|||
resp = env.cmd('KNOT.UPD.LOAD', 'example.com', 1, 1)
|
||||
env.assertEqual(len(resp), 1, message="Failed to commit update")
|
||||
|
||||
# add/remove canceling
|
||||
txn1 = env.cmd('KNOT.ZONE.BEGIN', 'example.com', 1)
|
||||
env.cmd('KNOT.ZONE.STORE', 'example.com', txn1, "@ IN SOA ns.icann.org. noc.dns.icann.org. ( 1 7200 3600 1209600 3600 )")
|
||||
env.cmd('KNOT.ZONE.COMMIT', 'example.com', txn1)
|
||||
|
||||
txn = env.cmd('KNOT.UPD.BEGIN', 'example.com', 1)
|
||||
env.cmd('KNOT.UPD.ADD', 'example.com', txn, "cancel TXT test")
|
||||
env.cmd('KNOT.UPD.REMOVE', 'example.com', txn, "cancel TXT test")
|
||||
env.cmd('KNOT.UPD.ADD', 'example.com', txn, "cancel2 TXT test2")
|
||||
env.cmd('KNOT.UPD.REMOVE', 'example.com', txn, "cancel2 TXT test2")
|
||||
env.cmd('KNOT.UPD.COMMIT', 'example.com', txn)
|
||||
resp = env.cmd('KNOT.UPD.LOAD', 'example.com', 1, 1)
|
||||
env.assertEqual(len(resp[0]), 1, message="Failed to commit update")
|
||||
|
||||
def test_upd_abort():
|
||||
env = Env(moduleArgs=['max-event-age', '60', 'default-ttl', '3600'])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue