moose-inventory 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 570b23a90a452e12fb6aa8f03e5b9613a3c365ff
4
- data.tar.gz: 152441118aedc1f0935510e6f9c7357d514553b7
3
+ metadata.gz: 97767bc15af5cacaf663c0d481bdf3bb3ce44945
4
+ data.tar.gz: b78aee8bd6198832650adf9f6d396f0f8e104ec2
5
5
  SHA512:
6
- metadata.gz: 15a262e2ac4d8bab1fc356b7f60aceb612544d09a1df770952199eabe4668923dae44d40cf2d76460939f197374208bef687c8e33a70f575979a9635bbceaa38
7
- data.tar.gz: 44eb25e1744164bc618c5d54ae52bc926f30f8e5c265939fb7ae53dd857ec8c676831089713b1d674f7c17079d723bbf310189d890a88bf76e163ca4649ff094
6
+ metadata.gz: f72e5c69616c5453b9a03282754ba78292e4c92e3f6e9293b9ab3bb62f99a6cc616bad2ed3701e568565e881eef47321d7dac15bfded5085210b677152f78366
7
+ data.tar.gz: f8c1100975131c6646659b642efad9e579eef5984cf5c6bd4b886d609e08b6f78c0d21dba0340e81f8b0f41229bfcb3bb3554cdf077da194baa4943f22838c51
@@ -65,17 +65,46 @@ module Moose
65
65
  #--------------------
66
66
  def self.transaction
67
67
  fail('Database connection has not been established') if @db.nil?
68
+
69
+ tries = 0
70
+
68
71
  begin
69
72
  @db.transaction(savepoint: true) do
70
73
  yield
71
74
  end
72
75
 
76
+ rescue Sequel::DatabaseError => e
77
+ # We want to rescue Sqlite3::BusyException. But, sequel catches that
78
+ # and re-raises it as Sequel::DatabaseError, with a message referencing
79
+ # the original exception class
80
+
81
+ # We look into e, to see whether it is a BusyException. If not,
82
+ # we re-raise immediately.
83
+ raise unless e.message.include?("BusyException")
84
+
85
+ # Looks like a BusyException, so we retrying, with a random stand-off.
86
+ tries += 1
87
+ case tries
88
+ when 1..10
89
+ if Moose::Inventory::Config._confopts[:trace] == true
90
+ STDERR.puts e.message
91
+ end
92
+ warn('The database appears to be locked by another process. '\
93
+ " This was try #{tries} of 10. "\
94
+ ' Retrying after a pause of random duration.')
95
+ sleep rand()
96
+ retry
97
+ else
98
+ raise
99
+ end
100
+
73
101
  rescue @exceptions[:moose] => e
74
102
  warn 'An error occurred during a transaction, any changes have been rolled back.'
75
103
 
76
104
  if Moose::Inventory::Config._confopts[:trace] == true
105
+ STDERR.puts $!.backtrace
77
106
  abort("ERROR: #{e}")
78
- else
107
+ else
79
108
  abort("ERROR: #{e.message}")
80
109
  end
81
110
 
@@ -2,6 +2,6 @@ module Moose
2
2
  ##
3
3
  # The Moose-Tools dynamic inventory management library
4
4
  module Inventory
5
- VERSION = '1.0.4'
5
+ VERSION = '1.0.5'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moose-inventory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Russell Davies
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-29 00:00:00.000000000 Z
11
+ date: 2015-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: indentation