Skip to content

Conversation

jamesob
Copy link
Contributor

@jamesob jamesob commented Jul 18, 2021

Make a note about a potentially confusing behavior with BaseIndex::m_synced;
if the user starts bitcoind with an empty datadir and an index enabled,
BaseIndex will consider itself synced (as a degenerate case). This affects
how indices are built during IBD (relying solely on BlockConnected signals vs.
using ThreadSync()).

Copy link

@Bocoi5011 Bocoi5011 left a comment

Choose a reason for hiding this comment

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

.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 19, 2021

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #25193 (indexes: Read the locator's top block during init, allow interaction with reindex-chainstate by mzumsande)
  • #24230 (indexes: Stop using node internal types and locking cs_main, improve sync logic by ryanofsky)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@bitcoin bitcoin deleted a comment from Bocoi5011 Jul 19, 2021

// Note: this will latch to true immediately if the user starts up with an empty
// datadir and an index enabled. If this is the case, indexation will happen solely
// via `BlockConnected` signals until, possibly, the next restart.
Copy link
Member

@maflcko maflcko Jul 19, 2021

Choose a reason for hiding this comment

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

What do you mean with "until the next restart"? Once the index is in sync with the active chain tip, it will stay that way, regardless of restarts. The only way it could get out of sync is when you disable the index on a restart, advance the tip, then enable it again. Am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is contingent on how fast the particular indexing process is; you can imagine that if a given index takes (for the sake of argument) a minute per block to build, if we get 1000 blocks connected and then the user shuts down immediately, the validationinterface queue may not clear* and we will start up out of sync after having been "synced" in the degenerate way. Does this make sense?

*I know we wait for this queue to clear during a graceful shutdown, but we can't assume this.

Copy link
Contributor

Choose a reason for hiding this comment

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

In commit "index: doc/log BaseIndex sync behavior with empty datadir" (2b48b03)

I also found this confusing and would suggest just saying "the index will get updated and stay in sync through BlockConnected notifications"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My issue with your suggested comment is that that isn't a complete picture of what's going on - as described above, indexation will only happen via BlockConnectected notifications until the next restart. If we have a hard shutoff that doesn't clear the validation queue, the index will sync sequentially in ThreadSync(), which makes that comment somewhat misleading.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine. I think I'm just agreeing with Marco that the comment seemed a little strange because I didn't know what it might be implying. It seems obvious there will be no BlockConnected signals if the process is dead.

@DrahtBot DrahtBot mentioned this pull request Jul 24, 2021
18 tasks
@tryphe
Copy link
Contributor

tryphe commented Jul 30, 2021

Concept ACK

Any easy way to confirm this behavior, regarding BlockConnected signals vs.
using ThreadSync()? Would be willing to test it out.

@jamesob
Copy link
Contributor Author

jamesob commented Oct 29, 2021

Worth merging? Anything left to do here? Should I close?

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK 2b48b03. Concept ~0. I'd be curious to know more about what is confusing without this log message. It seems pretty straightforward that if there are no blocks, then there is nothing for the sync thread to do, and the index is in sync. Like if pieces_of_popcorn == 0 then popcorn_eaten == true. So I'm not sure why this is confusing or degenerate, etc.

I guess I like the new comments, but I'm just unsure what the log message adds.


// Note: this will latch to true immediately if the user starts up with an empty
// datadir and an index enabled. If this is the case, indexation will happen solely
// via `BlockConnected` signals until, possibly, the next restart.
Copy link
Contributor

Choose a reason for hiding this comment

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

In commit "index: doc/log BaseIndex sync behavior with empty datadir" (2b48b03)

I also found this confusing and would suggest just saying "the index will get updated and stay in sync through BlockConnected notifications"

@jamesob jamesob closed this Nov 30, 2021
@jamesob
Copy link
Contributor Author

jamesob commented Jan 10, 2022

Reopening as I think this is still a useful clarification when trying to remind myself of how indexation works.

@maflcko
Copy link
Member

maflcko commented Jan 11, 2022

It is recommended to address the feedback comments in some way before merge

@jamesob
Copy link
Contributor Author

jamesob commented Jan 11, 2022

I guess I like the new comments, but I'm just unsure what the log message adds.

It's obviously not mandatory, but I found the whole indexation process a little confusing and so I figured the more hints the better?

Copy link
Contributor

@mzumsande mzumsande left a comment

Choose a reason for hiding this comment

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

ACK to the comment, I think that the additional log message would be redundant (see below).

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK 2b48b03. This seems fine and generally better, despite confusion and nitpicking


// Note: this will latch to true immediately if the user starts up with an empty
// datadir and an index enabled. If this is the case, indexation will happen solely
// via `BlockConnected` signals until, possibly, the next restart.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine. I think I'm just agreeing with Marco that the comment seemed a little strange because I didn't know what it might be implying. It seems obvious there will be no BlockConnected signals if the process is dead.

Copy link
Contributor

@fjahr fjahr left a comment

Choose a reason for hiding this comment

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

utACK 2b48b03

I think this can be merged as is but I would prefer it without the log message (see my comment).

I think one more place where a note on this could be helpful for users is in the getindexinfo RPC, something like this: fjahr@255f094. Feel free to add this in here but I can also open a follow-up.

@bitcoin bitcoin deleted a comment from Rokon22 Apr 18, 2022
@jamesob jamesob force-pushed the 2021-07-index-doc branch from 2b48b03 to 59c8765 Compare July 18, 2022 19:25
@jamesob jamesob changed the title index: doc/log BaseIndex sync behavior with empty datadir doc: BaseIndex sync behavior with empty datadir Jul 18, 2022
@jamesob jamesob force-pushed the 2021-07-index-doc branch from 59c8765 to 4ba81ca Compare July 21, 2022 14:31
Make a note about a potentially confusing behavior with `BaseIndex::m_synced`;
if the user starts bitcoind with an empty datadir and an index enabled,
BaseIndex will consider itself synced (as a degenerate case). This affects
how indices are built during IBD (relying solely on BlockConnected signals vs.
using ThreadSync()).
@jamesob jamesob force-pushed the 2021-07-index-doc branch from 4ba81ca to 11780f2 Compare July 21, 2022 14:33
@mzumsande
Copy link
Contributor

ACK 11780f2

@maflcko maflcko merged commit b8067cd into bitcoin:master Jul 21, 2022
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 22, 2022
11780f2 doc: BaseIndex sync behavior with empty datadir (James O'Beirne)

Pull request description:

  Make a note about a potentially confusing behavior with `BaseIndex::m_synced`;
  if the user starts bitcoind with an empty datadir and an index enabled,
  BaseIndex will consider itself synced (as a degenerate case). This affects
  how indices are built during IBD (relying solely on BlockConnected signals vs.
  using ThreadSync()).

ACKs for top commit:
  mzumsande:
    ACK 11780f2

Tree-SHA512: 0b530379e57c62e05d2ddca7bb8e2c936786fa00678f9eaa1bb3742d957c48f141d46f936734b03f6673d964abc7eb72c1769f1784b9d3563d218e96296b7afd
@bitcoin bitcoin locked and limited conversation to collaborators Jul 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants