fluentd 1.15.0-x64-mingw-ucrt → 1.15.1-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fluentd might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a6e43bfa63b90a8a0955bf136969601b7b82a5670d15e5a11c5754e7fb9fc0f
4
- data.tar.gz: 8f0d2eb534deabed428d241abc3ff465354667cda27fb14b0aefd4473dc1fe64
3
+ metadata.gz: a8a4ebaf830b3781a6abcdbaf11e7f09a90b16cab77077a752b1bf9410bf4cfa
4
+ data.tar.gz: e5e23fbaf4d812a195b9d298118f9f826bc1715436006007434df2f1497d18a6
5
5
  SHA512:
6
- metadata.gz: 2d8cd91e569687321b67ece222365241d81eccd69076e5bfaa1d65082d32741d83bfa3ee2837be73cae8f0786fdd0eefc6cb797e6aa85de8237f7dee5471dd10
7
- data.tar.gz: a11bcbf8bfefa286a6f82dc679ba54959b482f55c5f71f18b76a2db4838e4b0aa2b6ecd9c0391ed6e8f9e7b16066e6bf1e0a01ecfba66e52e48e3093d8eb6069
6
+ metadata.gz: b11d570ebef680b7028293220b70c265fc81d932fb46e315b4ce1b6ccce6c683cddca89223500ab53c1435ce46b2dfdd37a29d01403bf5fea1001e44a00c30ca
7
+ data.tar.gz: e839fe3659ae89e5f0aa59cf938b9f4e8d8075148b8d526dd214e6ab5a423e9c497aad7e9b152dbb03f84b19ed26353682f842846b6a4fb770932eaf8b6c00cb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # v1.15
2
2
 
3
+ ## Release v1.15.1 - 2022/07/27
4
+
5
+ ### Bug Fix
6
+
7
+ * Add support for concurrent append in out_file
8
+ https://github.com/fluent/fluentd/pull/3808
9
+
10
+ ### Misc
11
+
12
+ * in_tail: Show more information on skipping update_watcher
13
+ https://github.com/fluent/fluentd/pull/3829
14
+
3
15
  ## Release v1.15.0 - 2022/06/29
4
16
 
5
17
  ### Enhancement
data/lib/fluent/error.rb CHANGED
@@ -28,6 +28,9 @@ module Fluent
28
28
  class InvalidRootDirectory < UnrecoverableError
29
29
  end
30
30
 
31
+ class InvalidLockDirectory < UnrecoverableError
32
+ end
33
+
31
34
  # For internal use
32
35
  class UncatchableError < Exception
33
36
  end
@@ -31,6 +31,7 @@ module Fluent
31
31
  def initialize
32
32
  @log = nil
33
33
  super
34
+ @fluentd_lock_dir = ENV['FLUENTD_LOCK_DIR']
34
35
  @_state = State.new(false, false, false, false, false, false, false, false, false)
35
36
  @_context_router = nil
36
37
  @_fluentd_worker_id = nil
@@ -70,6 +71,24 @@ module Fluent
70
71
  true
71
72
  end
72
73
 
74
+ def get_lock_path(name)
75
+ name = name.gsub(/[^a-zA-Z0-9]/, "_")
76
+ File.join(@fluentd_lock_dir, "fluentd-#{name}.lock")
77
+ end
78
+
79
+ def acquire_worker_lock(name)
80
+ if @fluentd_lock_dir.nil?
81
+ raise InvalidLockDirectory, "can't acquire lock because FLUENTD_LOCK_DIR isn't set"
82
+ end
83
+ lock_path = get_lock_path(name)
84
+ File.open(lock_path, "w") do |f|
85
+ f.flock(File::LOCK_EX)
86
+ yield
87
+ end
88
+ # Update access time to prevent tmpwatch from deleting a lock file.
89
+ FileUtils.touch(lock_path);
90
+ end
91
+
73
92
  def string_safe_encoding(str)
74
93
  unless str.valid_encoding?
75
94
  str = str.scrub('?')
@@ -498,7 +498,8 @@ module Fluent::Plugin
498
498
  pe_inode = pe.read_inode
499
499
  target_info_from_position_entry = TargetInfo.new(path, pe_inode)
500
500
  unless pe_inode == @pf[target_info_from_position_entry].read_inode
