Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22fa00199
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Summer2022
22fa00199
Commits
d5ffd35a
Unverified
Commit
d5ffd35a
authored
2 years ago
by
jiangxinmeng1
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix txnstore data race (#4579)
fix data race in txnstore.getOrSetDB. add dbsMu Approved by: @XuPeng-SH
parent
37f023f4
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
pkg/vm/engine/tae/txn/txnimpl/store.go
+19
-8
19 additions, 8 deletions
pkg/vm/engine/tae/txn/txnimpl/store.go
pkg/vm/engine/tae/txn/txnimpl/txndb.go
+22
-11
22 additions, 11 deletions
pkg/vm/engine/tae/txn/txnimpl/txndb.go
with
41 additions
and
19 deletions
pkg/vm/engine/tae/txn/txnimpl/store.go
+
19
−
8
View file @
d5ffd35a
...
...
@@ -15,6 +15,7 @@
package
txnimpl
import
(
"sync"
"sync/atomic"
"time"
...
...
@@ -34,6 +35,7 @@ import (
type
txnStore
struct
{
txnbase
.
NoopTxnStore
dbs
map
[
uint64
]
*
txnDB
mu
sync
.
RWMutex
driver
wal
.
Driver
nodesMgr
base
.
INodeManager
txn
txnif
.
AsyncTxn
...
...
@@ -284,16 +286,25 @@ func (store *txnStore) CreateNonAppendableSegment(dbId, tid uint64) (seg handle.
}
func
(
store
*
txnStore
)
getOrSetDB
(
id
uint64
)
(
db
*
txnDB
,
err
error
)
{
store
.
mu
.
RLock
()
db
=
store
.
dbs
[
id
]
if
db
==
nil
{
var
entry
*
catalog
.
DBEntry
if
entry
,
err
=
store
.
catalog
.
GetDatabaseByID
(
id
);
err
!=
nil
{
return
}
db
=
newTxnDB
(
store
,
entry
)
db
.
idx
=
len
(
store
.
dbs
)
store
.
dbs
[
id
]
=
db
store
.
mu
.
RUnlock
()
if
db
!=
nil
{
return
}
var
entry
*
catalog
.
DBEntry
if
entry
,
err
=
store
.
catalog
.
GetDatabaseByID
(
id
);
err
!=
nil
{
return
}
store
.
mu
.
Lock
()
defer
store
.
mu
.
Unlock
()
db
=
store
.
dbs
[
id
]
if
db
!=
nil
{
return
}
db
=
newTxnDB
(
store
,
entry
)
db
.
idx
=
len
(
store
.
dbs
)
store
.
dbs
[
id
]
=
db
return
}
...
...
This diff is collapsed.
Click to expand it.
pkg/vm/engine/tae/txn/txnimpl/txndb.go
+
22
−
11
View file @
d5ffd35a
...
...
@@ -15,6 +15,7 @@
package
txnimpl
import
(
"sync"
"time"
"github.com/matrixorigin/matrixone/pkg/logutil"
...
...
@@ -29,6 +30,7 @@ import (
type
txnDB
struct
{
store
*
txnStore
tables
map
[
uint64
]
*
txnTable
mu
sync
.
RWMutex
entry
*
catalog
.
DBEntry
createEntry
txnif
.
TxnEntry
dropEntry
txnif
.
TxnEntry
...
...
@@ -234,19 +236,28 @@ func (db *txnDB) CreateNonAppendableSegment(tid uint64) (seg handle.Segment, err
}
func
(
db
*
txnDB
)
getOrSetTable
(
id
uint64
)
(
table
*
txnTable
,
err
error
)
{
db
.
mu
.
RLock
()
table
=
db
.
tables
[
id
]
if
table
==
nil
{
var
entry
*
catalog
.
TableEntry
if
entry
,
err
=
db
.
entry
.
GetTableEntryByID
(
id
);
err
!=
nil
{
return
}
if
db
.
store
.
warChecker
==
nil
{
db
.
store
.
warChecker
=
newWarChecker
(
db
.
store
.
txn
,
db
.
store
.
catalog
)
}
table
=
newTxnTable
(
db
.
store
,
entry
)
table
.
idx
=
len
(
db
.
tables
)
db
.
tables
[
id
]
=
table
db
.
mu
.
RUnlock
()
if
table
!=
nil
{
return
}
var
entry
*
catalog
.
TableEntry
if
entry
,
err
=
db
.
entry
.
GetTableEntryByID
(
id
);
err
!=
nil
{
return
}
db
.
mu
.
Lock
()
defer
db
.
mu
.
Unlock
()
table
=
db
.
tables
[
id
]
if
table
!=
nil
{
return
}
if
db
.
store
.
warChecker
==
nil
{
db
.
store
.
warChecker
=
newWarChecker
(
db
.
store
.
txn
,
db
.
store
.
catalog
)
}
table
=
newTxnTable
(
db
.
store
,
entry
)
table
.
idx
=
len
(
db
.
tables
)
db
.
tables
[
id
]
=
table
return
}
...
...
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