Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions client/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"context"
"database/sql"
"database/sql/driver"

"github.com/pkg/errors"
)

// ExecuteTx starts a transaction, and runs fn in it
Expand All @@ -39,11 +41,11 @@ func ExecuteTx(
func ExecuteInTx(tx driver.Tx, fn func() error) (err error) {
err = fn()
if err == nil {
// Ignore commit errors. The tx has already been committed by RELEASE.
err = tx.Commit()
if err != nil {
err = errors.Wrapf(err, "exec in tx")
}
} else {
// We always need to execute a Rollback() so sql.DB releases the
// connection.
_ = tx.Rollback()
}
return
Expand Down
2 changes: 1 addition & 1 deletion cmd/cql-fuse/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (

// BlockSize is the size of each data block. It must not
// change throughout the lifetime of the filesystem.
const BlockSize = 4 << 10 // 4KB
const BlockSize = 128 << 10 // 128KB

func min(a, b uint64) uint64 {
if a < b {
Expand Down
3 changes: 3 additions & 0 deletions cmd/cql-fuse/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ func TestShrinkGrow(t *testing.T) {
if data, err = tryGrow(db, data, id, BlockSize*5); err != nil {
log.Fatal(err)
}
if data, err = tryGrow(db, data, id, BlockSize*999); err != nil {
log.Fatal(err)
}

// Shrink it down to 0.
if data, err = tryShrink(db, data, id, 0); err != nil {
Expand Down
30 changes: 21 additions & 9 deletions cmd/cql-fuse/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,24 @@ import (
)

var usage = func() {
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
fmt.Fprintf(os.Stderr, " %s -config <config> -dsn <dsn> -mount <mountpoint>\n\n", os.Args[0])
_, _ = fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
_, _ = fmt.Fprintf(os.Stderr, " %s -config <config> -dsn <dsn> -mount <mountpoint>\n\n", os.Args[0])
flag.PrintDefaults()
}

func main() {
var config, dsn, mountPoint, password string

var (
config string
dsn string
mountPoint string
password string
readOnly bool
)
flag.StringVar(&config, "config", "./conf/config.yaml", "config file path")
flag.StringVar(&mountPoint, "mount", "./", "dir to mount")
flag.StringVar(&dsn, "dsn", "", "database url")
flag.StringVar(&password, "password", "", "master key password for covenantsql")
flag.BoolVar(&readOnly, "readonly", false, "mount read only volume")
flag.Usage = usage
flag.Parse()

Expand All @@ -102,11 +108,12 @@ func main() {
log.Fatal(err)
}

cfg, err := client.ParseDSN(dsn)
if err != nil {
log.Fatal(err)
}

db, err := sql.Open("covenantsql", dsn)
db, err := sql.Open("covenantsql", cfg.FormatDSN())
if err != nil {
log.Fatal(err)
}
Expand All @@ -118,13 +125,18 @@ func main() {
}

cfs := CFS{db}
opts := make([]fuse.MountOption, 0, 5)
opts = append(opts, fuse.FSName("CovenantFS"))
opts = append(opts, fuse.Subtype("CovenantFS"))
opts = append(opts, fuse.LocalVolume())
opts = append(opts, fuse.VolumeName(cfg.DatabaseID))
if readOnly {
opts = append(opts, fuse.ReadOnly())
}
// Mount filesystem.
c, err := fuse.Mount(
mountPoint,
fuse.FSName("CovenantFS"),
fuse.Subtype("CovenantFS"),
fuse.LocalVolume(),
fuse.VolumeName(""),
opts...,
)
if err != nil {
log.Fatal(err)
Expand Down
6 changes: 2 additions & 4 deletions genMarshalHash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

PROJECT_DIR=$(cd $(dirname $0)/; pwd)

if [[ -x hsp ]]; then
echo "install HashStablePack cmd: hsp"
go get -u github.com/CovenantSQL/HashStablePack/hsp
fi
echo "install HashStablePack cmd: hsp"
go get -v -u github.com/CovenantSQL/HashStablePack/hsp

echo ${PROJECT_DIR}

Expand Down
2 changes: 1 addition & 1 deletion test/fuse/node_miner_0/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ BlockProducer:
Miner:
IsTestMode: true
RootDir: "./data"
MaxReqTimeGap: "2s"
MaxReqTimeGap: "60s"
ProvideServiceInterval: "3s"
KnownNodes:
- ID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9
Expand Down
2 changes: 1 addition & 1 deletion test/fuse/node_miner_1/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ BlockProducer:
Miner:
IsTestMode: true
RootDir: "./data"
MaxReqTimeGap: "2s"
MaxReqTimeGap: "60s"
ProvideServiceInterval: "3s"
KnownNodes:
- ID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9
Expand Down
2 changes: 1 addition & 1 deletion test/fuse/node_miner_2/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ BlockProducer:
Miner:
IsTestMode: true
RootDir: "./data"
MaxReqTimeGap: "2s"
MaxReqTimeGap: "60s"
ProvideServiceInterval: "3s"
KnownNodes:
- ID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9
Expand Down