Method: Fluent::Plugin::Output#rollback_write

Defined in:
lib/fluent/plugin/output.rb

#rollback_write(chunk_id, update_retry: true) ⇒ Object

update_retry parameter is for preventing busy loop by async write We will remove this parameter by re-design retry_state management between threads.



1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
# File 'lib/fluent/plugin/output.rb', line 1126

def rollback_write(chunk_id, update_retry: true)
  # This API is to rollback chunks explicitly from plugins.
  # 3rd party plugins can depend it on automatic rollback of #try_rollback_write
  @dequeued_chunks_mutex.synchronize do
    @dequeued_chunks.delete_if{ |info| info.chunk_id == chunk_id }
  end
  # returns true if chunk was rollbacked as expected
  #         false if chunk was already flushed and couldn't be rollbacked unexpectedly
  # in many cases, false can be just ignored
  if @buffer.takeback_chunk(chunk_id)
    @rollback_count_metrics.inc
    if update_retry
      primary = @as_secondary ? @primary_instance : self
      primary.update_retry_state(chunk_id, @as_secondary)
    end
    true
  else
    false
  end
end