var _ storage.ConsecutiveChunkWriter = (*provider)(nil)
func (p *provider) WriteConsecutiveChunks(prefix string, w io.Writer) (written int64, err error) {
- err = p.withConn(func(conn conn) error {
+ err = p.withConn(func(_ context.Context, conn conn) error {
err = io.EOF
err = sqlitex.Exec(conn, `
select
var expvars = expvar.NewMap("sqliteStorage")
func runQueryWithLabels(query withConn, labels pprof.LabelSet, conn conn) (err error) {
- pprof.Do(context.Background(), labels, func(context.Context) {
- err = query(conn)
+ pprof.Do(context.Background(), labels, func(ctx context.Context) {
+ // We pass in the context in the hope that the CPU profiler might incorporate sqlite
+ // activity the action that triggered it. It doesn't seem that way, since those calls don't
+ // take a context.Context themselves. It may come in useful in the goroutine profiles
+ // though, and doesn't hurt to expose it here for other purposes should things change.
+ err = query(ctx, conn)
})
return
}
}
func getLabels(skip int) pprof.LabelSet {
- return pprof.Labels("f", func() string {
+ return pprof.Labels("sqlite-storage-action", func() string {
var pcs [8]uintptr
runtime.Callers(skip+3, pcs[:])
fs := runtime.CallersFrames(pcs[:])
}
}
-type withConn func(conn) error
+type withConn func(context.Context, conn) error
func (i instance) withConn(with withConn, write bool) error {
return i.p.withConn(with, write, 1)
func (i instance) Readdirnames() (names []string, err error) {
prefix := i.location + "/"
- err = i.withConn(func(conn conn) error {
+ err = i.withConn(func(_ context.Context, conn conn) error {
return sqlitex.Exec(conn, "select name from blob where name like ?", func(stmt *sqlite.Stmt) error {
names = append(names, stmt.ColumnText(0)[len(prefix):])
return nil
}
func (i instance) PutSized(reader io.Reader, size int64) (err error) {
- err = i.withConn(func(conn conn) error {
+ err = i.withConn(func(_ context.Context, conn conn) error {
err := sqlitex.Exec(conn, "insert or replace into blob(name, data) values(?, zeroblob(?))",
nil,
i.location, size)
if false {
return i.PutSized(&buf, int64(buf.Len()))
} else {
- return i.withConn(func(conn conn) error {
+ return i.withConn(func(_ context.Context, conn conn) error {
for range iter.N(10) {
err = sqlitex.Exec(conn,
"insert or replace into blob(name, data) values(?, cast(? as blob))",
}
func (i instance) Stat() (ret os.FileInfo, err error) {
- err = i.withConn(func(conn conn) error {
+ err = i.withConn(func(_ context.Context, conn conn) error {
var blob *sqlite.Blob
blob, err = i.openBlob(conn, false, false)
if err != nil {
}
func (i instance) ReadAt(p []byte, off int64) (n int, err error) {
- err = i.withConn(func(conn conn) error {
+ err = i.withConn(func(_ context.Context, conn conn) error {
if false {
var blob *sqlite.Blob
blob, err = i.openBlob(conn, false, true)
}
func (i instance) Delete() error {
- return i.withConn(func(conn conn) error {
+ return i.withConn(func(_ context.Context, conn conn) error {
return sqlitex.Exec(conn, "delete from blob where name=?", nil, i.location)
}, true)
}