501
- log.debug "Skip update_watcher because watcher has been already updated by other inotify event"
501
+ log.warn "Skip update_watcher because watcher has been already updated by other inotify event",
502
+ path: path, inode: pe.read_inode, inode_in_pos_file: @pf[target_info_from_position_entry].read_inode
502
503
  return
503
504
  end
504
505
  end
@@ -188,6 +188,10 @@ module Fluent::Plugin
188
188
  condition = Gem::Dependency.new('', [">= 2.7.0", "< 3.1.0"])
189
189
  @need_ruby_on_macos_workaround = true if condition.match?('', RUBY_VERSION)
190
190
  end
191
+
192
+ if @need_lock && @append && @fluentd_lock_dir.nil?
193
+ raise Fluent::InvalidLockDirectory, "must set FLUENTD_LOCK_DIR on multi-worker append mode"
194
+ end
191
195
  end
192
196
 
193
197
  def multi_workers_ready?
@@ -217,7 +221,13 @@ module Fluent::Plugin
217
221
  end
218
222
 
219
223
  if @append
220
- writer.call(path, chunk)
224
+ if @need_lock
225
+ acquire_worker_lock(path) do
226
+ writer.call(path, chunk)
227
+ end
228
+ else
229
+ writer.call(path, chunk)
230
+ end
221
231
  else
222
232
  find_filepath_available(path, with_lock: @need_lock) do |actual_path|
223
233
  writer.call(actual_path, chunk)
@@ -875,7 +875,11 @@ module Fluent
875
875
  se = ServerEngine.create(ServerModule, WorkerModule){
876
876
  Fluent::Supervisor.load_config(@config_path, params)
877
877
  }
878
- se.run
878
+
879
+ Dir.mktmpdir("fluentd-lock-") do |lock_dir|
880
+ ENV['FLUENTD_LOCK_DIR'] = lock_dir
881
+ se.run
882
+ end
879
883
  end
880
884
 
881
885
  def install_main_process_signal_handlers
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Fluent
18
18
 
19
- VERSION = '1.15.0'
19
+ VERSION = '1.15.1'
20
20
 
21
21
  end
@@ -1,4 +1,5 @@
1
1
  require_relative '../helper'
2
+ require 'tmpdir'
2
3
  require 'fluent/plugin/base'
3
4
 
4
5
  module FluentPluginBaseTest
@@ -112,4 +113,37 @@ class BaseTest < Test::Unit::TestCase
112
113
  assert_equal 1, logger.logs.size
113
114
  assert{ logger.logs.first.include?("invalid byte sequence is replaced in ") }
114
115
  end
116
+
117
+ test 'generates worker lock path safely' do
118
+ Dir.mktmpdir("test-fluentd-lock-") do |lock_dir|
119
+ ENV['FLUENTD_LOCK_DIR'] = lock_dir
120
+ p = FluentPluginBaseTest::DummyPlugin.new
121
+ path = p.get_lock_path("Aa\\|=~/_123");
122
+
123
+ assert_equal lock_dir, File.dirname(path)
124
+ assert_equal "fluentd-Aa______123.lock", File.basename(path)
125
+ end
126
+ end
127
+
128
+ test 'can acquire inter-worker locking' do
129
+ Dir.mktmpdir("test-fluentd-lock-") do |lock_dir|
130
+ ENV['FLUENTD_LOCK_DIR'] = lock_dir
131
+ p = FluentPluginBaseTest::DummyPlugin.new
132
+ lock_path = p.get_lock_path("test_base")
133
+
134
+ p.acquire_worker_lock("test_base") do
135
+ # With LOCK_NB set, flock() returns `false` when the
136
+ # file is already locked.
137
+ File.open(lock_path, "w") do |f|
138
+ assert_equal false, f.flock(File::LOCK_EX|File::LOCK_NB)
139
+ end
140
+ end
141
+
142
+ # Lock should be release by now. In that case, flock
143
+ # must return 0.
144
+ File.open(lock_path, "w") do |f|
145
+ assert_equal 0, f.flock(File::LOCK_EX|File::LOCK_NB)
146
+ end
147
+ end
148
+ end
115
149
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluentd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.0
4
+ version: 1.15.1
5
5
  platform: x64-mingw-ucrt
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-29 00:00:00.000000000 Z
11
+ date: 2022-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler