Skip to content

Commit 3937712

Browse files
authored
Merge branch 'master' into create-workflow-retry-actor-not-found-master
2 parents 355d76c + 7fa2686 commit 3937712

File tree

67 files changed

+749
-233
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+749
-233
lines changed

.build-tools/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module build-tools
22

3-
go 1.24.1
3+
go 1.24.4
44

55
require (
66
github.com/google/go-containerregistry v0.11.1-0.20220802162123-c1f9836a4fa9

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ MODFILES := $(shell find . -name go.mod)
424424
define modtidy-target
425425
.PHONY: modtidy-$(1)
426426
modtidy-$(1):
427-
cd $(shell dirname $(1)); CGO_ENABLED=$(CGO) go mod tidy -compat=1.24.1; cd -
427+
cd $(shell dirname $(1)); CGO_ENABLED=$(CGO) go mod tidy -compat=1.24.4; cd -
428428
endef
429429

430430
# Generate modtidy target action for each go.mod file

docker/Dockerfile-debug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# current directory must be ./dist
22

3-
FROM golang:1.24.1
3+
FROM golang:1.24.4
44

55
ARG PKG_FILES
66
RUN go install github.com/go-delve/delve/cmd/dlv@latest

docker/Dockerfile-dev

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Based on https://github.com/microsoft/vscode-dev-containers/tree/v0.224.3/containers/go/.devcontainer/base.Dockerfile
22

3-
# [Choice] Go version: 1, 1.24.3, etc
4-
ARG GOVERSION=1.24.3
3+
# [Choice] Go version: 1, 1.24.4, etc
4+
ARG GOVERSION=1.24.4
55
FROM golang:${GOVERSION}-bullseye
66

77
# [Option] Install zsh

docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This includes dockerfiles to build Dapr release and debug images and development
1212

1313
The Dev Container can be rebuilt with custom options. Relevant args (and their default values) include:
1414

15-
* `GOVERSION` (default: `1.24.1`)
15+
* `GOVERSION` (default: `1.24.4`)
1616
* `INSTALL_ZSH` (default: `true`)
1717
* `KUBECTL_VERSION` (default: `latest`)
1818
* `HELM_VERSION` (default: `latest`)

docs/development/setup-dapr-development-env.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This document helps you get started developing Dapr. If you find any problems wh
2323
2424
## Go (Golang)
2525
26-
1. Download and install [Go 1.24.1 or later](https://golang.org/doc/install#tarball).
26+
1. Download and install [Go 1.24.4 or later](https://golang.org/doc/install#tarball).
2727
2828
2. Install [Delve](https://github.com/go-delve/delve/tree/master/Documentation/installation) for Go debugging, if desired.
2929

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/dapr/dapr
22

3-
go 1.24.2
3+
go 1.24.4
44

55
require (
66
contrib.go.opencensus.io/exporter/prometheus v0.4.2

pkg/actors/router/router.go

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,9 @@ func New(opts Options) Interface {
101101
}
102102

103103
func (r *router) Call(ctx context.Context, req *internalv1pb.InternalInvokeRequest) (*internalv1pb.InternalInvokeResponse, error) {
104-
cancel, err := r.locker.LockRequest(req)
105-
if err != nil {
106-
return nil, err
107-
}
108-
defer cancel()
109-
110104
var res *internalv1pb.InternalInvokeResponse
105+
var err error
106+
111107
if r.resiliency.PolicyDefined(req.GetActor().GetActorType(), resiliency.ActorPolicy{}) {
112108
res, err = r.callActor(ctx, req)
113109
} else {
@@ -129,25 +125,17 @@ func (r *router) Call(ctx context.Context, req *internalv1pb.InternalInvokeReque
129125
func (r *router) CallReminder(ctx context.Context, req *api.Reminder) error {
130126
if req.SkipLock {
131127
return r.callReminder(ctx, req)
132-
} else {
133-
cancel, err := r.locker.Lock(req.ActorType, req.ActorID)
134-
if err != nil {
135-
return err
136-
}
137-
defer cancel()
138128
}
139129

140-
var err error
141130
if r.resiliency.PolicyDefined(req.ActorType, resiliency.ActorPolicy{}) {
142-
err = r.callReminder(ctx, req)
131+
return r.callReminder(ctx, req)
143132
} else {
144133
policyRunner := resiliency.NewRunner[struct{}](ctx, r.resiliency.BuiltInPolicy(resiliency.BuiltInActorNotFoundRetries))
145-
_, err = policyRunner(func(ctx context.Context) (struct{}, error) {
134+
_, err := policyRunner(func(ctx context.Context) (struct{}, error) {
146135
return struct{}{}, r.callReminder(ctx, req)
147136
})
137+
return err
148138
}
149-
150-
return err
151139
}
152140

153141
func (r *router) CallStream(ctx context.Context, req *internalv1pb.InternalInvokeRequest, stream chan<- *internalv1pb.InternalInvokeResponse) error {
@@ -196,6 +184,16 @@ func (r *router) callReminder(ctx context.Context, req *api.Reminder) error {
196184
return err
197185
}
198186

187+
if !req.SkipLock {
188+
// Only lock the request if it is a local call.
189+
var cancel context.CancelFunc
190+
cancel, err = r.locker.Lock(req.ActorType, req.ActorID)
191+
if err != nil {
192+
return err
193+
}
194+
defer cancel()
195+
}
196+
199197
target, _, err := r.table.GetOrCreate(req.ActorType, req.ActorID)
200198
if err != nil {
201199
return backoff.Permanent(err)
@@ -234,6 +232,14 @@ func (r *router) callActor(ctx context.Context, req *internalv1pb.InternalInvoke
234232
}
235233

236234
if lar.Local {
235+
// Only lock the request if it is a local call.
236+
var cancel context.CancelFunc
237+
cancel, err = r.locker.LockRequest(req)
238+
if err != nil {
239+
return nil, err
240+
}
241+
defer cancel()
242+
237243
var resp *internalv1pb.InternalInvokeResponse
238244
resp, err = r.callLocalActor(ctx, req)
239245
if err != nil {

pkg/actors/state/fake/fake.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,48 +20,48 @@ import (
2020
)
2121

2222
type Fake struct {
23-
getFn func(ctx context.Context, req *api.GetStateRequest) (*api.StateResponse, error)
24-
getBulkFn func(ctx context.Context, req *api.GetBulkStateRequest) (api.BulkStateResponse, error)
25-
transactionalStateOperationFn func(ctx context.Context, ignoreHosted bool, req *api.TransactionalRequest) error
23+
getFn func(ctx context.Context, req *api.GetStateRequest, lock bool) (*api.StateResponse, error)
24+
getBulkFn func(ctx context.Context, req *api.GetBulkStateRequest, lock bool) (api.BulkStateResponse, error)
25+
transactionalStateOperationFn func(ctx context.Context, ignoreHosted bool, req *api.TransactionalRequest, lock bool) error
2626
}
2727

2828
func New() *Fake {
2929
return &Fake{
30-
getFn: func(ctx context.Context, req *api.GetStateRequest) (*api.StateResponse, error) {
30+
getFn: func(ctx context.Context, req *api.GetStateRequest, lock bool) (*api.StateResponse, error) {
3131
return nil, nil
3232
},
33-
getBulkFn: func(ctx context.Context, req *api.GetBulkStateRequest) (api.BulkStateResponse, error) {
33+
getBulkFn: func(ctx context.Context, req *api.GetBulkStateRequest, lock bool) (api.BulkStateResponse, error) {
3434
return api.BulkStateResponse{}, nil
3535
},
36-
transactionalStateOperationFn: func(ctx context.Context, ignoreHosted bool, req *api.TransactionalRequest) error {
36+
transactionalStateOperationFn: func(ctx context.Context, ignoreHosted bool, req *api.TransactionalRequest, lock bool) error {
3737
return nil
3838
},
3939
}
4040
}
4141

42-
func (f *Fake) WithGetFn(fn func(ctx context.Context, req *api.GetStateRequest) (*api.StateResponse, error)) *Fake {
42+
func (f *Fake) WithGetFn(fn func(ctx context.Context, req *api.GetStateRequest, lock bool) (*api.StateResponse, error)) *Fake {
4343
f.getFn = fn
4444
return f
4545
}
4646

47-
func (f *Fake) WithGetBulkFn(fn func(ctx context.Context, req *api.GetBulkStateRequest) (api.BulkStateResponse, error)) *Fake {
47+
func (f *Fake) WithGetBulkFn(fn func(ctx context.Context, req *api.GetBulkStateRequest, lock bool) (api.BulkStateResponse, error)) *Fake {
4848
f.getBulkFn = fn
4949
return f
5050
}
5151

52-
func (f *Fake) WithTransactionalStateOperationFn(fn func(ctx context.Context, ignoreHosted bool, req *api.TransactionalRequest) error) *Fake {
52+
func (f *Fake) WithTransactionalStateOperationFn(fn func(ctx context.Context, ignoreHosted bool, req *api.TransactionalRequest, lock bool) error) *Fake {
5353
f.transactionalStateOperationFn = fn
5454
return f
5555
}
5656

57-
func (f *Fake) Get(ctx context.Context, req *api.GetStateRequest) (*api.StateResponse, error) {
58-
return f.getFn(ctx, req)
57+
func (f *Fake) Get(ctx context.Context, req *api.GetStateRequest, lock bool) (*api.StateResponse, error) {
58+
return f.getFn(ctx, req, lock)
5959
}
6060

61-
func (f *Fake) GetBulk(ctx context.Context, req *api.GetBulkStateRequest) (api.BulkStateResponse, error) {
62-
return f.getBulkFn(ctx, req)
61+
func (f *Fake) GetBulk(ctx context.Context, req *api.GetBulkStateRequest, lock bool) (api.BulkStateResponse, error) {
62+
return f.getBulkFn(ctx, req, lock)
6363
}
6464

65-
func (f *Fake) TransactionalStateOperation(ctx context.Context, ignoreHosted bool, req *api.TransactionalRequest) error {
66-
return f.transactionalStateOperationFn(ctx, ignoreHosted, req)
65+
func (f *Fake) TransactionalStateOperation(ctx context.Context, ignoreHosted bool, req *api.TransactionalRequest, lock bool) error {
66+
return f.transactionalStateOperationFn(ctx, ignoreHosted, req, lock)
6767
}

pkg/actors/state/state.go

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ var ErrTransactionsTooManyOperations = errors.New("the transaction contains more
4040

4141
type Interface interface {
4242
// Get retrieves actor state.
43-
Get(ctx context.Context, req *api.GetStateRequest) (*api.StateResponse, error)
43+
Get(ctx context.Context, req *api.GetStateRequest, lock bool) (*api.StateResponse, error)
4444

4545
// GetBulk retrieves actor state in bulk.
46-
GetBulk(ctx context.Context, req *api.GetBulkStateRequest) (api.BulkStateResponse, error)
46+
GetBulk(ctx context.Context, req *api.GetBulkStateRequest, lock bool) (api.BulkStateResponse, error)
4747

4848
// TransactionalStateOperation performs a transactional state operation with the actor state store.
49-
TransactionalStateOperation(ctx context.Context, ignoreHosted bool, req *api.TransactionalRequest) error
49+
TransactionalStateOperation(ctx context.Context, ignoreHosted bool, req *api.TransactionalRequest, lock bool) error
5050
}
5151

5252
type Backend interface {
@@ -90,12 +90,16 @@ func New(opts Options) Interface {
9090
}
9191
}
9292

93-
func (s *state) Get(ctx context.Context, req *api.GetStateRequest) (*api.StateResponse, error) {
94-
ctx, cancel, err := s.placement.Lock(ctx)
95-
if err != nil {
96-
return nil, err
93+
func (s *state) Get(ctx context.Context, req *api.GetStateRequest, lock bool) (*api.StateResponse, error) {
94+
if lock {
95+
var cancel context.CancelFunc
96+
var err error
97+
ctx, cancel, err = s.placement.Lock(ctx)
98+
if err != nil {
99+
return nil, err
100+
}
101+
defer cancel()
97102
}
98-
defer cancel()
99103

100104
storeName, store, err := s.stateStore()
101105
if err != nil {
@@ -133,12 +137,16 @@ func (s *state) Get(ctx context.Context, req *api.GetStateRequest) (*api.StateRe
133137
}, nil
134138
}
135139

136-
func (s *state) GetBulk(ctx context.Context, req *api.GetBulkStateRequest) (api.BulkStateResponse, error) {
137-
ctx, cancel, err := s.placement.Lock(ctx)
138-
if err != nil {
139-
return nil, err
140+
func (s *state) GetBulk(ctx context.Context, req *api.GetBulkStateRequest, lock bool) (api.BulkStateResponse, error) {
141+
if lock {
142+
var cancel context.CancelFunc
143+
var err error
144+
ctx, cancel, err = s.placement.Lock(ctx)
145+
if err != nil {
146+
return nil, err
147+
}
148+
defer cancel()
140149
}
141-
defer cancel()
142150

143151
storeName, store, err := s.stateStore()
144152
if err != nil {
@@ -183,12 +191,16 @@ func (s *state) GetBulk(ctx context.Context, req *api.GetBulkStateRequest) (api.
183191
return bulkRes, nil
184192
}
185193

186-
func (s *state) TransactionalStateOperation(ctx context.Context, ignoreHosted bool, req *api.TransactionalRequest) error {
187-
ctx, cancel, err := s.placement.Lock(ctx)
188-
if err != nil {
189-
return err
194+
func (s *state) TransactionalStateOperation(ctx context.Context, ignoreHosted bool, req *api.TransactionalRequest, lock bool) error {
195+
if lock {
196+
var cancel context.CancelFunc
197+
var err error
198+
ctx, cancel, err = s.placement.Lock(ctx)
199+
if err != nil {
200+
return err
201+
}
202+
defer cancel()
190203
}
191-
defer cancel()
192204

193205
if !ignoreHosted {
194206
if _, ok := s.table.HostedTarget(req.ActorType, req.ActorID); !ok {
@@ -200,6 +212,7 @@ func (s *state) TransactionalStateOperation(ctx context.Context, ignoreHosted bo
200212
baseKey := key.ConstructComposite(s.appID, req.ActorKey())
201213
metadata := map[string]string{metadataPartitionKey: baseKey}
202214
baseKey += api.DaprSeparator
215+
var err error
203216
for i, o := range req.Operations {
204217
operations[i], err = o.StateOperation(baseKey, api.StateOperationOpts{
205218
Metadata: metadata,

0 commit comments

Comments
 (0)