File tree 5 files changed +61
-9
lines changed
5 files changed +61
-9
lines changed Original file line number Diff line number Diff line change @@ -4,22 +4,38 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
5
5
## [ Unreleased]
6
6
7
+ ### Added
8
+
9
+ ### Changed
10
+
11
+ ### Deprecated
12
+
13
+ ### Removed
14
+
15
+ ### Fixed
16
+
17
+
18
+ ## [ 0.0.2]
19
+
7
20
### Added
8
21
- Add ` (*pq.Reader).Begin/Done ` to reuse a read transaction for multiple reads. PR #4
9
22
- Add ` Flags ` to txfile.Options. PR #5
10
23
- Add support to increase a file's maxSize on open. PR #5
24
+ - Add support to reduce the maximum file size PR #8
11
25
- Add support to pre-allocate the meta area. PR #7
26
+ - Improved error handling and error reporting. PR #15 , #16 , #17 , #18
12
27
- Begin returns an error if transaction is not compatible to file open mode. PR #17
13
28
- Introduce Error type to txfile and pq package. PR #17 , #18
14
29
15
30
### Changed
16
31
- Refine platform dependent file syncing. PR #10
17
-
18
- ### Deprecated
19
-
20
- ### Removed
32
+ - Begin methods can return an error. PR #17
21
33
22
34
### Fixed
35
+ - Windows Fix: Add missing file unlock on close, so file can be reopened and locked. PR #11
36
+ - Windows Fix: Can not open file because '<filename >' can not be locked right now. PR #11
37
+ - Windows Fix: Max mmaped area must not exceed actual file size on windows. PR #11
23
38
24
39
25
- [ Unreleased ] : https://github.com/elastic/go-structform/compare/v0.0.1...HEAD
40
+ [ Unreleased ] : https://github.com/elastic/go-txfile/compare/v0.0.2...HEAD
41
+ [ 0.0.2 ] : https://github.com/elastic/go-txfile/compare/v0.0.1...v0.0.2
Original file line number Diff line number Diff line change @@ -23,9 +23,9 @@ import (
23
23
"math/bits"
24
24
"os"
25
25
"sync"
26
+ "sync/atomic"
26
27
"unsafe"
27
28
28
- "github.com/elastic/beats/libbeat/common/atomic"
29
29
"github.com/elastic/go-txfile/internal/cleanup"
30
30
"github.com/elastic/go-txfile/internal/invariant"
31
31
"github.com/elastic/go-txfile/internal/vfs"
@@ -53,7 +53,7 @@ type File struct {
53
53
meta [2 ]* metaPage
54
54
metaActive int
55
55
56
- txids atomic. Uint
56
+ txids uint64
57
57
}
58
58
59
59
// internal contants
@@ -299,7 +299,9 @@ func (f *File) beginTx(settings TxOptions) (*Tx, reason) {
299
299
lock := f .locks .TxLock (settings .Readonly )
300
300
lock .Lock ()
301
301
tracef ("init new transaction (readonly: %v)\n " , settings .Readonly )
302
- tx := newTx (f , f .txids .Inc (), lock , settings )
302
+
303
+ txid := atomic .AddUint64 (& f .txids , 1 )
304
+ tx := newTx (f , txid , lock , settings )
303
305
tracef ("begin transaction: %p (readonly: %v)\n " , tx , settings .Readonly )
304
306
return tx , nil
305
307
}
Original file line number Diff line number Diff line change
1
+ module github.com/elastic/go-txfile
2
+
3
+ require (
4
+ github.com/davecgh/go-spew v1.1.0 // indirect
5
+ github.com/kr/pretty v0.1.0 // indirect
6
+ github.com/pmezard/go-difflib v1.0.0 // indirect
7
+ github.com/stretchr/testify v1.2.2
8
+ github.com/theckman/go-flock v0.4.0
9
+ github.com/urso/go-bin v0.0.0-20180220135811-781c575c9f0e
10
+ github.com/urso/qcgen v0.0.0-20180131103024-0b059e7db4f4
11
+ golang.org/x/sys v0.0.0-20180802203216-0ffbfd41fbef
12
+ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
13
+ )
Original file line number Diff line number Diff line change
1
+ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 =
2
+ github.com/davecgh/go-spew v1.1.0 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
3
+ github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI =
4
+ github.com/kr/pretty v0.1.0 /go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo =
5
+ github.com/kr/pty v1.1.1 /go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ =
6
+ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE =
7
+ github.com/kr/text v0.1.0 /go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI =
8
+ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM =
9
+ github.com/pmezard/go-difflib v1.0.0 /go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4 =
10
+ github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w =
11
+ github.com/stretchr/testify v1.2.2 /go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs =
12
+ github.com/theckman/go-flock v0.4.0 h1:bcqNkS4RTQBGWybG7IBimUMxnLz53Qes1+D4QaOhzJc =
13
+ github.com/theckman/go-flock v0.4.0 /go.mod h1:kjuth3y9VJ2aNlkNEO99G/8lp9fMIKaGyBmh84IBheM =
14
+ github.com/urso/go-bin v0.0.0-20180220135811-781c575c9f0e h1:NiofbjIUI5gR+ybDsGSVH1fWyjSeDYiYVJHT1+kcsak =
15
+ github.com/urso/go-bin v0.0.0-20180220135811-781c575c9f0e /go.mod h1:6GfHrdWBQYjFRIznu7XuQH4lYB2w8nO4bnImVKkzPOM =
16
+ github.com/urso/qcgen v0.0.0-20180131103024-0b059e7db4f4 h1:hhA8EBThzz9PztawVTycKvfETVuBqxAQ5keFlAVtbAw =
17
+ github.com/urso/qcgen v0.0.0-20180131103024-0b059e7db4f4 /go.mod h1:RspW+E2Yb7Fs7HclB2tiDaiu6Rp41BiIG4Wo1YaoXGc =
18
+ golang.org/x/sys v0.0.0-20180802203216-0ffbfd41fbef h1:ESfhYoBNk2UQGmavscFPKfwmc4ZTB2+UdQYsVw6Bq9M =
19
+ golang.org/x/sys v0.0.0-20180802203216-0ffbfd41fbef /go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY =
20
+ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY =
21
+ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 /go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0 =
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ type txFlags struct {
77
77
checkpoint bool // mark wal checkpoint has been applied
78
78
}
79
79
80
- func newTx (file * File , id uint , lock sync.Locker , settings TxOptions ) * Tx {
80
+ func newTx (file * File , id uint64 , lock sync.Locker , settings TxOptions ) * Tx {
81
81
meta := file .getMetaPage ()
82
82
invariant .Check (meta != nil , "file meta is not set" )
83
83
You can’t perform that action at this time.
0 commit comments