Skip to content

Commit

Permalink
Less logspam from the data writer, and slower
Browse files Browse the repository at this point in the history
Slower data writer might reduce the race condition in logrus. See #280.
  • Loading branch information
shuhaowu committed Apr 30, 2021
1 parent 6285e4f commit 52be393
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/helpers/data_writer_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,22 @@ def start(&on_write)
@threads << Thread.new do
@logger.info("starting data writer thread #{i}")

n = 0
begin
connection = Mysql2::Client.new(@db_config)

until @stop_requested do
write_data(connection, &on_write)
n += 1
# Kind of makes the following race condition a bit better...
# https://github.com/Shopify/ghostferry/issues/280
sleep(0.03)
end
ensure
connection.close
end

@logger.info("stopped data writer thread #{i}")
@logger.info("stopped data writer thread #{i} with a total of #{n} data writes")
end
end
end
Expand Down Expand Up @@ -99,7 +104,6 @@ def write_data(connection, &on_write)
op = "DELETE"
end

@logger.debug("writing data: #{op} #{id}")
on_write.call(op, id) unless on_write.nil?
end

Expand Down

0 comments on commit 52be393

Please sign in to comment.