Commit Graph

148 Commits (09ff73b9a728580290b782419771e747c275c8e4)

Author SHA1 Message Date
Benjamin Wang 848f5fb7e4 Enhance TestDB_Concurrent_WriteTo to check consistent read
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
2024-06-27 18:31:39 +01:00
Ishan Tyagi c0b6749ca4 Fix tests to open a bbolt database with file mode:0600 instead of 0666.
Signed-off-by: Ishan Tyagi <ishantyagi25@gmail.com>
2023-07-29 18:06:26 +05:30
Benjamin Wang fddd3ac7f7 remove field 'filesz' from DB
There is no reason to maintain a file size. It's only used
when mapping the db or growing the db; obviously neither
are hot path.

Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-05-26 16:44:04 +08:00
Cenk Alti 05286ad2af
Do not create db file if opened read-only
Signed-off-by: Cenk Alti <cenkalti@gmail.com>
2023-05-17 15:17:51 -04:00
Josh Rickmar 7a957f94b2 Introduce errors package and restore API compatibility
This moves the error variables that had been moved to the
internal/common package during recent refactoring to a non-internal
errors package, once again allowing consumers to test for particular
error conditions.

To preserve API compatibility with bbolt v1.3, these error variables
are also redefined in the bbolt package, with deprecation notice to
migrate to bbolt/errors.

Signed-off-by: Josh Rickmar <jrick@zettaport.com>
2023-04-06 13:26:30 +00:00
Benjamin Wang 7b07e70b8c test: improve testDB_Close_PendingTx to reduce flaky
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-03-30 16:33:34 +08:00
Benjamin Wang ea511567eb refactor both bolt and guts_cli based on the common package
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-03-04 04:22:09 +08:00
Benjamin Wang 35c4569bf9 revert the signature of tx.Check and add tx.CheckWithStringer
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-01-29 19:53:07 +08:00
Piotr Tabor 51370e425a
Merge pull request #225 from ptabor/extend_checker2
Recursive checker implementation.
2023-01-14 12:03:10 +01:00
Piotr Tabor f16e2522ce Address review comments.
Signed-off-by: Piotr Tabor <ptab@google.com>
2023-01-13 19:14:45 +01:00
Piotr Tabor 0c8d75db1e Recursive checker implementation.
Recursive checker confirms database consistency with respect to b-tree
key order constraints:
  - keys on pages must be sorted
  - keys on children pages are between 2 consecutive keys on parent
branch page).

Signed-off-by: Piotr Tabor <ptab@google.com>
2023-01-13 19:14:45 +01:00
Benjamin Wang eabffad75a add protection when mmap somehow fails
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-01-12 07:58:02 +08:00
Benjamin Wang 63d0cb428d cleanup data and dataaz when unmapping db on Windows platform
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-01-12 07:17:08 +08:00
Wei Fu dd4458ce3a TxStats: provides Getter/Inc functions
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-01-04 20:06:51 +08:00
Wei Fu 4e98e8fb3c TestDB_Concurrent_WriteTo: copy option to fix data race
The test log:

==================
WARNING: DATA RACE
Write at 0x00c000388370 by goroutine 37:
  go.etcd.io/bbolt/internal/btesting.MustOpenDBWithOption()
      /home/runner/work/bbolt/bbolt/internal/btesting/btesting.go:52 +0x1c7
  go.etcd.io/bbolt_test.TestDB_Concurrent_WriteTo.func1()
      /home/runner/work/bbolt/bbolt/db_test.go:685 +0x1f4
  go.etcd.io/bbolt_test.TestDB_Concurrent_WriteTo·dwrap·18()
      /home/runner/work/bbolt/bbolt/db_test.go:714 +0x47

Previous write at 0x00c000388370 by goroutine 83:
  go.etcd.io/bbolt/internal/btesting.MustOpenDBWithOption()
      /home/runner/work/bbolt/bbolt/internal/btesting/btesting.go:52 +0x1c7
  go.etcd.io/bbolt_test.TestDB_Concurrent_WriteTo.func1()
      /home/runner/work/bbolt/bbolt/db_test.go:685 +0x1f4
  go.etcd.io/bbolt_test.TestDB_Concurrent_WriteTo·dwrap·18()
      /home/runner/work/bbolt/bbolt/db_test.go:714 +0x47

Goroutine 37 (running) created at:
  go.etcd.io/bbolt_test.TestDB_Concurrent_WriteTo()
      /home/runner/work/bbolt/bbolt/db_test.go:714 +0x724
  testing.tRunner()
      /opt/hostedtoolcache/go/1.17.13/x64/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /opt/hostedtoolcache/go/1.17.13/x64/src/testing/testing.go:1306 +0x47

Goroutine 83 (running) created at:
  go.etcd.io/bbolt_test.TestDB_Concurrent_WriteTo()
      /home/runner/work/bbolt/bbolt/db_test.go:714 +0x724
  testing.tRunner()
      /opt/hostedtoolcache/go/1.17.13/x64/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /opt/hostedtoolcache/go/1.17.13/x64/src/testing/testing.go:1306 +0x47
