-
Notifications
You must be signed in to change notification settings - Fork 260
Flaky test fix: Reduce unnecessary reads from live ledgers, and log a warning when they do occur #8047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Eddy Ashton (eddyashton)
wants to merge
6
commits into
microsoft:main
from
eddyashton:distinguish_chunk_flush_from_state_get
Closed
Flaky test fix: Reduce unnecessary reads from live ledgers, and log a warning when they do occur #8047
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0fd61a6
Avoid unnecessary ledger reads, log warnings where they remain
eddyashton 127a2b9
Lint
eddyashton a8080ee
Merge branch 'main' of https://github.com/microsoft/CCF into distingu…
eddyashton 110e730
Merge branch 'main' into distinguish_chunk_flush_from_state_get
eddyashton a8afa8f
Merge branch 'main' into distinguish_chunk_flush_from_state_get
achamayou a635637
Merge branch 'main' into distinguish_chunk_flush_from_state_get
achamayou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2212,23 +2212,54 @@ def wait_for_snapshots_to_be_committed( | |
|
|
||
| return node.get_committed_snapshots(wait_for_snapshots_to_be_committed) | ||
|
|
||
| def _get_ledger_public_view_at(self, node, call, seqno, timeout): | ||
| def create_and_wait_for_chunk(self, node=None, seqno=None, timeout=5): | ||
| if node is None: | ||
| node, _ = self.find_primary() | ||
|
|
||
| proposal = self.consortium.force_ledger_chunk(node) | ||
| target_seqno = seqno or proposal.completed_seqno | ||
| end_time = time.time() + timeout | ||
| self.consortium.force_ledger_chunk(node) | ||
| last_error = None | ||
| while time.time() < end_time: | ||
| chunk = node.find_committed_ledger_chunk_covering(target_seqno) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be better done with |
||
| if chunk is not None: | ||
| LOG.info( | ||
| "Found committed ledger chunk {}-{} covering seqno {} at {}", | ||
| chunk[0], | ||
| chunk[1], | ||
| target_seqno, | ||
| chunk[2], | ||
| ) | ||
| return proposal, chunk | ||
|
|
||
| try: | ||
| return call(seqno) | ||
| member = self.consortium.get_any_active_member() | ||
| r = member.update_ack_state_digest(node) | ||
| with node.client() as c: | ||
| c.wait_for_commit(r) | ||
| except Exception as ex: | ||
| LOG.info(f"Exception: {ex}") | ||
| time.sleep(0.1) | ||
| last_error = ex | ||
| LOG.info(f"Exception while waiting for committed chunk: {ex}") | ||
| time.sleep(0.1) | ||
|
|
||
| raise TimeoutError( | ||
| f"Could not read transaction at seqno {seqno} from ledger {node.remote.ledger_paths()} after {timeout}s" | ||
| f"Could not find committed chunk covering seqno {target_seqno} " | ||
| f"on node {node.local_node_id} after {timeout}s: {last_error}" | ||
| ) | ||
|
|
||
| def _get_ledger_public_view_at(self, node, call, seqno, timeout): | ||
| self.create_and_wait_for_chunk(node=node, seqno=seqno, timeout=timeout) | ||
| return call(node.get_committed_ledger(), seqno) | ||
|
|
||
| def get_ledger_public_state_at(self, seqno, timeout=5): | ||
| primary, _ = self.find_primary() | ||
| return self._get_ledger_public_view_at( | ||
| primary, primary.get_ledger_public_tables_at, seqno, timeout | ||
| primary, | ||
| lambda ledger, s: ledger.get_transaction(s) | ||
| .get_public_domain() | ||
| .get_tables(), | ||
| seqno, | ||
| timeout, | ||
| ) | ||
|
|
||
| def get_latest_ledger_public_state(self, timeout=5): | ||
|
|
@@ -2238,7 +2269,10 @@ def get_latest_ledger_public_state(self, timeout=5): | |
| body = resp.body.json() | ||
| tx_id = TxID.from_str(body["transaction_id"]) | ||
| return self._get_ledger_public_view_at( | ||
| primary, primary.get_ledger_public_state_at, tx_id.seqno, timeout | ||
| primary, | ||
| lambda ledger, _: ledger.get_latest_public_state(), | ||
| tx_id.seqno, | ||
| timeout, | ||
| ) | ||
|
|
||
| @functools.cached_property | ||
|
|
||
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be a
POST /node/snapshot:createinstead, rather than the slow and complicated governance business this call involves.