propogate replicate through the account_report process
- currently we swap back to :report db even if upstream we timed out from using it and are using :secondary. Result is missed data in the output report. flag = none test plan: This is tricky to test as it is a race condition between primary and report db and requires report db to timeout on being up to date. For now, just verify specs pass and monitor if empty reports continue to happen in prod. Change-Id: I92f0024593cd497949747378b8c8792e4cc047b3 refs: PFS-18941 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/286338 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Matt Maruri <mmaruri@instructure.com> QA-Review: Mark Valentine <mvalentine@instructure.com> Product-Review: Mark Valentine <mvalentine@instructure.com>
This commit is contained in:
parent
4b5cfc36e4
commit
fdd9c25dc6
|
@ -302,12 +302,12 @@ module AccountReports::ReportHelper
|
|||
)
|
||||
end
|
||||
|
||||
def write_report(headers, enable_i18n_features = false, &block)
|
||||
file = generate_and_run_report(headers, "csv", enable_i18n_features, &block)
|
||||
def write_report(headers, enable_i18n_features = false, replica = :report, &block)
|
||||
file = generate_and_run_report(headers, "csv", enable_i18n_features, replica, &block)
|
||||
GuardRail.activate(:primary) { send_report(file) }
|
||||
end
|
||||
|
||||
def generate_and_run_report(headers = nil, extension = "csv", enable_i18n_features = false)
|
||||
def generate_and_run_report(headers = nil, extension = "csv", enable_i18n_features = false, replica = :report)
|
||||
file = AccountReports.generate_file(@account_report, extension)
|
||||
options = {}
|
||||
if enable_i18n_features
|
||||
|
@ -316,7 +316,7 @@ module AccountReports::ReportHelper
|
|||
ExtendedCSV.open(file, "w", **options) do |csv|
|
||||
csv.instance_variable_set(:@account_report, @account_report)
|
||||
csv << headers unless headers.nil?
|
||||
activate_report_db { yield csv } if block_given?
|
||||
activate_report_db(replica: replica) { yield csv } if block_given?
|
||||
GuardRail.activate(:primary) { @account_report.update_attribute(:current_line, csv.lineno) }
|
||||
end
|
||||
file
|
||||
|
@ -449,7 +449,7 @@ module AccountReports::ReportHelper
|
|||
|
||||
def write_report_from_rows(headers, replica: :report)
|
||||
activate_report_db(replica: replica) do
|
||||
write_report(headers) do |csv|
|
||||
write_report(headers, false, replica) do |csv|
|
||||
@account_report.account_report_rows.order(:account_report_runner_id, :row_number)
|
||||
.find_in_batches(strategy: :cursor) do |batch|
|
||||
batch.each { |record| csv << record.row }
|
||||
|
@ -463,7 +463,7 @@ module AccountReports::ReportHelper
|
|||
activate_report_db(replica: replica) do
|
||||
files.each do |file, headers_for_file|
|
||||
csvs[file] = if @account_report.account_report_rows.where(file: file).exists?
|
||||
generate_and_run_report(headers_for_file) do |csv|
|
||||
generate_and_run_report(headers_for_file, "csv", false, replica) do |csv|
|
||||
@account_report.account_report_rows.where(file: file)
|
||||
.order(:account_report_runner_id, :row_number)
|
||||
.find_in_batches(strategy: :cursor) do |batch|
|
||||
|
@ -471,7 +471,7 @@ module AccountReports::ReportHelper
|
|||
end
|
||||
end
|
||||
else
|
||||
generate_and_run_report(headers_for_file)
|
||||
generate_and_run_report(headers_for_file, "csv", false, replica)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue