No need to handle freelist as a specical case when freeing a page#788
No need to handle freelist as a specical case when freeing a page#788ahrtr merged 1 commit intoetcd-io:mainfrom
Conversation
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
eaf4f1e to
d1cd0de
Compare
| delete(t.allocs, p.Id()) | ||
| } else if p.IsFreelistPage() { | ||
| // Freelist is always allocated by prior tx. | ||
| allocTxid = txid - 1 |
There was a problem hiding this comment.
The Line 79 txp.alloctx = append(txp.alloctx, allocTxid) could append zero into alloctx.
There are two cases we should consider:
Rollback
The zero value will be covered by the rollback. So it looks fine.
bbolt/internal/freelist/shared.go
Lines 96 to 99 in efc3eb6
Release by opening new writable TX
This change looks safe to me because the page will be free after all the read-only TX are closed.
I think the original Freelist is always allocated by prior tx. might free the page which can be read by opening read-only TX.
bbolt/internal/freelist/shared.go
Lines 179 to 183 in efc3eb6
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahrtr, fuweid, ivanvc The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/lgtm Thanks @ahrtr - I'll adjust the testcases accordingly. |
Read #67 (comment)
When the page ID to be freed isn't included in
f.allocs, then it means it must be allocated before opening the db this time, and the write transaction is the very first write TXN after opening the db. So it (the page ID to be freed) must be visible to all readonly transactions. We just need to use the default value 0 for such case, in the same way as we did for other page types.Will rebase this PR once #775 gets merged.
The existing test cases already cover the sanity test. We will add more dedicated test cases for freelist management later.
cc @tjungblu @fuweid @ivanvc