Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,7 @@ void clearClientConnectionState(client *c) {
c->flag.reply_skip_next = 0;
c->flag.no_touch = 0;
c->flag.no_evict = 0;
c->flag.import_source = 0;
}

/* Free the client structure and all the data associated with it.
Expand Down
43 changes: 43 additions & 0 deletions tests/unit/expire.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,49 @@ start_server {tags {"expire"}} {
}
}

test {RESET clears the import-source flag} {
r config set import-mode yes
assert_equal [r client import-source on] {OK}
assert_match {*flags=I*} [r client list id [r client id]]

# RESET must make the connection resemble a fresh client, which
# includes dropping the import-source privilege.
r reset
assert_match {*flags=N*} [r client list id [r client id]]

r config set import-mode no
} {OK} {needs:reset}

test {RESET drops import-source expiration semantics} {
r flushall
r config set import-mode yes

r set foo1 1 PX 1
after 10

# While import-source is on, the expired key is visible.
assert_equal [r client import-source on] {OK}
assert_match {*flags=I*} [r client list id [r client id]]
assert_equal [r ttl foo1] {0}
assert_equal [r get foo1] {1}

# After RESET the connection must lose import-source semantics, so the
# logically-expired key looks missing again, exactly like a fresh client.
r reset
assert_match {*flags=N*} [r client list id [r client id]]
assert_equal [r get foo1] {}
assert_equal [r ttl foo1] {-2}

r config set import-mode no

# Verify all keys have expired (cleanup, mirrors the import-source tests).
wait_for_condition 40 100 {
[r dbsize] eq 0
} else {
fail "Keys did not actively expire."
}
} {} {needs:reset}

test {replicaKeysWithExpire memory leak verification and cleanup} {
# This test verifies the memory leak issue and cleanup mechanism for replicaKeysWithExpire

Expand Down
Loading