+
Skip to content

Conversation

cbeck88
Copy link
Contributor

@cbeck88 cbeck88 commented Oct 12, 2022

These batches have a size which is configurable as a command line parameter.


The point of this is that we have been having issues where the network latency to get from fog-view to postgres has been high enough that it becomes the bottleneck for fog-view loading all the data into ORAM, and begins to significantly negatively impact the time to restart fog view. We can make the server more tolerant of that by making it try to load more data at once.

Thanks to James for suggested approach here

These batches have a size which is configurable as a command line
parameter.
@cbeck88 cbeck88 requested review from a team, eranrund, jcape, remoun and samdealy October 12, 2022 04:55
// We might have more work to do, we aren't sure because of the error
may_have_more_work = true;
// Let's back off for one interval when there is an error
sleep(DB_POLL_INTERNAL);
Copy link
Contributor Author

@cbeck88 cbeck88 Oct 12, 2022

Choose a reason for hiding this comment

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

I am not sure if this is a good idea, but right now I think nothing backs off if we hit the error path, which might be a bad thing.

This is not directly related to the main change.

let proto = ProtoIngestedBlockData::decode(&*proto)?;
result.push(proto.e_tx_out_records);
} else {
log::warn!(self.logger, "When querying for block index {} and up to {} blocks on, the {}'th response has block_number {} which is not expected. Gaps in the data?", block_index, block_count, idx, block_number);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

there is not much reason to think that this code path will happen, but I would rather be defensive

@cbeck88 cbeck88 self-assigned this Oct 12, 2022
@cbeck88 cbeck88 added remediation Issue: Postmortem remediation fog-view labels Oct 12, 2022
Copy link
Contributor

@eranrund eranrund left a comment

Choose a reason for hiding this comment

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

Nice, thank you for the quick turnaround on this.
Some relatively minor suggestions for improvements.

@jcape jcape added the old-v3.0.0 Blocker for v3 (should get cherry-picked to release/v3 branch) label Oct 12, 2022
@cbeck88 cbeck88 requested review from eranrund and remoun October 13, 2022 04:58
@wjuan-mob wjuan-mob self-requested a review October 13, 2022 17:17
@cbeck88
Copy link
Contributor Author

cbeck88 commented Oct 13, 2022

this passed CD

};

// We will get one row for each hit in the table we found
let rows: Vec<(i64, Vec<u8>)> = query.load::<(i64, Vec<u8>)>(&conn)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC we don't need to specify the type twice

Suggested change
let rows: Vec<(i64, Vec<u8>)> = query.load::<(i64, Vec<u8>)>(&conn)?;
let rows: Vec<(i64, Vec<u8>)> = query.load(&conn)?;

let db_test_context = SqlRecoveryDbTestContext::new(logger.clone());
let db = db_test_context.get_db_instance();
let db_fetcher = DbFetcher::new(db.clone(), Default::default(), logger);
let db_fetcher = DbFetcher::new(db.clone(), Default::default(), 1, logger);
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems useful to exercise a DbFetcher with batch_size > 1 in this file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, we do that in the smoke test, but I thought it's okay to keep this unit test working with 1

/// Arguments:
/// * ingress_key: The ingress key we need ETxOutRecords from
/// * block_index: The first block we need ETxOutRecords from
/// * block_count: How many subsequent blocks to also request data for.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this should be how many consecutive blocks to also request data for? Subsequent seems to suggest 0 should just return only this block_index, and 1 means return this and 1 additional?

/// Arguments:
/// * ingress_key: The ingress key we need ETxOutRecords from
/// * block_index: The first block we need ETxOutRecords from
/// * block_count: How many subsequent blocks to also request data for.
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar comment to above.

Co-authored-by: Remoun Metyas <remoun@mobilecoin.com>
@cbeck88 cbeck88 merged commit c372ea0 into release/v2 Oct 13, 2022
@cbeck88 cbeck88 deleted the feature/fog-view-db-batch-loading branch October 13, 2022 18:24
cbeck88 added a commit that referenced this pull request Oct 14, 2022
* Make fog-view load blocks from postgres in batches

These batches have a size which is configurable as a command line
parameter.

* fixup tests

* add unit test for new function

* address eran and remoun comments in db_fetcher

* change parameter to a usize

* rename per request

* Update fog/sql_recovery_db/src/lib.rs

Co-authored-by: Remoun Metyas <remoun@mobilecoin.com>

Co-authored-by: Remoun Metyas <remoun@mobilecoin.com>
cbeck88 added a commit that referenced this pull request Oct 17, 2022
* Make fog-view load blocks from postgres in batches (#2707)

* Make fog-view load blocks from postgres in batches

These batches have a size which is configurable as a command line
parameter.

* fixup tests

* add unit test for new function

* address eran and remoun comments in db_fetcher

* change parameter to a usize

* rename per request

* Update fog/sql_recovery_db/src/lib.rs

Co-authored-by: Remoun Metyas <remoun@mobilecoin.com>

Co-authored-by: Remoun Metyas <remoun@mobilecoin.com>

* Nits from fog view db fetch pr (#2714)

* fix nits from fog-view-db-fetch pull request

* update changelog

Co-authored-by: Remoun Metyas <remoun@mobilecoin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fog-view old-v3.0.0 Blocker for v3 (should get cherry-picked to release/v3 branch) remediation Issue: Postmortem remediation

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载