]> git.openstreetmap.org Git - chef.git/commitdiff
Merge remote-tracking branch 'github/pull/317'
authorTom Hughes <tom@compton.nu>
Tue, 7 Jul 2020 19:19:40 +0000 (20:19 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 7 Jul 2020 19:19:40 +0000 (20:19 +0100)
cookbooks/planet/files/default/replication-bin/replicate-changesets
cookbooks/planet/recipes/replication.rb
cookbooks/planet/templates/default/changesets.conf.erb

index 29131b2edd27c2394fb5d83f76157912d90a58ec..77dc83312e946354415b09112f1952ebffa550d7 100755 (executable)
@@ -261,8 +261,13 @@ class Replicator
 
   # saves new state (including the changeset dump xml)
   def save!
-    File.open(@config["state_file"], "r") do |fl|
-      fl.flock(File::LOCK_EX)
+    File.open(@config["lock_file"], File::RDWR | File::CREAT, 0o600) do |fl|
+      # take the lock in non-blocking mode. if this process doesn't get the lock
+      # then another will be run from cron shortly. this prevents a whole bunch
+      # of processes queueing on the lock and causing weirdness if/when they
+      # get woken up in a random order.
+      got_lock = fl.flock(File::LOCK_EX | File::LOCK_NB)
+      return unless got_lock
 
       # try and write the files to tmp locations and then
       # move them into place later, to avoid in-progress
index b23c00f36bacacdc65ef03b4ec303e247ee56afc..f1be1d0d0b45fe8676d1c8b3ad37b5854b85b851 100644 (file)
@@ -127,6 +127,12 @@ directory "/etc/replication" do
   mode 0o755
 end
 
+directory "/var/run/lock/changeset-replication/" do
+  owner "planet"
+  group "planet"
+  mode 0o750
+end
+
 template "/etc/replication/auth.conf" do
   source "replication.auth.erb"
   user "root"
index 309f253b49638720077e3f01bfba988567a8fd1c..73fc83e17ecba370a9c4bd24d7348eee3ea784e1 100644 (file)
@@ -1,3 +1,4 @@
 state_file: /store/planet/replication/changesets/state.yaml
 db: host=<%= node[:web][:database_host] %> dbname=openstreetmap user=planetdiff password=<%= @password %>
 data_dir: /store/planet/replication/changesets
+lock_file: /var/run/lock/changeset-replication/lockfile