Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support sampling time to ack messages in explicit ack mode #1225

Merged
merged 3 commits into from
Dec 19, 2019

Conversation

ripienaar
Copy link
Contributor

A quick spike on the idea I mentioned of sampling ack times in observables

@ripienaar
Copy link
Contributor Author

ripienaar commented Dec 17, 2019

[#2889] Received on [$JS.OBSERVABLE.SAMPLE.jsm.sampled1]: '{
  "message_set": "jsm",
  "observable": "sampled1",
  "obs_seq": 1,
  "ack_delay": 961000
}'

server/msgset.go Outdated
@@ -113,7 +113,7 @@ func (a *Account) AddMsgSet(config *MsgSetConfig) (*MsgSet, error) {
}
// Setup the internal client.
c := s.createInternalJetStreamClient()
mset := &MsgSet{jsa: jsa, config: cfg, client: c, obs: make(map[string]*Observable)}
mset := &MsgSet{jsa: jsa, config: cfg, client: c, obs: make(map[string]*Observable), mu: sync.RWMutex{}}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems unlikely that this would be needed but I triggered this without it

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1439c7e]

goroutine 934 [running]:
github.com/nats-io/nats-server/v2/server.(*MsgSet).Name(0x0, 0x0, 0x0)
        /Users/rip/go/src/github.com/nats-io/nats-server/server/msgset.go:432 +0x2e
github.com/nats-io/nats-server/v2/server.(*Observable).sampleAck(0xc0000ab6c0, 0x1, 0x1)
        /Users/rip/go/src/github.com/nats-io/nats-server/server/observable.go:540 +0x68
github.com/nats-io/nats-server/v2/server.(*Observable).ackMsg(0xc0000ab6c0, 0x1, 0x1)
        /Users/rip/go/src/github.com/nats-io/nats-server/server/observable.go:561 +0x1a3

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea we should not need it, will fix elsewhere.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

msgset is nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah thats true, you're right it is the msgset, that really shouldnt happen :)

server/jetstream.go Outdated Show resolved Hide resolved
server/observable.go Outdated Show resolved Hide resolved
server/observable.go Show resolved Hide resolved
server/observable.go Outdated Show resolved Hide resolved
server/observable.go Show resolved Hide resolved
server/observable.go Outdated Show resolved Hide resolved
@ripienaar
Copy link
Contributor Author

ripienaar commented Dec 18, 2019

after latest commits we have:

[#4140] Received on [$JS.OBSERVABLE.ACKSAMPLE.jsm.sampled1]: '{
  "message_set": "jsm",
  "observable": "sampled1",
  "obs_seq": 9,
  "msg_set_seq": 2,
  "ack_delay": 1575000,
  "delivery_count": 3
}'

@derekcollison
Copy link
Member

I think we could be more consistent with naming. Some ideas below.

[#4140] Received on [$JS.OBSERVABLE.ACKSAMPLE.jsm.sampled1]: '{
  "msg_set": "jsm",
  "obs": "sampled1",
  "obs_seq": 9,
  "msg_set_seq": 2,
  "ack_time": 1575000,
  "delivered": 3
}'

@ripienaar
Copy link
Contributor Author

updated key names and rebased onto latest jetstream branch

Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@derekcollison derekcollison merged commit 6f612ac into nats-io:jetstream Dec 19, 2019
@ripienaar ripienaar deleted the ack_sampling branch December 20, 2019 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants