mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-07 04:52:03 +00:00
fix(cache): use key versioning (#10657)
# Which Problems Are Solved
Cached object may have a different schema between Zitadel versions.
# How the Problems Are Solved
Use the curent build version in DB based cache connectors PostgreSQL and
Redis.
# Additional Changes
- Cleanup the ZitadelVersion field from the authz Instance
- Solve potential race condition on global variables in build package.
# Additional Context
- Closes https://github.com/zitadel/zitadel/issues/10648
- Obsoletes https://github.com/zitadel/zitadel/pull/10646
- Needs to be back-ported to v4 over
https://github.com/zitadel/zitadel/pull/10645
(cherry picked from commit f6f37d3a31)
This commit is contained in:
committed by
Livio Spring
parent
f9b3c1ef50
commit
6e90d4a927
@@ -15,7 +15,6 @@ import (
|
||||
"github.com/zitadel/logging"
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/zitadel/zitadel/cmd/build"
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
@@ -218,7 +217,7 @@ func (q *Queries) InstanceByHost(ctx context.Context, instanceHost, publicHost s
|
||||
publicDomain := strings.Split(publicHost, ":")[0] // remove possible port
|
||||
|
||||
instance, ok := q.caches.instance.Get(ctx, instanceIndexByHost, instanceDomain)
|
||||
if ok && instance.ZitadelVersion == build.Version() {
|
||||
if ok {
|
||||
return instance, instance.checkDomain(instanceDomain, publicDomain)
|
||||
}
|
||||
instance, scan := scanAuthzInstance()
|
||||
@@ -242,7 +241,7 @@ func (q *Queries) InstanceByID(ctx context.Context, id string) (_ authz.Instance
|
||||
}()
|
||||
|
||||
instance, ok := q.caches.instance.Get(ctx, instanceIndexByID, id)
|
||||
if ok && instance.ZitadelVersion == build.Version() {
|
||||
if ok {
|
||||
return instance, nil
|
||||
}
|
||||
|
||||
@@ -251,7 +250,6 @@ func (q *Queries) InstanceByID(ctx context.Context, id string) (_ authz.Instance
|
||||
logging.OnError(err).WithField("instance_id", id).Warn("instance by ID")
|
||||
|
||||
if err == nil {
|
||||
instance.ZitadelVersion = build.Version()
|
||||
q.caches.instance.Set(ctx, instance)
|
||||
}
|
||||
return instance, err
|
||||
@@ -479,7 +477,6 @@ type authzInstance struct {
|
||||
ExternalDomains database.TextArray[string] `json:"external_domains,omitempty"`
|
||||
TrustedDomains database.TextArray[string] `json:"trusted_domains,omitempty"`
|
||||
ExecutionTargets target_domain.Router `json:"execution_targets,omitzero"`
|
||||
ZitadelVersion string `json:"zitadel_version,omitempty"`
|
||||
}
|
||||
|
||||
type csp struct {
|
||||
|
||||
Reference in New Issue
Block a user