Redis Should the SWAPDB command set CLIENT_DIRTY_CAS?

I think step3 should fail, because k=1 in db1, not the original set k 2.

The current code handles db->blocking_keys, but does not handle db->watched_keys. I think the CLIENT_DIRTY_CAS flag should be set so that exec returns nil, the example code is as follows:

    dictIterator *di = dictGetSafeIterator(db->watched_keys);
    while((de = dictNext(di)) != NULL) {
        list *clients = dictGetVal(de);
        if (!clients) continue;
        /* Mark all the clients watching this key as CLIENT_DIRTY_CAS */
        listRewind(clients,&li);
        while((ln = listNext(&li))) {
            client *c = listNodeValue(ln);
            c->flags |= CLIENT_DIRTY_CAS;
        }
    }
    dictReleaseIterator(di);

Tracking does not need to be processed, because tracking does not distinguish db, and the value of key has not changed.

Comment From: hwware

same thoughts here, I also noticed this issue before..IMHO the swapdb should make transaction fail if there is any client watching keys..

Comment From: madolson

I agree, we should fix this.