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
d6200a51
Commit
d6200a51
authored
4 years ago
by
陈庆祥
Committed by
yefu.chen
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix meta cache error
Signed-off-by:
godchen
<
qingxiang.chen@zilliz.com
>
parent
55634dc5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
internal/proxynode/meta_cache.go
+44
-33
44 additions, 33 deletions
internal/proxynode/meta_cache.go
with
44 additions
and
33 deletions
internal/proxynode/meta_cache.go
+
44
−
33
View file @
d6200a51
...
...
@@ -20,20 +20,19 @@ type Cache interface {
GetPartitionID
(
collectionName
string
,
partitionName
string
)
(
typeutil
.
UniqueID
,
error
)
GetCollectionSchema
(
collectionName
string
)
(
*
schemapb
.
CollectionSchema
,
error
)
RemoveCollection
(
collectionName
string
)
RemovePartition
(
partitionName
string
)
RemovePartition
(
collectionName
string
,
partitionName
string
)
}
type
collectionInfo
struct
{
collID
typeutil
.
UniqueID
schema
*
schemapb
.
CollectionSchema
collID
typeutil
.
UniqueID
schema
*
schemapb
.
CollectionSchema
partInfo
map
[
string
]
typeutil
.
UniqueID
}
type
MetaCache
struct
{
client
MasterClientInterface
collInfo
map
[
string
]
*
collectionInfo
partInfo
map
[
string
]
typeutil
.
UniqueID
col2par
map
[
string
][]
string
mu
sync
.
RWMutex
}
...
...
@@ -52,8 +51,6 @@ func NewMetaCache(client MasterClientInterface) (*MetaCache, error) {
return
&
MetaCache
{
client
:
client
,
collInfo
:
map
[
string
]
*
collectionInfo
{},
partInfo
:
map
[
string
]
typeutil
.
UniqueID
{},
col2par
:
map
[
string
][]
string
{},
},
nil
}
...
...
@@ -79,11 +76,16 @@ func (m *MetaCache) readCollectionSchema(collectionName string) (*schemapb.Colle
return
collInfo
.
schema
,
nil
}
func
(
m
*
MetaCache
)
readPartitionID
(
partitionName
string
)
(
typeutil
.
UniqueID
,
error
)
{
func
(
m
*
MetaCache
)
readPartitionID
(
collectionName
string
,
partitionName
string
)
(
typeutil
.
UniqueID
,
error
)
{
m
.
mu
.
RLock
()
defer
m
.
mu
.
RUnlock
()
partitionID
,
ok
:=
m
.
partInfo
[
partitionName
]
collInfo
,
ok
:=
m
.
collInfo
[
collectionName
]
if
!
ok
{
return
0
,
errors
.
Errorf
(
"can't find collection name:%s"
,
collectionName
)
}
partitionID
,
ok
:=
collInfo
.
partInfo
[
partitionName
]
if
!
ok
{
return
0
,
errors
.
Errorf
(
"can't find partition name:%s"
,
partitionName
)
}
...
...
@@ -112,15 +114,14 @@ func (m *MetaCache) GetCollectionID(collectionName string) (typeutil.UniqueID, e
return
0
,
errors
.
Errorf
(
"%s"
,
coll
.
Status
.
Reason
)
}
collInfo
:=
&
collectionInfo
{
collID
:
coll
.
CollectionID
,
schema
:
coll
.
Schema
,
}
_
,
ok
:=
m
.
collInfo
[
collectionName
]
if
!
ok
{
m
.
collInfo
[
collectionName
]
=
collInfo
m
.
collInfo
[
collectionName
]
=
&
coll
ection
Info
{}
}
return
collInfo
.
collID
,
nil
m
.
collInfo
[
collectionName
]
.
schema
=
coll
.
Schema
m
.
collInfo
[
collectionName
]
.
collID
=
coll
.
CollectionID
return
m
.
collInfo
[
collectionName
]
.
collID
,
nil
}
func
(
m
*
MetaCache
)
GetCollectionSchema
(
collectionName
string
)
(
*
schemapb
.
CollectionSchema
,
error
)
{
collSchema
,
err
:=
m
.
readCollectionSchema
(
collectionName
)
...
...
@@ -144,19 +145,18 @@ func (m *MetaCache) GetCollectionSchema(collectionName string) (*schemapb.Collec
return
nil
,
errors
.
Errorf
(
"%s"
,
coll
.
Status
.
Reason
)
}
collInfo
:=
&
collectionInfo
{
collID
:
coll
.
CollectionID
,
schema
:
coll
.
Schema
,
}
_
,
ok
:=
m
.
collInfo
[
collectionName
]
if
!
ok
{
m
.
collInfo
[
collectionName
]
=
collInfo
m
.
collInfo
[
collectionName
]
=
&
coll
ection
Info
{}
}
return
collInfo
.
schema
,
nil
m
.
collInfo
[
collectionName
]
.
schema
=
coll
.
Schema
m
.
collInfo
[
collectionName
]
.
collID
=
coll
.
CollectionID
return
m
.
collInfo
[
collectionName
]
.
schema
,
nil
}
func
(
m
*
MetaCache
)
GetPartitionID
(
collectionName
string
,
partitionName
string
)
(
typeutil
.
UniqueID
,
error
)
{
partitionID
,
err
:=
m
.
readPartitionID
(
partitionName
)
partitionID
,
err
:=
m
.
readPartitionID
(
collectionName
,
partitionName
)
if
err
==
nil
{
return
partitionID
,
nil
}
...
...
@@ -180,34 +180,45 @@ func (m *MetaCache) GetPartitionID(collectionName string, partitionName string)
return
0
,
errors
.
Errorf
(
"partition ids len: %d doesn't equal Partition name len %d"
,
len
(
partitions
.
PartitionIDs
),
len
(
partitions
.
PartitionNames
))
}
m
.
col2par
[
collectionName
]
=
partitions
.
PartitionNames
_
,
ok
:=
m
.
collInfo
[
collectionName
]
if
!
ok
{
m
.
collInfo
[
collectionName
]
=
&
collectionInfo
{
partInfo
:
map
[
string
]
typeutil
.
UniqueID
{},
}
}
partInfo
:=
m
.
collInfo
[
collectionName
]
.
partInfo
for
i
:=
0
;
i
<
len
(
partitions
.
PartitionIDs
);
i
++
{
_
,
ok
:=
m
.
partInfo
[
partitions
.
PartitionNames
[
i
]]
_
,
ok
:=
partInfo
[
partitions
.
PartitionNames
[
i
]]
if
!
ok
{
m
.
partInfo
[
partitions
.
PartitionNames
[
i
]]
=
partitions
.
PartitionIDs
[
i
]
partInfo
[
partitions
.
PartitionNames
[
i
]]
=
partitions
.
PartitionIDs
[
i
]
}
}
_
,
ok
:
=
m
.
partInfo
[
partitionName
]
_
,
ok
=
partInfo
[
partitionName
]
if
!
ok
{
return
0
,
errors
.
Errorf
(
"partitionID of partitionName:%s can not be find"
,
partitionName
)
}
return
m
.
partInfo
[
partitionName
],
nil
return
partInfo
[
partitionName
],
nil
}
func
(
m
*
MetaCache
)
RemoveCollection
(
collectionName
string
)
{
m
.
mu
.
Lock
()
defer
m
.
mu
.
Unlock
()
delete
(
m
.
collInfo
,
collectionName
)
for
_
,
partitionName
:=
range
m
.
col2par
[
collectionName
]
{
delete
(
m
.
partInfo
,
partitionName
)
}
delete
(
m
.
col2par
,
collectionName
)
}
func
(
m
*
MetaCache
)
RemovePartition
(
partitionName
string
)
{
func
(
m
*
MetaCache
)
RemovePartition
(
collectionName
,
partitionName
string
)
{
m
.
mu
.
Lock
()
defer
m
.
mu
.
Unlock
()
delete
(
m
.
partInfo
,
partitionName
)
_
,
ok
:=
m
.
collInfo
[
collectionName
]
if
!
ok
{
return
}
partInfo
:=
m
.
collInfo
[
collectionName
]
.
partInfo
if
partInfo
==
nil
{
return
}
delete
(
partInfo
,
partitionName
)
}
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