def close(flush_to_disk = false)
@shared_data.synchronize do
@shared_data.client.write("closeTransaction", @txn_id,
AnalyticsLogger.timestamp_string, true)
result = @shared_data.client.read
if result != ["ok"]
raise "Expected logging server to respond with 'ok', but got #{result.inspect} instead"
end
if flush_to_disk
@shared_data.client.write("flush")
result = @shared_data.client.read
if result != ["ok"]
raise "Invalid logging server response #{result.inspect} to the 'flush' command"
end
end
@shared_data.unref
@shared_data = nil
end if @shared_data
end