fix: Prevent speculative file growth and mmap state on MaxSize exceeded on Windows env.#1205
fix: Prevent speculative file growth and mmap state on MaxSize exceeded on Windows env.#1205Elbehery wants to merge 2 commits into
Windows env.#1205Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Elbehery The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
da58b8a to
9d3e334
Compare
|
@ahrtr following up on #1130 (comment)
so instead of disabling the to eliminate it's side effect. Please let me know if this is sufficient Also I have added all the commits from #1130, authored by @mattsains 👍🏽 Thanks for your patience and support 🙏🏽 |
9d3e334 to
493227e
Compare
|
To avoid long back and forth review communication, please just apply my PR #1206 into your PR, thx |
|
Hello I just saw the comment. Will follow up tomorrow morning It is almost done, I want finalize it if possible plz |
Sure. Please add all related test cases in the first commit, and ensure all test cases fail. Then apply my PR/commit as the second commit, and ensure all test cases pass. |
1640b45 to
725b012
Compare
|
@ahrtr ptal 👍🏽 |
|
@Elbehery can you orignaize this PR so that we only have two commits as mentioned above #1205 (comment)? |
29e967a to
77a4979
Compare
|
/ok-to-test |
|
@ahrtr updated but the CI is not being triggered :/ |
| t.Run("reads succeed after open with high InitialMmapSize", func(t *testing.T) { | ||
| path := copyDB(t) | ||
| db, err := btesting.OpenDBWithOption(t, path, &bolt.Options{ | ||
| MaxSize: 1, | ||
| InitialMmapSize: int(baseSize), | ||
| }) | ||
| require.NoError(t, err) | ||
| defer db.MustClose() | ||
|
|
||
| err = db.View(func(tx *bolt.Tx) error { | ||
| b := tx.Bucket([]byte("data")) | ||
| require.NotNil(t, b, "bucket 'data' must exist") | ||
| require.NotNil(t, b.Get([]byte("0001")), "key 0001 must be readable") | ||
| return nil | ||
| }) | ||
| require.NoError(t, err, "read transaction must succeed") | ||
| }) | ||
|
|
||
| // After open with high InitialMmapSize and a generous MaxSize, small | ||
| // writes that fit within the limit must succeed. | ||
| t.Run("small writes succeed after open with high InitialMmapSize", func(t *testing.T) { | ||
| path := copyDB(t) | ||
| db, err := btesting.OpenDBWithOption(t, path, &bolt.Options{ | ||
| MaxSize: int(baseSize) * 4, | ||
| InitialMmapSize: int(baseSize) * 2, | ||
| }) | ||
| require.NoError(t, err) | ||
| defer db.MustClose() | ||
|
|
||
| err = fillDBWithKeys(db, 1, 1) | ||
| require.NoError(t, err, "small write must succeed when within MaxSize") | ||
| }) | ||
|
|
||
| // After open, writes that would push past MaxSize must return ErrMaxSizeReached. | ||
| t.Run("oversized writes return ErrMaxSizeReached after open with high InitialMmapSize", func(t *testing.T) { | ||
| path := copyDB(t) | ||
| db, err := btesting.OpenDBWithOption(t, path, &bolt.Options{ | ||
| MaxSize: int(baseSize), | ||
| InitialMmapSize: int(baseSize) / 2, | ||
| }) | ||
| require.NoError(t, err) | ||
| defer db.MustClose() | ||
|
|
||
| err = fillDBWithKeys(db, 2, 100000) |
There was a problem hiding this comment.
Please move them into a separate test case, use table driven sub test
|
/retest |
|
Looks like bot broke. |
- Update fillDBWithKeys to accept a configurable value size - Fix TestDB_MaxSizeNotExceeded to use larger values that trigger grow - Remove Windows skip from TestDB_MaxSizeExceededCanOpenWithHighMmap - Rewrite TestDB_MaxSizeExceededDoesNotGrow with table-driven sub-tests covering InitialMmapSize variants on Windows - Add TestDB_MaxSizeWithHighInitialMMapDoesNotGrowOnWrite for non-Windows Signed-off-by: elbehery <elbeherymustafa@gmail.com>
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
77a4979 to
9e9dae1
Compare
|
close & reopen still don't trigger the workflow. @Elbehery probably raise a new PR? |
|
raised #1210 |
|
Maybe it's Github that broke |
yes #1210 (comment) |
|
/retest |
|
closed in favor of #1210 |
Fixes #1108
Continuation of #1130
cc @ahrtr @ivanvc @fuweid @serathius