Introduce static_write_txn - #373
Open
Paraworker wants to merge 2 commits into
Open
Conversation
Kerollmops
requested changes
Jul 10, 2026
Kerollmops
left a comment
Member
There was a problem hiding this comment.
Hello @Paraworker,
Thanks for the changes. Looks good to me. I would just like you to clean a bit the codebase.
Thank you very much 🌵
Comment on lines
281
to
+289
| pub(crate) fn new<T>(env: &'p Env<T>) -> Result<RwTxn<'p>> { | ||
| Self::begin(Cow::Borrowed(&env.inner)) | ||
| } | ||
|
|
||
| pub(crate) fn static_write_txn<T>(env: Env<T>) -> Result<RwTxn<'static>> { | ||
| Self::begin(Cow::Owned(env.inner)) | ||
| } | ||
|
|
||
| fn begin(env: Cow<'_, Arc<EnvInner>>) -> Result<RwTxn<'_>> { |
Member
There was a problem hiding this comment.
Would you mind changing a bit the naming and doing the same naming changes for the RoTxn struct, please?
static_read_txnbecomesfrom_owned_envstatic_write_txnbecomesfrom_owned_env- apply the same technique to provide a
Cowas a parameter to thebeginmethod for theRoTxntoo.
Paraworker
force-pushed
the
main
branch
2 times, most recently
from
July 10, 2026 08:29
5a0872c to
8fde86c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
What does this PR do?
Env::static_write_txnandEncryptedEnv::static_write_txn, mirroring the existingstatic_read_txnAPI. These constructors consume the env (self) and return anRwTxn<'static>whose lifetime is no longer tied to a borrowedEnv, letting callers hold a write txn without keeping a separateEnvreference alive.heed/src/txn.rsmirrorsRwTxn::static_read_txn: begins anmdb_txn_beginwrite transaction and stores the env asCow::OwnedinsideRoTxnInnerso the env cannot be closed while the txn lives.
write_txnrustdoc on bothEnvandEncryptedEnvto cross-reference the newstatic_write_txn.PR checklist
Please check if your PR fulfills the following requirements:
static_read_txnimplementation, then mirrored its shape forstatic_write_txn(env consumed by value,Cow::Ownedenv handle,'staticlifetime on the returned txn). Final code and docs were reviewed by hand.