fluentd 1.15.0-x86-mingw32 → 1.15.1-x86-mingw32

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: 941e114cec61513919b4fbd711bfc2bb58254a75d8f5f76028027f432cc89116
4
- data.tar.gz: 8ec3c41476caf98e3a82ef624786d1fb9900361480326476141d8a0eb58c19d4
3
+ metadata.gz: 14de5d3497bb33697ce746637f710eb09e7504142a90fcdf80b61dd6de9997ed
4
+ data.tar.gz: 4273c9f6178dc0bb04ac79433c12fc60a0b2ebe5a5876f7fe39b1c4278cae2ad
5
5
  SHA512:
6
- metadata.gz: 923a7cc3e4449082c7e9de20e6fb39cd9d2e42f481bece900e779a8a711d961b81c5fe38ff34f907473ef8a35e9ddff1d33d6e9b42d63377c147ddd88c9ba368
7
- data.tar.gz: 2f4e5a26e4ab6d82784aad47784c3371c0b59920222301d3ef5ec105807e6bcd58c6153d2af0316842b1f62ca9f68aaa7c7f811f0b8b8d54e1d7bbef101ed1a4
6
+ metadata.gz: 689134be721ca4af6bf05f278dea10687f24eef985978032be425fdef1a43056f903d04efb8aaf81efc4418ece9127da88e39546643dbb872c962410528dc3f3
7
+ data.tar.gz: bd4ef3aacb731e0f8eeb013b52160e40225f57d15f698fbb8b034e79fbfff2ae3567c76bb5f7d9302b01fff1dca28537886d254a94e5a3af4d913c580636a35d
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: x86-mingw32
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