Thomas Jungblut
3ce0fd0ad5
add freelist interface unit tests
...
adding more unit tests for better coverage of the interface.
Signed-off-by: Thomas Jungblut <tjungblu@redhat.com>
2024-08-20 10:44:26 +02:00
Benjamin Wang
257eadc054
rollback alloc map: remove all page ids which are allocated by the txid
...
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
2024-08-12 16:05:21 +01:00
Thomas Jungblut
33b71a50af
Dedupe Reload/NoSyncReload, prefer empty instead of nil init
...
Reload and NoSyncReload have duplicated code, this unifies both
for later refactoring.
This PR is split from #786 , where the tests found differences on reloading
and nil/empty initializations. Added some more clarifications in godocs
for certain panic behavior and expected returns on the interface.
Signed-off-by: Thomas Jungblut <tjungblu@redhat.com>
2024-08-06 11:20:34 +02:00
Benjamin Wang
da1c83cbeb
panicking when a write txn tries to free a page which was allocated by itself
...
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
2024-07-30 08:41:22 +01:00
Benjamin Wang
49c7697344
Merge pull request #794 from tjungblu/791_inconsistency
...
ensure hashmap init clears maps
2024-07-30 08:37:25 +01:00
Thomas Jungblut
f4de460a1b
add testcases for hashmap init
...
This also rectifies a bunch of nil/empty differences between the
implementation that show up during init and page releases.
Signed-off-by: Thomas Jungblut <tjungblu@redhat.com>
2024-07-22 16:52:06 +02:00
Thomas Jungblut
ce50f55c6e
ensure hashmap init clears maps
...
This reorders some statements in the hashmap initialization to ensure we
always start fresh, even when no pageids were passed to it.
fixes #791
Signed-off-by: Thomas Jungblut <tjungblu@redhat.com>
2024-07-22 16:20:01 +02:00
Benjamin Wang
7b031d53c9
add test case to verify freelist in case of TXN rollback
...
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
2024-07-22 14:17:46 +01:00
Benjamin Wang
d1cd0deee6
No need to handle freelist as a specical case when freeing a page
...
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
2024-07-17 13:25:50 +01:00
Thomas Jungblut
62e81c036f
introduce a freelist interface
...
This introduces an interface for the freelist, splits it into two concrete
implementations.
fixes etcd-io#773
Signed-off-by: Thomas Jungblut <tjungblu@redhat.com>
2024-07-09 10:41:35 +02:00
ncabatoff
804c83609e
Rework assertion to follow etcd approach. Enable assertions in tests.
...
Signed-off-by: ncabatoff <ncabatoff@hashicorp.com>
2023-10-26 09:19:13 -04:00
Benjamin Wang
31914ea6e8
cmd: add meta page related surgery commands
...
Two command:
- surgery meta validate
- surgery meta update
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-10-18 16:55:03 +01:00
Allen Ray
18ebb97451
Update to go1.21.1
...
Signed-off-by: Allen Ray <alray@redhat.com>
2023-09-15 09:26:06 -04: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
a78b0c40ed
set page flags directly instead of XOR the value
...
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-05-19 19:33:21 +08:00
Benjamin Wang
b027e485ce
cmd: print a warning to abandon the freelist if present in 'surgery copy-page' command
...
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-05-06 06:25:23 +08:00
Benjamin Wang
6adc0c47a6
move FreelistType from internal/common to top level package bbolt
...
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-04-12 07:32:45 +08: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
1776766466
move copyFile into internal/common/util.go
...
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-04-05 14:08:17 +08:00
Benjamin Wang
dc50a72933
cmd: add 'surgery abandon-freelist' command
...
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-03-31 07:04:05 +08:00
Benjamin Wang
a12c0c4bd7
test: support enabling strict mode in testing
...
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-03-29 08:38:02 +08:00
Benjamin Wang
74e26bee77
update command 'surgery clear-page-elements' not to automatically abandon freelist
...
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-03-25 09:33:59 +08:00
Benjamin Wang
87eed0ac93
add test case to verify 'surgery-clear-elements' on overflow page
...
Also resolved a bug related to overflow page.
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-03-25 07:42:01 +08:00
Benjamin Wang
8902ef92e9
resolve some minor review comments
...
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-03-25 07:42:01 +08:00
Benjamin Wang
9832aff38a
internal: add function ClearElements in surgeon package
...
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-03-25 07:42:01 +08:00
Benjamin Wang
b91d901b74
test: perform check in view(readonly) mode
...
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-03-20 11:00:38 +08:00
Benjamin Wang
15d561e54f
move inode operations(read/write) into package internal/common
...
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-03-15 08:44:19 +08:00
Benjamin Wang
a3a9877de6
encapsulate the logic of checking the page type
...
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-03-08 10:47:59 +08:00
Benjamin Wang
852b1df32f
refactor: move inode to internal/common package
...
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-03-04 04:22:09 +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
34595e7231
create a common package
...
Points:
1. There are lots of duplicated definitions between bolt and
guts_cli, which is definitely not good.
2. The implementation in guts_cli also has issue, please
refer to https://github.com/etcd-io/bbolt/issues/391 .
This refactoring can fix the issue.
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
Benjamin Wang
834868d65d
add 'surgery clear-page' command
...
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-01-20 18:46:07 +08:00
Benjamin Wang
8df4afc24b
add 'bbolt surgery revert-meta-page' command
...
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-01-16 18:32:41 +08:00
Piotr Tabor
eb0deb9550
Refactor common code within key-order checker.
...
Signed-off-by: Piotr Tabor <ptab@google.com>
2023-01-13 19:14:45 +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
ee27a544ca
Recursive checker: Final touches.
...
Signed-off-by: Piotr Tabor <ptab@google.com>
2023-01-13 19:14:45 +01:00
Piotr Tabor
710c33fe89
Tests for recursive checker (working on a corrupted files).
...
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
a938f00609
Merge pull request #373 from fuweid/fix-213
...
fix data race on tx.Stats
2023-01-05 06:46:28 +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
Piotr Tabor
bf9b712eb2
Add Test whether XRay finds path to a bucket as well.
...
Signed-off-by: Piotr Tabor <ptab@google.com>
2023-01-03 19:02:55 +01:00
Piotr Tabor
9f841cc213
Fix goimports and scripts.
...
Signed-off-by: Piotr Tabor <ptab@google.com>
2023-01-03 19:02:55 +01:00
Piotr Tabor
8961219de8
Execution of ./scripts/fix.sh
...
Signed-off-by: Piotr Tabor <ptab@google.com>
2022-12-30 12:59:02 +01:00
Piotr Tabor
9a6782574d
Add library that allows to perform low-level changes/inspection on bbolt file.
...
For sake of usage it in tests and CLI (so internal).
Signed-off-by: Piotr Tabor <ptab@google.com>
2022-12-30 12:59:02 +01:00
Piotr Tabor
fc83b20869
Factor out low-lever access to pages out of CLI into internal/guts.
...
Long-term guts_cli should get replaced by the main code from bbolt main code.
Signed-off-by: Piotr Tabor <ptab@google.com>
2022-12-28 16:53:03 +01: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
93380c59e8
testing: group (reorder) imports.
...
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
46cdbf5b6c
Factor out (bolt)testing library.
...
Thanks to putting it outside the bbolt_test package it can be used to test other packages.
The replacement of the bbolt_test variant inlined in db_test.go is to be performed in a follow up PR.
Signed-off-by: Piotr Tabor <ptab@google.com>
2022-12-28 15:18:46 +01:00