==================

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-01-03 15:42:51 +08:00
Benjamin Wang c19ea9b613 Handle the case of io.EOF when reading the second meta page
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-12-29 16:37:24 +08:00
Benjamin Wang dab07c58b4 Update test cases TestOpen_ReadPageSize_FromMeta1_OS and TestOpen_ReadPageSize_FromMeta1_Given
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-12-29 09:10:57 +08:00
Benjamin Wang 7b6c235774
Merge pull request #294 from ahrtr/enhance_check_command
Get the page size from the second meta page if the first one is invalid
2022-12-29 06:46:34 +08:00
Piotr Tabor 37d72cc1cd Use require.NoError in btesting.go
Signed-off-by: Piotr Tabor <ptab@google.com>
2022-12-28 15:18:46 +01:00
Piotr Tabor 26cc5e3e8b Tests: Migrate from test DB to btesting.DB
Signed-off-by: Piotr Tabor <ptab@google.com>
2022-12-28 15:18:46 +01:00
Piotr Tabor f3e164d8dd Example: How to use the separated 'btesting' library.
Signed-off-by: Piotr Tabor <ptab@google.com>
2022-12-28 15:18:46 +01:00
Benjamin Wang 2385046d41 replace all ioutil with os
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-12-28 16:56:01 +08:00
ahrtr 8e6a1168ae get the page size from the second meta page if the first one is invalid
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-12-28 16:52:47 +08:00
Manuel Rüger 33c86c78ca .github: Enable lint
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2022-10-20 22:47:35 +02:00
Manuel Rüger 9b606419b1 Run gofmt
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2022-10-20 21:09:53 +02:00
Manuel Rüger fd6c0aa81a Makefile: Move to golangci-lint 2022-03-26 00:28:02 +01:00
Benjamin d5db64bdbf
upgrade golang to 1.17 and replace iouitl with io and os (#297) 2022-01-29 19:28:06 -08:00
JmPotato 685b13a4ef
Clean and simplify some code (#279)
* Clean and simplify some code

Signed-off-by: JmPotato <ghzpotato@gmail.com>

* Remove unused Makefile content

Signed-off-by: JmPotato <ghzpotato@gmail.com>
2021-05-22 23:29:23 -07:00
wpedrak c69165412d Skip few long running tests in `-short` mode 2021-04-23 13:10:08 +02:00
lzhfromustc 981093d53c test: add buffer to a channel to avoid the goroutine leak 2021-03-24 11:43:11 -04:00
Gyuho Lee 4d27a42422
Merge pull request #206 from lzhfromustc/4_Fatal_misusages
Fix the misusage of t.Fatal() in 4 test functions
2020-03-19 11:27:51 -07:00
Josh Rickmar 543c40ab41 Fix unsafe pointer conversions caught by Go 1.14 checkptr 2020-03-18 21:18:39 -04:00
Ziheng Liu 59e65f9618 Fix the misusage of t.Fatal() in 4 test functions 2020-03-03 23:00:28 -05:00
Xingyu Chen 8693da9f4d use segregated hashmap to boost the freelist allocate and release performance (#141) 2019-01-25 10:30:05 -08:00
John Howard 7ee3ded59d Fix Windows flock/funlock race (#122)
Signed-off-by: John Howard <jhoward@microsoft.com>
2018-09-12 13:56:54 -07:00
Gyuho Lee 76a4670663 *: update import paths "go.etcd.io/bbolt"
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
2018-08-28 08:15:54 -07:00
Paul e06ec0a754 Fix Close() to also wait for view transactions and fix tests as well (#91)
* Fix testDB_Close_PendingTx to do something with the writable arg and stop it from closing twice

* Fix Close() to wait for view transactions by getting a full lock on mmaplock

* Fix the TestTx_Check_ReadOnly to close the view transaction

* Fix the TestTx_Commit_ErrTxNotWritable to close the view transaction
2018-08-27 19:56:38 -07:00
Gyuho Lee 0bff9a461c *: update import paths to "github.com/etcd-io/bbolt"
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
2018-08-27 19:25:01 -07:00
Anthony Romano 41fefe7322 test: check concurrent WriteTo operations aren't corrupted
Reliably triggers consistency check failures on ramdisk without freelist
free fix.
2017-11-16 08:16:58 -08:00
Gyu-Ho Lee 68861c5f87 db_test.go: remove temp files after tests
Was filling up all the disk space in Jenkins VMs.

Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
2017-09-28 01:39:15 -07:00
Anthony Romano e39821f3de *: fix gofmt errors and makefile test 2017-09-13 14:38:05 -07:00
lorneli d294ec8a42 db: add test in read-only mode 2017-09-12 20:04:55 +08:00
Anthony Romano a6c45c18c3 Merge pull request #16 from heyitsanthony/config-page-size
Options.PageSize
2017-08-11 10:43:09 -07:00
Anthony Romano 6b378d844e Merge pull request #18 from heyitsanthony/fmt
more fmt passes
2017-08-11 09:58:09 -07:00
Anthony Romano 1ab9756653 fix overflow breaking 32-bit test builds 2017-08-10 23:36:52 -07:00
Anthony Romano 32c9f9e929 pass unused 2017-08-10 22:07:25 -07:00
Anthony Romano 012f88489b add PageSize to Option struct
Configure the db page size at runtime. Makes cross-arch debugging a bit easier.
2017-08-10 20:46:08 -07:00
Anthony Romano 78ca4fde00 get rid of os.Getpagesize() calls where appropriate 2017-08-10 20:46:08 -07:00
Gyu-Ho Lee 7ce671beee *: fix gofmt style issues in 'range' 2017-07-27 14:57:54 -07:00
Anthony Romano 05bfb3bd9a rebuild freelist when opening with FreelistSync after NoFreelistSync
Writes pgidNoFreelist to the meta freelist page to detect when freelists
haven't been synced down.

Fixes #5
2017-07-25 08:01:43 -07:00