Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
e87b841b
Commit
e87b841b
authored
Mar 14, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
57fa0d99
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
5 deletions
+19
-5
go/neo/storage/sqlite/sqlite.go
go/neo/storage/sqlite/sqlite.go
+19
-5
No files found.
go/neo/storage/sqlite/sqlite.go
View file @
e87b841b
...
@@ -39,7 +39,7 @@ import (
...
@@ -39,7 +39,7 @@ import (
// NOTE github.com/gwenn/gosqlite is used for the following reasons:
// NOTE github.com/gwenn/gosqlite is used for the following reasons:
//
//
// - it is used directly instead of using it via "database/sql" because for a
// - it is used directly instead of using it via "database/sql" because for a
// typical 5µs query quering through "database/sql", even in the most
// typical 5µs query quer
y
ing through "database/sql", even in the most
// careful, hacky and unsafe way, adds at least 3µs and more.
// careful, hacky and unsafe way, adds at least 3µs and more.
// see also: https://github.com/golang/go/issues/23879
// see also: https://github.com/golang/go/issues/23879
//
//
...
@@ -52,7 +52,7 @@ import (
...
@@ -52,7 +52,7 @@ import (
//
//
// --------
// --------
//
//
// NOTE 2: we do not interrupt requests on context cancelation:
// NOTE 2: we do not interrupt requests on context cancel
l
ation:
//
//
// - it is relatively expensive to support when using a CGo library - see e.g.
// - it is relatively expensive to support when using a CGo library - see e.g.
// https://github.com/mattn/go-sqlite3/pull/530
// https://github.com/mattn/go-sqlite3/pull/530
...
@@ -61,7 +61,7 @@ import (
...
@@ -61,7 +61,7 @@ import (
// - on Linux disk file IO, in contrast to e.g. network and pipes,
// - on Linux disk file IO, in contrast to e.g. network and pipes,
// cannot be really interrupted.
// cannot be really interrupted.
//
//
// so we are ok for the cancel to be working on the granu
a
larity of
// so we are ok for the cancel to be working on the granularity of
// whole query.
// whole query.
sqlite3
"github.com/gwenn/gosqlite"
sqlite3
"github.com/gwenn/gosqlite"
)
)
...
@@ -328,7 +328,7 @@ func (b *Backend) Load(ctx context.Context, xid zodb.Xid) (_ *proto.AnswerObject
...
@@ -328,7 +328,7 @@ func (b *Backend) Load(ctx context.Context, xid zodb.Xid) (_ *proto.AnswerObject
// XXX somehow detect errors in sql misuse and log them as 500 without reporting to client?
// XXX somehow detect errors in sql misuse and log them as 500 without reporting to client?
// XXX such errors start with "unsupported Scan, "
// XXX such errors start with "unsupported Scan, "
// XXX use conn for severl query1 (see below) without intermediate returns to pool?
// XXX use conn for sever
a
l query1 (see below) without intermediate returns to pool?
err
=
b
.
query1
(
err
=
b
.
query1
(
"SELECT tid, compression, data.hash, value, value_tid"
+
"SELECT tid, compression, data.hash, value, value_tid"
+
...
@@ -411,7 +411,6 @@ func (b *Backend) Close() error {
...
@@ -411,7 +411,6 @@ func (b *Backend) Close() error {
// ---- open ----
// ---- open ----
func
openConn
(
dburl
string
)
(
*
sqlite3
.
Conn
,
error
)
{
func
openConn
(
dburl
string
)
(
*
sqlite3
.
Conn
,
error
)
{
println
(
"openconn"
,
dburl
)
conn
,
err
:=
sqlite3
.
Open
(
dburl
,
conn
,
err
:=
sqlite3
.
Open
(
dburl
,
sqlite3
.
OpenNoMutex
,
// we use connections only from 1 goroutine simultaneously
sqlite3
.
OpenNoMutex
,
// we use connections only from 1 goroutine simultaneously
sqlite3
.
OpenReadWrite
)
//, sqlite3.OpenSharedCache)
sqlite3
.
OpenReadWrite
)
//, sqlite3.OpenSharedCache)
...
@@ -463,6 +462,21 @@ func openConn(dburl string) (*sqlite3.Conn, error) {
...
@@ -463,6 +462,21 @@ func openConn(dburl string) (*sqlite3.Conn, error) {
dburl
,
mode
,
mode_
)
dburl
,
mode
,
mode_
)
}
}
// TODO locking_mode=EXCLUSIVE means sqlite will acquire SHARED lock on
// first read operation and EXCLUSIVE lock on first write. It is better
// we downgrade EXCLUSIVE back to SHARED after transaction finish in
// order for separate processes (e.g. sqlite3 shell) to be able to still
// read data. Ways to downgrade could be:
//
// - to set locking_mode=normal and read something,
// https://www.sqlite.org/pragma.html#pragma_locking_mode
//
// or
//
// - to patch sqlite and add something lie "EXCLUSIVE_READ" locking
// mode. (see pager_end_transaction() and pagerUnlockDb(SHARED_LOCK)
// call there in sqlite3 sources).
return
conn
,
nil
return
conn
,
nil
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment