Skip to content

Commit

Permalink
Fix redis transaction registry (#184)
Browse files Browse the repository at this point in the history
* fix(redis_transaction_registry): decouple from keepTTL marker in set command, available only from version > 6.x

* fix: failing test kill_query
  • Loading branch information
gontarzpawel authored Jul 7, 2022
1 parent f4a34c3 commit c63bb7c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cache/transaction_registry_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (r *redisTransactionRegistry) Fail(key *Key) error {
}

func (r *redisTransactionRegistry) updateTransactionState(key *Key, state TransactionState) error {
return r.redisClient.Set(context.Background(), toTransactionKey(key), uint64(state), redis.KeepTTL).Err()
return r.redisClient.Set(context.Background(), toTransactionKey(key), uint64(state), r.deadline).Err()
}

func (r *redisTransactionRegistry) Status(key *Key) (TransactionState, error) {
Expand Down
6 changes: 3 additions & 3 deletions proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,14 +467,14 @@ func TestKillQuery(t *testing.T) {
name: "timeout user",
f: func(p *reverseProxy) *http.Response {
p.users["default"].maxExecutionTime = time.Millisecond * 10
return makeHeavyRequest(p, time.Millisecond*20)
return makeHeavyRequest(p, time.Millisecond*40)
},
},
{
name: "timeout cluster user",
f: func(p *reverseProxy) *http.Response {
p.clusters["cluster"].users["web"].maxExecutionTime = time.Millisecond * 10
return makeHeavyRequest(p, time.Millisecond*20)
return makeHeavyRequest(p, time.Millisecond*40)
},
},
}
Expand All @@ -492,7 +492,7 @@ func TestKillQuery(t *testing.T) {
t.Fatalf("expected Id to be extracted from %q", b)
}

time.Sleep(time.Millisecond * 30)
time.Sleep(time.Millisecond * 50)
state, err := registry.get(id)
if err != nil {
t.Fatalf("unexpected requestRegistry err for key %q: %s", id, err)
Expand Down

0 comments on commit c63bb7c

Please sign in to comment.