bricolage-streamingload 0.14.1 → 0.14.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba544bbf6c3a133aeb0882e5193296dc734a25ec
4
- data.tar.gz: 8706c5cd050e1083075d2890e422e3834680c2ea
3
+ metadata.gz: 01102c31f0c9f92fb7d6653c130f2a06633cf1fc
4
+ data.tar.gz: 4b160bb1a4c176faa0451319d94c8d6aa2404f85
5
5
  SHA512:
6
- metadata.gz: d03f41030b3c7bc7175c1abf7b2f6e8e5c3a40c3cff5754e678c76338190b9c0293792dc4a8cc34fbf262419ac054467503c823ceafc2a55a6e59d9a2762f937
7
- data.tar.gz: 8bd7c0cc4b826383d552ed196581b00a8d33010e24ada2cb9f3eb76ed381178b35e706585a2da449d019bf8bd4e43233afc84902695382df152925261d3fb848
6
+ metadata.gz: cd84fa57a717eda77e19710004df60ee780311e3ef89d8668f1d65ef0b67455911339194dae90c914e2c60f56eece109d2ca460998ad918a0d554a273aa5b950
7
+ data.tar.gz: 7e981e9c417716f0b5b51a90b442596849c906f62184222b4b2dd9347f3e4c510e2400748f93989ab60b46a95974b5842d5b557be721ac01362f3a410e25a678
@@ -69,7 +69,7 @@ module Bricolage
69
69
  return true
70
70
  end
71
71
 
72
- MAX_RETRY = 5
72
+ MAX_RETRY = 2
73
73
 
74
74
  def execute_task
75
75
  @process_id = "#{Socket.gethostname}-#{$$}"
@@ -241,6 +241,12 @@ module Bricolage
241
241
  ;
242
242
  EndSQL
243
243
  @logger.info "load succeeded: #{manifest.url}"
244
+ rescue JobFailure => ex
245
+ if /stl_load_errors/ =~ ex.message
246
+ # We cannot resolve this load error by retry, give up now.
247
+ raise JobError, ex.message
248
+ end
249
+ raise
244
250
  end
245
251
 
246
252
  def write_load_log(log)
@@ -1,5 +1,5 @@
1
1
  module Bricolage
2
2
  module StreamingLoad
3
- VERSION = '0.14.1'
3
+ VERSION = '0.14.2'
4
4
  end
5
5
  end
@@ -161,8 +161,7 @@ module Bricolage
161
161
  [1001, 's3://data-bucket/testschema.sql_fails/0001.json.gz', 1024, 'testschema.sql_fails', 'mmmm', current_timestamp, current_timestamp],
162
162
  [1002, 's3://data-bucket/testschema.sql_fails/0002.json.gz', 1024, 'testschema.sql_fails', 'mmmm', current_timestamp, current_timestamp]
163
163
  db.insert_into 'strload_jobs',
164
- [101, 11, 'localhost-1234', 'failure', current_timestamp, current_timestamp, 'query failed'],
165
- [102, 11, 'localhost-1234', 'failure', current_timestamp, current_timestamp, 'query failed']
164
+ [101, 11, 'localhost-1234', 'failure', current_timestamp, current_timestamp, 'query failed']
166
165
 
167
166
  job = new_job(task_id: 11, force: false)
