Skip to content

Allow optional persistent datadir - #52

Merged
RCasatta merged 1 commit into
rust-bitcoin:masterfrom
rajarshimaitra:persistent-datadir
Mar 23, 2022
Merged

RCasatta merged 1 commit into
rust-bitcoin:masterfrom
rajarshimaitra:persistent-datadir

Conversation

@rajarshimaitra

Copy link
Copy Markdown
Contributor

The intention here is to open possibility to have persistent data directory option for the node along with tempdir option too..

There were many ways of doing this.. I choose this one as it seemed the one with least changes..

Looking for approach acks..

@RCasatta

Copy link
Copy Markdown
Collaborator

Internals logic with DataDir structs looks ok from a first look but I have doubts with the Conf struct.

Use cases we need are:

  1. Create a temp dir where the SO put temporary stuff (eg /tmp)
  2. Create a temp dir in this root directory I am giving you
  3. Use this datadir I am giving you and avoid deletion at the end

The reason why Conf is #[non_exhaustive] is to be free to add fields while avoiding breaking changes downstream, if we rename tmpdir in datadir not only we are not compatible, but we are loosing use case (2)

I think we should add a field in the Conf struct which is datadir: Option<PathBuf>

If both datadir and tmpdir are some we throw an error

if both are none we do (1)

if tmpdir is some we do (2)

if datadir is some we do (3)

@rajarshimaitra
rajarshimaitra force-pushed the persistent-datadir branch 2 times, most recently from 410b4d5 to fa929ba Compare March 21, 2022 05:59
@rajarshimaitra

Copy link
Copy Markdown
Contributor Author

Yes thanks for the suggestion. That makes perfect sense. Updated the Conf struct to simulate the behavior..

@RCasatta RCasatta left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please also squash the 2 commits because the second one reworks stuff of the previous?

Thanks for your work

Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
@RCasatta

Copy link
Copy Markdown
Collaborator

Another thing come to my mind, at the moment the impl Drop simply kill the process which is fine for temporary directory, but for persistent I think is better to call stop from the rpc

@rajarshimaitra

Copy link
Copy Markdown
Contributor Author

Thanks @RCasatta for the review.. All were valid points.. Polished up the code a bit.. Changed the name workdir to staticdir, similar names were getting confusing..

Added the self.client.stop at Drop, but not sure what happens when the client returns error in a stop call.. Maybe it just ignores and drops anyway..

@RCasatta

RCasatta commented Mar 22, 2022 •

Copy link
Copy Markdown
Collaborator

Added the self.client.stop at Drop, but not sure what happens when the client returns error in a stop call.. Maybe it just ignores and drops anyway..

I think it's fine how you did it (no panic should ever happen in drop)

utack except for #52 (comment)

This allows the node work directory to be either temporary or
persisting on the disk.

This can be configured using the `tmpdir` and `staticdir` `Conf` options
in different combinations. Usage information in the `Conf` doc.
@rajarshimaitra

Copy link
Copy Markdown
Contributor Author

utack except for #52 (comment)

I assume its the comment on the specific error type? Fixed that in last push..

@RCasatta

RCasatta commented Mar 23, 2022 •

Copy link
Copy Markdown
Collaborator

ACK 7e05242

thanks!

going to release a new version on crates.io soon

@RCasatta
RCasatta merged commit 7e05242 into rust-bitcoin:master Mar 23, 2022
tcharding added a commit to rust-bitcoin/corepc that referenced this pull request May 7, 2026
c08ea32 bitcoind: call wait in drop to reap process (Nick Johnson)

Pull request description:

  Over in [rust-psbt we are seeing integration test failures](https://git.rust-bitcoin.org/rust-bitcoin/rust-psbt/actions/runs/58/jobs/8/attempt/1) which result in a CI runner spinning for hours, even though the test failed in a minute. Setting aside why the test failed (looks bitcoind related but dunno what), I am wondering if we should have a stronger guarantee in the drop to clean up the process. I looked back in the [old archive for the original impl reasoning](rust-bitcoin/bitcoind#52) and don't see much.

  I could also see this being a big no-no in a Drop impl, but for a high level thing like the bitcoind process maybe better than not?

ACKs for top commit:
  tcharding:
    ACK c08ea32

Tree-SHA512: 9a1ff79f4f8ad3735363cc385f235fd3dc99643965b4f134de5514014167f8e41baf313384173d8404e650d2cfcf74d1f99dcd3edf4f596a5922a49cf83a6d5a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants