Skip to content

Commit f3f04ad

Browse files
authored
Merge pull request #7681 from TheThingsNetwork/fix/gs-event-race-condition
Fix race condition on downlink attempt event registration
2 parents d35fe1c + bac4d9a commit f3f04ad

4 files changed

Lines changed: 2 additions & 47 deletions

File tree

config/messages.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4841,15 +4841,6 @@
48414841
"file": "pattern.go"
48424842
}
48434843
},
4844-
"error:pkg/events:marshal_data": {
4845-
"translations": {
4846-
"en": "marshal data"
4847-
},
4848-
"description": {
4849-
"package": "pkg/events",
4850-
"file": "events.go"
4851-
}
4852-
},
48534844
"error:pkg/events:no_matching_events": {
48544845
"translations": {
48554846
"en": "no matching events for regexp `{regexp}`"

pkg/events/events.go

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ import (
2525
"strings"
2626
"time"
2727

28-
"github.com/getsentry/sentry-go"
2928
"go.thethings.network/lorawan-stack/v3/pkg/errors"
30-
sentryerrors "go.thethings.network/lorawan-stack/v3/pkg/errors/sentry"
3129
"go.thethings.network/lorawan-stack/v3/pkg/goproto"
3230
"go.thethings.network/lorawan-stack/v3/pkg/jsonpb"
3331
"go.thethings.network/lorawan-stack/v3/pkg/ttnpb"
@@ -222,47 +220,14 @@ func Proto(e Event) (*ttnpb.Event, error) {
222220
pb.Context = ctx
223221
if evt.data != nil {
224222
var err error
225-
// TODO: uncomment masrshalData and remove mustMarshalEventData after the issue mentioned
226-
// below (7632) is fixed.
227-
// pb.Data, err = marshalData(e.Data())
228-
pb.Data, err = mustMarshalEventData(e)
223+
pb.Data, err = marshalData(e.Data())
229224
if err != nil {
230225
return nil, err
231226
}
232227
}
233228
return pb, nil
234229
}
235230

236-
// TODO: remove after issue is resolved
237-
// https://github.com/TheThingsNetwork/lorawan-stack/issues/7623
238-
var errMarshalData = errors.Define("marshal_data", "marshal data")
239-
240-
func mustMarshalEventData(e Event) (*anypb.Any, error) {
241-
defer func() {
242-
if p := recover(); p != nil {
243-
var err error
244-
if pErr, ok := p.(error); ok {
245-
err = errMarshalData.WithCause(pErr).WithAttributes(
246-
"event_name", e.Name(),
247-
"event_correlation_ids", e.CorrelationIds(),
248-
"event_identifiers", e.Identifiers(),
249-
)
250-
} else {
251-
err = errMarshalData.WithAttributes(
252-
"panic", p,
253-
"event_name", e.Name(),
254-
"event_correlation_ids", e.CorrelationIds(),
255-
"event_identifiers", e.Identifiers(),
256-
)
257-
}
258-
event := sentryerrors.NewEvent(err)
259-
sentry.CaptureEvent(event)
260-
}
261-
}()
262-
263-
return marshalData(e.Data())
264-
}
265-
266231
// FromProto returns the event from its protobuf representation.
267232
func FromProto(pb *ttnpb.Event) (Event, error) {
268233
ctx, err := unmarshalContext(context.Background(), pb.Context)

pkg/gatewayserver/grpc_nsgs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (gs *GatewayServer) ScheduleDownlink(ctx context.Context, down *ttnpb.Downl
8383
connDown.GetRequest().DownlinkPaths = nil // And do not leak the downlink paths to the gateway.
8484
connDown.CorrelationIds = events.CorrelationIDsFromContext(ctx)
8585

86-
registerScheduleDownlinkAttempt(ctx, conn.Gateway(), connDown, conn.Frontend().Protocol())
86+
registerScheduleDownlinkAttempt(ctx, conn.Gateway(), ttnpb.Clone(connDown), conn.Frontend().Protocol())
8787

8888
rx1, rx2, delay, err := conn.ScheduleDown(path, connDown)
8989
if err != nil {

pkg/webui/locales/ja.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2401,7 +2401,6 @@
24012401
"error:pkg/events/redis:channel_closed": "チャネルが閉じています",
24022402
"error:pkg/events/redis:unknown_encoding": "不明なエンコーディング",
24032403
"error:pkg/events:invalid_regexp": "無効な正規表現",
2404-
"error:pkg/events:marshal_data": "",
24052404
"error:pkg/events:no_matching_events": "正規表現`{regexp}`に一致するイベントがありません",
24062405
"error:pkg/events:unknown_event_name": "不明なイベント`{name}`",
24072406
"error:pkg/fetch:fetch_file": "ファイル `{filename}` を取得できません",

0 commit comments

Comments
 (0)