168
167
  assert_raise(JobFailure) {
@@ -178,7 +177,7 @@ module Bricolage
178
177
  assert_equal 11, job_row['task_id'].to_i
179
178
  assert_equal job.process_id, job_row['process_id']
180
179
  assert_equal 'failure', job_row['status']
181
- assert(/retry\#2/ =~ job_row['message'])
180
+ assert(/retry\#1/ =~ job_row['message'])
182
181
  }
183
182
  end
184
183
 
@@ -267,6 +266,33 @@ module Bricolage
267
266
  }
268
267
  end
269
268
 
269
+ test "execute_task (load error)" do
270
+ setup_context {|db|
271
+ db.insert_into 'strload_tables', [1, 'testschema.load_error', 'testschema', 'load_error', 100, 1800, false]
272
+ db.insert_into 'strload_tasks', [11, 'streaming_load_v3', 1, current_timestamp]
273
+ db.insert_into 'strload_task_objects', [11, 1001], [11, 1002]
274
+ db.insert_into 'strload_objects',
275
+ [1001, 's3://data-bucket/testschema.desttable/0001.json.gz', 1024, 'testschema.desttable', 'mmmm', current_timestamp, current_timestamp],
276
+ [1002, 's3://data-bucket/testschema.desttable/0002.json.gz', 1024, 'testschema.desttable', 'mmmm', current_timestamp, current_timestamp]
277
+
278
+ job = new_job(task_id: 11, force: false)
279
+ assert_raise(JobError) {
280
+ job.execute_task
281
+ }
282
+ assert_equal [
283
+ "begin transaction;",
284
+ "copy testschema.load_error from '#{job.manifest.url}' credentials 'cccc' manifest statupdate false compupdate false json 'auto' gzip timeformat 'auto' dateformat 'auto' acceptanydate acceptinvchars ' ' truncatecolumns trimblanks ;",
285
+ "abort;"
286
+ ], job.data_ds.sql_list
287
+
288
+ job_row = db.query_row("select * from strload_jobs where job_id = #{job.job_id}")
289
+ assert_equal 11, job_row['task_id'].to_i
290
+ assert_equal job.process_id, job_row['process_id']
291
+ assert_equal 'error', job_row['status']
292
+ assert(/stl_load_errors/ =~ job_row['message'])
293
+ }
294
+ end
295
+
270
296
  test "execute_task (unknown status, really=success)" do
271
297
  setup_context {|db|
272
298
  db.insert_into 'strload_tables', [1, 'testschema.desttable', 'testschema', 'desttable', 100, 1800, false]
@@ -430,11 +456,12 @@ module Bricolage
430
456
  class PSQLDataSourceMock < DataSource
431
457
  declare_type 'psql_mock'
432
458
 
433
- def initialize(fail_pattern: nil, error_pattern: nil, exception_pattern: nil, **params)
459
+ def initialize(fail_pattern: nil, error_pattern: nil, exception_pattern: nil, load_error_pattern: nil, **params)
434
460
  @sql_list = []
435
461
  @fail_pattern = fail_pattern ? Regexp.compile(fail_pattern) : nil
436
462
  @error_pattern = error_pattern ? Regexp.compile(error_pattern) : nil
437
463
  @exception_pattern = exception_pattern ? Regexp.compile(exception_pattern) : nil
464
+ @load_error_pattern = load_error_pattern ? Regexp.compile(load_error_pattern) : nil
438
465
  @job_status = {}
439
466
  end
440
467
 
@@ -461,6 +488,9 @@ module Bricolage
461
488
  if @exception_pattern and @exception_pattern =~ sql
462
489
  raise ArgumentError, "unexpected exception"
463
490
  end
491
+ if @load_error_pattern and @load_error_pattern =~ sql
492
+ raise JobError, "Load into table 'xxxx_table' failed. Check 'stl_load_errors' system table for details."
493
+ end
464
494
  end
465
495
 
466
496
  def provide_job_status(job_id, succeeded)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bricolage-streamingload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 0.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minero Aoki
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-01-09 00:00:00.000000000 Z
12
+ date: 2018-02-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bricolage
@@ -99,13 +99,13 @@ description: Bricolage Streaming Load Daemon loads S3 data files to Redshift con
99
99
  email:
100
100
  - aamine@loveruby.net
101
101
  executables:
102
- - bricolage-streaming-dispatcher
102
+ - send-flushtable-event
103
+ - send-shutdown-event
104
+ - send-load-task
103
105
  - bricolage-streaming-loader
104
106
  - send-checkpoint-event
105
107
  - send-data-event
106
- - send-flushtable-event
107
- - send-load-task
108
- - send-shutdown-event
108
+ - bricolage-streaming-dispatcher
109
109
  extensions: []
110
110
  extra_rdoc_files: []
111
111
  files: