Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
210310676
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2021
210310676
Commits
38266b85
Commit
38266b85
authored
4 years ago
by
Xiangyu Wang
Committed by
yefu.chen
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Lock channel at produce and consume
Signed-off-by:
Xiangyu Wang
<
xiangyu.wang@zilliz.com
>
parent
882c7aaa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/singlenode/main.go
+3
-0
3 additions, 0 deletions
cmd/singlenode/main.go
internal/util/rocksmq/rocksmq.go
+7
-6
7 additions, 6 deletions
internal/util/rocksmq/rocksmq.go
with
10 additions
and
6 deletions
cmd/singlenode/main.go
+
3
−
0
View file @
38266b85
package
main
import
(
"os"
"github.com/zilliztech/milvus-distributed/cmd/distributed/roles"
)
...
...
@@ -20,5 +22,6 @@ func initRoles(roles *roles.MilvusRoles) {
func
main
()
{
var
roles
roles
.
MilvusRoles
initRoles
(
&
roles
)
os
.
Setenv
(
"QUERY_NODE_ID"
,
"1"
)
roles
.
Run
(
true
)
}
This diff is collapsed.
Click to expand it.
internal/util/rocksmq/rocksmq.go
+
7
−
6
View file @
38266b85
...
...
@@ -75,8 +75,7 @@ type RocksMQ struct {
channels
map
[
string
]
*
Channel
cgCtxs
map
[
string
]
ConsumerGroupContext
idAllocator
allocator
.
GIDAllocator
produceMu
sync
.
Mutex
consumeMu
sync
.
Mutex
channelMu
map
[
string
]
*
sync
.
Mutex
notify
map
[
string
][]
*
Consumer
//ctx context.Context
...
...
@@ -110,6 +109,7 @@ func NewRocksMQ(name string, idAllocator allocator.GIDAllocator) (*RocksMQ, erro
}
rmq
.
channels
=
make
(
map
[
string
]
*
Channel
)
rmq
.
notify
=
make
(
map
[
string
][]
*
Consumer
)
rmq
.
channelMu
=
make
(
map
[
string
]
*
sync
.
Mutex
)
return
rmq
,
nil
}
...
...
@@ -148,6 +148,7 @@ func (rmq *RocksMQ) CreateChannel(channelName string) error {
endOffset
:
0
,
}
rmq
.
channels
[
channelName
]
=
channel
rmq
.
channelMu
[
channelName
]
=
new
(
sync
.
Mutex
)
return
nil
}
...
...
@@ -200,8 +201,8 @@ func (rmq *RocksMQ) DestroyConsumerGroup(groupName string, channelName string) e
}
func
(
rmq
*
RocksMQ
)
Produce
(
channelName
string
,
messages
[]
ProducerMessage
)
error
{
rmq
.
produceMu
.
Lock
()
defer
rmq
.
produceMu
.
Unlock
()
rmq
.
channelMu
[
channelName
]
.
Lock
()
defer
rmq
.
channelMu
[
channelName
]
.
Unlock
()
msgLen
:=
len
(
messages
)
idStart
,
idEnd
,
err
:=
rmq
.
idAllocator
.
Alloc
(
uint32
(
msgLen
))
...
...
@@ -260,8 +261,8 @@ func (rmq *RocksMQ) Produce(channelName string, messages []ProducerMessage) erro
}
func
(
rmq
*
RocksMQ
)
Consume
(
groupName
string
,
channelName
string
,
n
int
)
([]
ConsumerMessage
,
error
)
{
rmq
.
c
onsumeMu
.
Lock
()
defer
rmq
.
c
onsumeMu
.
Unlock
()
rmq
.
c
hannelMu
[
channelName
]
.
Lock
()
defer
rmq
.
c
hannelMu
[
channelName
]
.
Unlock
()
metaKey
:=
groupName
+
"/"
+
channelName
+
"/current_id"
currentID
,
err
:=
rmq
.
kv
.
Load
(
metaKey
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment