wurk 1.15.0 → 1.16.0

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.
Files changed (261) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -7
  3. data/app/controllers/wurk/api_controller.rb +4 -1
  4. data/app/controllers/wurk/profiles_controller.rb +15 -2
  5. data/lib/wurk/api/app.rb +20 -0
  6. data/lib/wurk/api/problem.rb +8 -1
  7. data/lib/wurk/batch/callbacks.rb +96 -12
  8. data/lib/wurk/batch/death_handler.rb +3 -1
  9. data/lib/wurk/batch/server_middleware.rb +7 -3
  10. data/lib/wurk/capsule.rb +14 -0
  11. data/lib/wurk/client/buffered.rb +124 -25
  12. data/lib/wurk/client.rb +20 -0
  13. data/lib/wurk/configuration.rb +9 -2
  14. data/lib/wurk/cron.rb +35 -4
  15. data/lib/wurk/fetcher/unit_of_work.rb +7 -0
  16. data/lib/wurk/health.rb +4 -1
  17. data/lib/wurk/iterable_job.rb +35 -9
  18. data/lib/wurk/job_retry.rb +10 -2
  19. data/lib/wurk/job_set.rb +9 -4
  20. data/lib/wurk/logger.rb +7 -0
  21. data/lib/wurk/lua/limiter_points_refund.lua +3 -1
  22. data/lib/wurk/lua.rb +54 -7
  23. data/lib/wurk/middleware/current_attributes.rb +40 -11
  24. data/lib/wurk/processor.rb +46 -2
  25. data/lib/wurk/queues.rb +84 -17
  26. data/lib/wurk/rails_boot.rb +1 -1
  27. data/lib/wurk/sorted_entry.rb +10 -2
  28. data/lib/wurk/stats.rb +26 -3
  29. data/lib/wurk/swarm/child_boot.rb +6 -1
  30. data/lib/wurk/unique.rb +32 -6
  31. data/lib/wurk/version.rb +1 -1
  32. data/lib/wurk/worker/setter.rb +13 -15
  33. data/lib/wurk/worker.rb +3 -18
  34. data/lib/wurk.rb +5 -1
  35. data/vendor/assets/dashboard/assets/ArgsValue-s6SvnYnn.js +1 -0
  36. data/vendor/assets/dashboard/assets/ArgsValue-s6SvnYnn.js.br +0 -0
  37. data/vendor/assets/dashboard/assets/ArgsValue-s6SvnYnn.js.gz +0 -0
  38. data/vendor/assets/dashboard/assets/BatchDetail-CprIJHVF.js +1 -0
  39. data/vendor/assets/dashboard/assets/BatchDetail-CprIJHVF.js.br +0 -0
  40. data/vendor/assets/dashboard/assets/BatchDetail-CprIJHVF.js.gz +0 -0
  41. data/vendor/assets/dashboard/assets/Batches-_UtmkdcL.js +1 -0
  42. data/vendor/assets/dashboard/assets/Batches-_UtmkdcL.js.br +0 -0
  43. data/vendor/assets/dashboard/assets/Batches-_UtmkdcL.js.gz +0 -0
  44. data/vendor/assets/dashboard/assets/Busy-CxUt_KaT.js +1 -0
  45. data/vendor/assets/dashboard/assets/Busy-CxUt_KaT.js.br +0 -0
  46. data/vendor/assets/dashboard/assets/Busy-CxUt_KaT.js.gz +0 -0
  47. data/vendor/assets/dashboard/assets/Cron-BO4CLzcL.js +1 -0
  48. data/vendor/assets/dashboard/assets/Cron-BO4CLzcL.js.br +0 -0
  49. data/vendor/assets/dashboard/assets/Cron-BO4CLzcL.js.gz +0 -0
  50. data/vendor/assets/dashboard/assets/Dashboard-BpeXrgWN.js +1 -0
  51. data/vendor/assets/dashboard/assets/Dashboard-BpeXrgWN.js.br +0 -0
  52. data/vendor/assets/dashboard/assets/Dashboard-BpeXrgWN.js.gz +0 -0
  53. data/vendor/assets/dashboard/assets/Dead-DxG8m9Ea.js +1 -0
  54. data/vendor/assets/dashboard/assets/Dead-DxG8m9Ea.js.br +0 -0
  55. data/vendor/assets/dashboard/assets/Dead-DxG8m9Ea.js.gz +0 -0
  56. data/vendor/assets/dashboard/assets/Extension-Bdw1AWK9.js +1 -0
  57. data/vendor/assets/dashboard/assets/Extension-Bdw1AWK9.js.br +0 -0
  58. data/vendor/assets/dashboard/assets/Extension-Bdw1AWK9.js.gz +0 -0
  59. data/vendor/assets/dashboard/assets/FilterBox-qrHAQiEp.js +1 -0
  60. data/vendor/assets/dashboard/assets/FilterBox-qrHAQiEp.js.br +0 -0
  61. data/vendor/assets/dashboard/assets/FilterBox-qrHAQiEp.js.gz +0 -0
  62. data/vendor/assets/dashboard/assets/FlowDetail-BbLiOUVq.js +1 -0
  63. data/vendor/assets/dashboard/assets/FlowDetail-BbLiOUVq.js.br +0 -0
  64. data/vendor/assets/dashboard/assets/FlowDetail-BbLiOUVq.js.gz +0 -0
  65. data/vendor/assets/dashboard/assets/{FlowState-B04ZLDe-.js → FlowState-Cp2exrrY.js} +1 -1
  66. data/vendor/assets/dashboard/assets/FlowState-Cp2exrrY.js.br +2 -0
  67. data/vendor/assets/dashboard/assets/FlowState-Cp2exrrY.js.gz +0 -0
  68. data/vendor/assets/dashboard/assets/Flows-Cdh5HxbD.js +1 -0
  69. data/vendor/assets/dashboard/assets/Flows-Cdh5HxbD.js.br +0 -0
  70. data/vendor/assets/dashboard/assets/Flows-Cdh5HxbD.js.gz +0 -0
  71. data/vendor/assets/dashboard/assets/JobDetailModal-DyrUaaGZ.js +2 -0
  72. data/vendor/assets/dashboard/assets/JobDetailModal-DyrUaaGZ.js.br +0 -0
  73. data/vendor/assets/dashboard/assets/JobDetailModal-DyrUaaGZ.js.gz +0 -0
  74. data/vendor/assets/dashboard/assets/Limiters-D7r6cfSD.js +1 -0
  75. data/vendor/assets/dashboard/assets/Limiters-D7r6cfSD.js.br +0 -0
  76. data/vendor/assets/dashboard/assets/Limiters-D7r6cfSD.js.gz +0 -0
  77. data/vendor/assets/dashboard/assets/Metrics-BLenaRy4.js +1 -0
  78. data/vendor/assets/dashboard/assets/Metrics-BLenaRy4.js.br +0 -0
  79. data/vendor/assets/dashboard/assets/Metrics-BLenaRy4.js.gz +0 -0
  80. data/vendor/assets/dashboard/assets/NotFound-P0HnKG_i.js +1 -0
  81. data/vendor/assets/dashboard/assets/NotFound-P0HnKG_i.js.br +0 -0
  82. data/vendor/assets/dashboard/assets/NotFound-P0HnKG_i.js.gz +0 -0
  83. data/vendor/assets/dashboard/assets/PageHeader-Dr0x5uFD.js +1 -0
  84. data/vendor/assets/dashboard/assets/PageHeader-Dr0x5uFD.js.br +0 -0
  85. data/vendor/assets/dashboard/assets/PageHeader-Dr0x5uFD.js.gz +0 -0
  86. data/vendor/assets/dashboard/assets/Profiles-DwBcuGsp.js +1 -0
  87. data/vendor/assets/dashboard/assets/Profiles-DwBcuGsp.js.br +0 -0
  88. data/vendor/assets/dashboard/assets/Profiles-DwBcuGsp.js.gz +0 -0
  89. data/vendor/assets/dashboard/assets/Queues-BpB_QfMT.js +1 -0
  90. data/vendor/assets/dashboard/assets/Queues-BpB_QfMT.js.br +0 -0
  91. data/vendor/assets/dashboard/assets/Queues-BpB_QfMT.js.gz +0 -0
  92. data/vendor/assets/dashboard/assets/RefreshError-CFF9cD72.js +1 -0
  93. data/vendor/assets/dashboard/assets/RefreshError-CFF9cD72.js.br +0 -0
  94. data/vendor/assets/dashboard/assets/RefreshError-CFF9cD72.js.gz +0 -0
  95. data/vendor/assets/dashboard/assets/Retries-CvpBa3nA.js +1 -0
  96. data/vendor/assets/dashboard/assets/Retries-CvpBa3nA.js.br +0 -0
  97. data/vendor/assets/dashboard/assets/Retries-CvpBa3nA.js.gz +0 -0
  98. data/vendor/assets/dashboard/assets/Scheduled-B5_rNwmD.js +1 -0
  99. data/vendor/assets/dashboard/assets/Scheduled-B5_rNwmD.js.br +0 -0
  100. data/vendor/assets/dashboard/assets/Scheduled-B5_rNwmD.js.gz +0 -0
  101. data/vendor/assets/dashboard/assets/Search-DBiXXQ1X.js +1 -0
  102. data/vendor/assets/dashboard/assets/Search-DBiXXQ1X.js.br +0 -0
  103. data/vendor/assets/dashboard/assets/Search-DBiXXQ1X.js.gz +0 -0
  104. data/vendor/assets/dashboard/assets/activatable-CjwuwYIK.js +1 -0
  105. data/vendor/assets/dashboard/assets/activatable-CjwuwYIK.js.br +0 -0
  106. data/vendor/assets/dashboard/assets/activatable-CjwuwYIK.js.gz +0 -0
  107. data/vendor/assets/dashboard/assets/{ar-CugpXGea.js → ar-CP7xhN_d.js} +1 -1
  108. data/vendor/assets/dashboard/assets/ar-CP7xhN_d.js.br +0 -0
  109. data/vendor/assets/dashboard/assets/ar-CP7xhN_d.js.gz +0 -0
  110. data/vendor/assets/dashboard/assets/charts-BowrQgy3.js +1 -0
  111. data/vendor/assets/dashboard/assets/charts-BowrQgy3.js.br +0 -0
  112. data/vendor/assets/dashboard/assets/charts-BowrQgy3.js.gz +0 -0
  113. data/vendor/assets/dashboard/assets/de-CESa1rIa.js +1 -0
  114. data/vendor/assets/dashboard/assets/de-CESa1rIa.js.br +0 -0
  115. data/vendor/assets/dashboard/assets/de-CESa1rIa.js.gz +0 -0
  116. data/vendor/assets/dashboard/assets/es-DduN2Y-4.js +1 -0
  117. data/vendor/assets/dashboard/assets/es-DduN2Y-4.js.br +0 -0
  118. data/vendor/assets/dashboard/assets/es-DduN2Y-4.js.gz +0 -0
  119. data/vendor/assets/dashboard/assets/fr-D0g3vgjI.js +1 -0
  120. data/vendor/assets/dashboard/assets/fr-D0g3vgjI.js.br +0 -0
  121. data/vendor/assets/dashboard/assets/fr-D0g3vgjI.js.gz +0 -0
  122. data/vendor/assets/dashboard/assets/i18n-DyFKCgd5.js +1 -0
  123. data/vendor/assets/dashboard/assets/i18n-DyFKCgd5.js.br +0 -0
  124. data/vendor/assets/dashboard/assets/i18n-DyFKCgd5.js.gz +0 -0
  125. data/vendor/assets/dashboard/assets/index-BX9nblxT.css +1 -0
  126. data/vendor/assets/dashboard/assets/index-BX9nblxT.css.br +0 -0
  127. data/vendor/assets/dashboard/assets/index-BX9nblxT.css.gz +0 -0
  128. data/vendor/assets/dashboard/assets/index-lb7Hct36.js +141 -0
  129. data/vendor/assets/dashboard/assets/index-lb7Hct36.js.br +0 -0
  130. data/vendor/assets/dashboard/assets/index-lb7Hct36.js.gz +0 -0
  131. data/vendor/assets/dashboard/assets/ja-D04z9gNg.js +1 -0
  132. data/vendor/assets/dashboard/assets/ja-D04z9gNg.js.br +0 -0
  133. data/vendor/assets/dashboard/assets/ja-D04z9gNg.js.gz +0 -0
  134. data/vendor/assets/dashboard/assets/{pt-BR-4k5M2MYH.js → pt-BR-CI0f7zuq.js} +1 -1
  135. data/vendor/assets/dashboard/assets/pt-BR-CI0f7zuq.js.br +0 -0
  136. data/vendor/assets/dashboard/assets/pt-BR-CI0f7zuq.js.gz +0 -0
  137. data/vendor/assets/dashboard/assets/useJobSetList-DOJEPjtn.js +2 -0
  138. data/vendor/assets/dashboard/assets/useJobSetList-DOJEPjtn.js.br +0 -0
  139. data/vendor/assets/dashboard/assets/useJobSetList-DOJEPjtn.js.gz +0 -0
  140. data/vendor/assets/dashboard/assets/useResetPageOnEmpty-BkhAVjcM.js +1 -0
  141. data/vendor/assets/dashboard/assets/useResetPageOnEmpty-BkhAVjcM.js.br +0 -0
  142. data/vendor/assets/dashboard/assets/useResetPageOnEmpty-BkhAVjcM.js.gz +0 -0
  143. data/vendor/assets/dashboard/assets/useSort-BH4O54LC.js +1 -0
  144. data/vendor/assets/dashboard/assets/useSort-BH4O54LC.js.br +0 -0
  145. data/vendor/assets/dashboard/assets/useSort-BH4O54LC.js.gz +0 -0
  146. data/vendor/assets/dashboard/assets/{utils-CQj4rqng.js → utils-5e3YBxoh.js} +1 -1
  147. data/vendor/assets/dashboard/assets/utils-5e3YBxoh.js.br +0 -0
  148. data/vendor/assets/dashboard/assets/utils-5e3YBxoh.js.gz +0 -0
  149. data/vendor/assets/dashboard/assets/zh-CN-Ty7GVN_E.js +1 -0
  150. data/vendor/assets/dashboard/assets/zh-CN-Ty7GVN_E.js.br +0 -0
  151. data/vendor/assets/dashboard/assets/zh-CN-Ty7GVN_E.js.gz +0 -0
  152. data/vendor/assets/dashboard/index.html +3 -3
  153. data/vendor/assets/dashboard/wurk-manifest.json +2 -2
  154. metadata +118 -112
  155. data/vendor/assets/dashboard/assets/ArgsValue-D10BT0xi.js +0 -1
  156. data/vendor/assets/dashboard/assets/ArgsValue-D10BT0xi.js.br +0 -0
  157. data/vendor/assets/dashboard/assets/ArgsValue-D10BT0xi.js.gz +0 -0
  158. data/vendor/assets/dashboard/assets/BatchDetail-ByPRHv86.js +0 -1
  159. data/vendor/assets/dashboard/assets/BatchDetail-ByPRHv86.js.br +0 -0
  160. data/vendor/assets/dashboard/assets/BatchDetail-ByPRHv86.js.gz +0 -0
  161. data/vendor/assets/dashboard/assets/Batches-CVVOJFhz.js +0 -1
  162. data/vendor/assets/dashboard/assets/Batches-CVVOJFhz.js.br +0 -0
  163. data/vendor/assets/dashboard/assets/Batches-CVVOJFhz.js.gz +0 -0
  164. data/vendor/assets/dashboard/assets/Busy-Dp26yz1A.js +0 -1
  165. data/vendor/assets/dashboard/assets/Busy-Dp26yz1A.js.br +0 -0
  166. data/vendor/assets/dashboard/assets/Busy-Dp26yz1A.js.gz +0 -0
  167. data/vendor/assets/dashboard/assets/Cron-BiRV6eoU.js +0 -1
  168. data/vendor/assets/dashboard/assets/Cron-BiRV6eoU.js.br +0 -0
  169. data/vendor/assets/dashboard/assets/Cron-BiRV6eoU.js.gz +0 -0
  170. data/vendor/assets/dashboard/assets/Dashboard-CnpCQ8Of.js +0 -1
  171. data/vendor/assets/dashboard/assets/Dashboard-CnpCQ8Of.js.br +0 -0
  172. data/vendor/assets/dashboard/assets/Dashboard-CnpCQ8Of.js.gz +0 -0
  173. data/vendor/assets/dashboard/assets/Dead-ykYbsK8n.js +0 -1
  174. data/vendor/assets/dashboard/assets/Dead-ykYbsK8n.js.br +0 -0
  175. data/vendor/assets/dashboard/assets/Dead-ykYbsK8n.js.gz +0 -0
  176. data/vendor/assets/dashboard/assets/Extension-BUsciXhN.js +0 -1
  177. data/vendor/assets/dashboard/assets/Extension-BUsciXhN.js.br +0 -0
  178. data/vendor/assets/dashboard/assets/Extension-BUsciXhN.js.gz +0 -0
  179. data/vendor/assets/dashboard/assets/FilterBox-DBIZXNtY.js +0 -1
  180. data/vendor/assets/dashboard/assets/FilterBox-DBIZXNtY.js.br +0 -0
  181. data/vendor/assets/dashboard/assets/FilterBox-DBIZXNtY.js.gz +0 -0
  182. data/vendor/assets/dashboard/assets/FlowDetail-CIGu7pRb.js +0 -1
  183. data/vendor/assets/dashboard/assets/FlowDetail-CIGu7pRb.js.br +0 -0
  184. data/vendor/assets/dashboard/assets/FlowDetail-CIGu7pRb.js.gz +0 -0
  185. data/vendor/assets/dashboard/assets/FlowState-B04ZLDe-.js.br +0 -0
  186. data/vendor/assets/dashboard/assets/FlowState-B04ZLDe-.js.gz +0 -0
  187. data/vendor/assets/dashboard/assets/Flows-Ce9Qoq0c.js +0 -1
  188. data/vendor/assets/dashboard/assets/Flows-Ce9Qoq0c.js.br +0 -0
  189. data/vendor/assets/dashboard/assets/Flows-Ce9Qoq0c.js.gz +0 -0
  190. data/vendor/assets/dashboard/assets/JobDetailModal-DWp0OMoV.js +0 -2
  191. data/vendor/assets/dashboard/assets/JobDetailModal-DWp0OMoV.js.br +0 -0
  192. data/vendor/assets/dashboard/assets/JobDetailModal-DWp0OMoV.js.gz +0 -0
  193. data/vendor/assets/dashboard/assets/Limiters-DiWCiVay.js +0 -1
  194. data/vendor/assets/dashboard/assets/Limiters-DiWCiVay.js.br +0 -0
  195. data/vendor/assets/dashboard/assets/Limiters-DiWCiVay.js.gz +0 -0
  196. data/vendor/assets/dashboard/assets/Metrics-DmMS2wo_.js +0 -1
  197. data/vendor/assets/dashboard/assets/Metrics-DmMS2wo_.js.br +0 -0
  198. data/vendor/assets/dashboard/assets/Metrics-DmMS2wo_.js.gz +0 -0
  199. data/vendor/assets/dashboard/assets/NotFound-CM1j8-Fv.js +0 -1
  200. data/vendor/assets/dashboard/assets/NotFound-CM1j8-Fv.js.br +0 -0
  201. data/vendor/assets/dashboard/assets/NotFound-CM1j8-Fv.js.gz +0 -0
  202. data/vendor/assets/dashboard/assets/PageHeader-BcHVxRbX.js +0 -1
  203. data/vendor/assets/dashboard/assets/PageHeader-BcHVxRbX.js.br +0 -0
  204. data/vendor/assets/dashboard/assets/PageHeader-BcHVxRbX.js.gz +0 -0
  205. data/vendor/assets/dashboard/assets/Profiles-B70MlVYQ.js +0 -1
  206. data/vendor/assets/dashboard/assets/Profiles-B70MlVYQ.js.br +0 -0
  207. data/vendor/assets/dashboard/assets/Profiles-B70MlVYQ.js.gz +0 -0
  208. data/vendor/assets/dashboard/assets/Queues-D3JZtWBv.js +0 -1
  209. data/vendor/assets/dashboard/assets/Queues-D3JZtWBv.js.br +0 -0
  210. data/vendor/assets/dashboard/assets/Queues-D3JZtWBv.js.gz +0 -0
  211. data/vendor/assets/dashboard/assets/Retries-BTWoV6so.js +0 -1
  212. data/vendor/assets/dashboard/assets/Retries-BTWoV6so.js.br +0 -0
  213. data/vendor/assets/dashboard/assets/Retries-BTWoV6so.js.gz +0 -0
  214. data/vendor/assets/dashboard/assets/Scheduled-D3PyiFqr.js +0 -1
  215. data/vendor/assets/dashboard/assets/Scheduled-D3PyiFqr.js.br +0 -0
  216. data/vendor/assets/dashboard/assets/Scheduled-D3PyiFqr.js.gz +0 -0
  217. data/vendor/assets/dashboard/assets/Search-bLwIhsaR.js +0 -1
  218. data/vendor/assets/dashboard/assets/Search-bLwIhsaR.js.br +0 -0
  219. data/vendor/assets/dashboard/assets/Search-bLwIhsaR.js.gz +0 -0
  220. data/vendor/assets/dashboard/assets/ar-CugpXGea.js.br +0 -0
  221. data/vendor/assets/dashboard/assets/ar-CugpXGea.js.gz +0 -0
  222. data/vendor/assets/dashboard/assets/charts-DZyiygHX.js +0 -1
  223. data/vendor/assets/dashboard/assets/charts-DZyiygHX.js.br +0 -0
  224. data/vendor/assets/dashboard/assets/charts-DZyiygHX.js.gz +0 -0
  225. data/vendor/assets/dashboard/assets/de-Bl5Jn_0l.js +0 -1
  226. data/vendor/assets/dashboard/assets/de-Bl5Jn_0l.js.br +0 -0
  227. data/vendor/assets/dashboard/assets/de-Bl5Jn_0l.js.gz +0 -0
  228. data/vendor/assets/dashboard/assets/es-lqQrmjYI.js +0 -1
  229. data/vendor/assets/dashboard/assets/es-lqQrmjYI.js.br +0 -0
  230. data/vendor/assets/dashboard/assets/es-lqQrmjYI.js.gz +0 -0
  231. data/vendor/assets/dashboard/assets/fr-D70VBoh3.js +0 -1
  232. data/vendor/assets/dashboard/assets/fr-D70VBoh3.js.br +0 -0
  233. data/vendor/assets/dashboard/assets/fr-D70VBoh3.js.gz +0 -0
  234. data/vendor/assets/dashboard/assets/i18n-DdPClaCG.js +0 -1
  235. data/vendor/assets/dashboard/assets/i18n-DdPClaCG.js.br +0 -0
  236. data/vendor/assets/dashboard/assets/i18n-DdPClaCG.js.gz +0 -0
  237. data/vendor/assets/dashboard/assets/index-CtK2Dy_G.css +0 -1
  238. data/vendor/assets/dashboard/assets/index-CtK2Dy_G.css.br +0 -0
  239. data/vendor/assets/dashboard/assets/index-CtK2Dy_G.css.gz +0 -0
  240. data/vendor/assets/dashboard/assets/index-ygQ-XC-L.js +0 -141
  241. data/vendor/assets/dashboard/assets/index-ygQ-XC-L.js.br +0 -0
  242. data/vendor/assets/dashboard/assets/index-ygQ-XC-L.js.gz +0 -0
  243. data/vendor/assets/dashboard/assets/ja-BYMqnHjg.js +0 -1
  244. data/vendor/assets/dashboard/assets/ja-BYMqnHjg.js.br +0 -0
  245. data/vendor/assets/dashboard/assets/ja-BYMqnHjg.js.gz +0 -0
  246. data/vendor/assets/dashboard/assets/pt-BR-4k5M2MYH.js.br +0 -0
  247. data/vendor/assets/dashboard/assets/pt-BR-4k5M2MYH.js.gz +0 -0
  248. data/vendor/assets/dashboard/assets/useJobSetList-D-uafkUL.js +0 -2
  249. data/vendor/assets/dashboard/assets/useJobSetList-D-uafkUL.js.br +0 -0
  250. data/vendor/assets/dashboard/assets/useJobSetList-D-uafkUL.js.gz +0 -0
  251. data/vendor/assets/dashboard/assets/useResetPageOnEmpty-DUA0JTgs.js +0 -1
  252. data/vendor/assets/dashboard/assets/useResetPageOnEmpty-DUA0JTgs.js.br +0 -0
  253. data/vendor/assets/dashboard/assets/useResetPageOnEmpty-DUA0JTgs.js.gz +0 -0
  254. data/vendor/assets/dashboard/assets/useSort-BwoC7g__.js +0 -1
  255. data/vendor/assets/dashboard/assets/useSort-BwoC7g__.js.br +0 -0
  256. data/vendor/assets/dashboard/assets/useSort-BwoC7g__.js.gz +0 -0
  257. data/vendor/assets/dashboard/assets/utils-CQj4rqng.js.br +0 -0
  258. data/vendor/assets/dashboard/assets/utils-CQj4rqng.js.gz +0 -0
  259. data/vendor/assets/dashboard/assets/zh-CN-B9E1MvsM.js +0 -1
  260. data/vendor/assets/dashboard/assets/zh-CN-B9E1MvsM.js.br +0 -0
  261. data/vendor/assets/dashboard/assets/zh-CN-B9E1MvsM.js.gz +0 -0
@@ -7,7 +7,8 @@ module Wurk
7
7
  # Activated globally — `Wurk::Client.reliable_push!`. Buffer is
8
8
  # per-process, in-memory only; crash = lost. Does NOT cover batch
9
9
  # creation or batch-context pushes (`bid` on payload): BATCH_PUSH has
10
- # atomic counter side-effects we can't safely replay.
10
+ # atomic counter side-effects we can't safely replay. Nor a batch's
11
+ # callback job (see BATCH_CALLBACK_CLASS).
11
12
  #
12
13
  # A failed push opens a circuit for that Redis: later pushes buffer without
13
14
  # touching the socket, so one caller pays the connection backoff and the rest
@@ -30,6 +31,19 @@ module Wurk
30
31
  # Payloads per replayed raw_push. A backlog reaches Redis in about
31
32
  # N / REPLAY_SLICE calls, each one pipeline per queue.
32
33
  REPLAY_SLICE = 100
34
+ # A batch fire writes the event's dedup marker once the callback push
35
+ # returns, so a callback job held only in memory would be lost on a crash
36
+ # with nothing left to fire it again. It has no `bid` when nothing above
37
+ # it is a batch (and `:death` never has one), so it is named here: its
38
+ # push raises instead, and Batch::Callbacks waits the outage out with the
39
+ # marker unwritten.
40
+ BATCH_CALLBACK_CLASS = 'Wurk::Batch::CallbackJob'
41
+ # Error replies that are about the entry's own data, so a replay drops
42
+ # that entry instead of holding every push behind it. A list of what is
43
+ # known to be the entry's fault, not of server states: an unrecognised
44
+ # reply (a Dragonfly or Valkey `ERR …`, a cluster `MOVED`) keeps the
45
+ # entries and raises, as before, rather than dropping jobs for good.
46
+ ENTRY_ERROR_CODES = %w[WRONGTYPE].freeze
33
47
 
34
48
  # A clean exit tries to deliver what is still in memory, but never holds the
35
49
  # process up for longer than this: a hung Redis would otherwise stall shutdown.
@@ -192,6 +206,11 @@ module Wurk
192
206
  @installed == true
193
207
  end
194
208
 
209
+ # Whether a payload may wait out an outage in memory at all.
210
+ def bufferable?(payload)
211
+ !payload['bid'] && payload['class'] != BATCH_CALLBACK_CLASS
212
+ end
213
+
195
214
  def buffer_cap
196
215
  @buffer_cap ||= DEFAULT_BUFFER_CAP
197
216
  end
@@ -315,8 +334,10 @@ module Wurk
315
334
  # `client` is the one whose push failed; every payload is tagged with
316
335
  # the Redis that client was writing to (see Origin).
317
336
  def enbuffer(payloads, client:)
318
- entries = entries_for(payloads, client)
337
+ # Ahead of entries_for, which serializes and can raise: the ensure
338
+ # reports against these caps whichever way this exits.
319
339
  caps = [buffer_cap, buffer_bytes_cap]
340
+ entries = entries_for(payloads, client)
320
341
  mode = overflow_mode
321
342
  undelivered = buffer_mutex.synchronize do
322
343
  mode == :raise ? append_within_capacity(entries, *caps) : append_dropping_oldest(entries, *caps)
@@ -539,9 +560,9 @@ module Wurk
539
560
  def replay_all(client, target)
540
561
  drained = 0
541
562
  until (entries = take_all(target)).empty?
542
- landed = replay_entries(client, entries)
563
+ landed, stalled = replay_entries(client, entries)
543
564
  drained += landed
544
- next if landed == entries.size
565
+ next unless stalled
545
566
 
546
567
  trip!(target)
547
568
  return drained
@@ -553,7 +574,15 @@ module Wurk
553
574
  # An app's own drainer keeps its interval; only the absence of one makes
554
575
  # this implicit, which is what stops `reset_after_fork!` re-arming it in
555
576
  # children that never pushed.
577
+ #
578
+ # A drainer's own failed replay trips the circuit too, and asks for
579
+ # nothing: either it is the live drainer, or a stop is joining it while
580
+ # holding the install lock. Taking the lock there stalled that stop for
581
+ # the whole join timeout, and once the stop dropped it, the tick found
582
+ # no drainer and started a new one behind the stop's back.
556
583
  def ensure_drainer
584
+ return if Thread.current[Drainer::THREAD_KEY]
585
+
557
586
  install_mutex.synchronize do
558
587
  next if @drainer&.running?
559
588
 
@@ -585,11 +614,16 @@ module Wurk
585
614
  buffer_mutex.synchronize { buffer.map { |entry| entry.origin.resolve } }.uniq(&:object_id)
586
615
  end
587
616
 
588
- # Replays `entries` slice by slice and returns how many reached Redis.
589
- # On the first slice that does not fully land, what did not land and
590
- # every later slice go back at the absolute head of the buffer, in
591
- # order: same-origin order is all that matters (other entries go to
592
- # another server).
617
+ # Replays `entries` slice by slice and returns [how many reached Redis,
618
+ # whether the replay stalled]. On the first slice that does not fully
619
+ # land, what did not land and every later slice go back at the absolute
620
+ # head of the buffer, in order: same-origin order is all that matters
621
+ # (other entries go to another server).
622
+ #
623
+ # A slice that Redis refused over one entry's own data (a WRONGTYPE on
624
+ # its queue key) is replayed entry by entry instead, so the refused one
625
+ # is set aside and the rest land: left in the buffer, it would refuse
626
+ # again on every replay and hold every push to this Redis hostage.
593
627
  #
594
628
  # A slice is a run of immediate or of scheduled payloads, because
595
629
  # Client#atomic_push routes a whole call by its first payload.
@@ -598,17 +632,79 @@ module Wurk
598
632
  remaining = entries
599
633
  replay_slices(entries).each do |slice|
600
634
  remaining = remaining.drop(slice.size)
601
- undelivered, error = replay(client, slice)
602
- landed += slice.size - undelivered.size
635
+ undelivered, error, count = replay_slice(client, slice)
636
+ landed += count
603
637
  next if undelivered.empty? && error.nil?
604
638
 
605
- return give_back(client, undelivered + remaining, error, landed)
639
+ return [give_back(client, undelivered + remaining, error, landed), true]
606
640
  end
607
- landed
641
+ [landed, false]
608
642
  ensure
609
643
  replay_settled(entries.size)
610
644
  end
611
645
 
646
+ # An error the payloads in the push caused rather than the server's
647
+ # state: a refusal of its data, or one that could not be serialized.
648
+ def entry_error?(error)
649
+ case error
650
+ when RedisClient::CommandError then ENTRY_ERROR_CODES.include?(error_code(error))
651
+ when JSON::JSONError, EncodingError then true
652
+ else false
653
+ end
654
+ end
655
+
656
+ # `code` is unset on an error built from a bare message; Redis puts the
657
+ # code first there too.
658
+ def error_code(error)
659
+ (error.code || error.message.split(' ', 2).first).to_s
660
+ end
661
+
662
+ # [entries that did not land, the error to stop on or nil, how many
663
+ # landed].
664
+ def replay_slice(client, slice)
665
+ undelivered, error = replay(client, slice)
666
+ return [undelivered, error, slice.size - undelivered.size] unless entry_error?(error)
667
+
668
+ report_entry_error(error, nil) if undelivered.empty?
669
+ rest, error, dropped = replay_each(client, undelivered)
670
+ [rest, error, slice.size - rest.size - dropped]
671
+ end
672
+
673
+ # One entry per raw_push, after a slice failed on an entry error.
674
+ # Returns [entries still to go back, the error that stopped it or nil,
675
+ # how many were dropped]. An entry refused on its own data is reported
676
+ # and dropped; a connection or server-state failure stops here as the
677
+ # slice would have. An entry that landed while a later command of its
678
+ # push failed (its status row) is reported but counts as landed.
679
+ def replay_each(client, entries)
680
+ dropped = 0
681
+ entries.each_with_index do |entry, index|
682
+ undelivered, error = replay(client, [entry])
683
+ next if error.nil? && undelivered.empty?
684
+ return [entries.drop(index + 1 - undelivered.size), error, dropped] unless entry_error?(error)
685
+
686
+ report_entry_error(error, undelivered.first&.payload)
687
+ dropped += undelivered.size
688
+ end
689
+ [[], nil, dropped]
690
+ end
691
+
692
+ # Through the error handlers, so it reaches whatever an app watches; a
693
+ # dropped job also gets its own ERROR line, since it will never run.
694
+ def report_entry_error(error, dropped_payload)
695
+ config = Wurk.configuration
696
+ context = { context: 'reliable_push replay' }
697
+ if dropped_payload
698
+ jid = dropped_payload['jid']
699
+ context.merge!(jid: jid, class: dropped_payload['class'], queue: dropped_payload['queue'])
700
+ config.logger.error do
701
+ "reliable_push: Redis refused buffered #{dropped_payload['class']} jid=#{jid} " \
702
+ "(#{error.class}: #{error.message}); dropping it, it will never run"
703
+ end
704
+ end
705
+ config.handle_exception(error, context)
706
+ end
707
+
612
708
  def replay_slices(entries)
613
709
  entries.chunk_while { |a, b| a.payload.key?('at') == b.payload.key?('at') }
614
710
  .flat_map { |run| run.each_slice(REPLAY_SLICE).to_a }
@@ -756,6 +852,8 @@ module Wurk
756
852
  class Drainer
757
853
  DEFAULT_INTERVAL = 2.0
758
854
  STOP_JOIN_TIMEOUT = 5.0
855
+ # Marks a drainer's own thread; see Buffered.ensure_drainer.
856
+ THREAD_KEY = :wurk_reliable_push_drainer
759
857
  # While a circuit is open, pushes are only in memory, so finding out that
760
858
  # Redis is back quickly matters more than the interval an idle drainer keeps.
761
859
  PROBE_PAUSE = 0.25
@@ -783,6 +881,7 @@ module Wurk
783
881
  @done = false
784
882
  @thread = Thread.new do
785
883
  Thread.current.name = 'wurk-reliable_push-drainer'
884
+ Thread.current[THREAD_KEY] = true
786
885
  run
787
886
  end
788
887
  end
@@ -885,19 +984,19 @@ module Wurk
885
984
  # of the set and still counts.
886
985
  def buffer_undelivered(payloads)
887
986
  Buffered.trip!(pool)
888
- bidless, batched = undelivered(payloads).partition { |p| !p['bid'] }
889
- enbuffer_bidless(bidless, batched)
890
- raise unless batched.empty?
987
+ bufferable, held = undelivered(payloads).partition { |p| Buffered.bufferable?(p) }
988
+ enbuffer_bufferable(bufferable, held)
989
+ raise unless held.empty?
891
990
 
892
- bidless
991
+ bufferable
893
992
  end
894
993
 
895
- # Batched payloads never buffer, so they still take the real attempt and
896
- # report its outcome to the caller.
994
+ # Batched payloads and batch callbacks never buffer, so they still take
995
+ # the real attempt and report its outcome to the caller.
897
996
  def circuit_open_for?(payloads)
898
997
  return false if Thread.current[Buffered::DRAINING_KEY] || Buffered.unbuffered?
899
998
 
900
- Buffered.circuit.open?(pool) && payloads.none? { |p| p['bid'] }
999
+ Buffered.circuit.open?(pool) && payloads.all? { |p| Buffered.bufferable?(p) }
901
1000
  end
902
1001
 
903
1002
  def buffer_without_trying(payloads)
@@ -919,16 +1018,16 @@ module Wurk
919
1018
 
920
1019
  # Bare `raise` re-raises whatever `$!` holds: the connection error from
921
1020
  # the caller's rescue, or the Overflow once we're inside this one.
922
- def enbuffer_bidless(bidless, batched)
923
- Buffered.enbuffer(bidless, client: self) if bidless.any?
1021
+ def enbuffer_bufferable(bufferable, held)
1022
+ Buffered.enbuffer(bufferable, client: self) if bufferable.any?
924
1023
  rescue Buffered::Overflow => e
925
1024
  # An overflow pre-empts the caller's connection-error re-raise, which
926
- # would strand the batched payloads silently — they never buffer. One
1025
+ # would strand the held payloads silently — they never buffer. One
927
1026
  # exception, every payload that failed to get through; `cause` stays
928
1027
  # the connection error rather than the folded-in Overflow.
929
- raise if batched.empty?
1028
+ raise if held.empty?
930
1029
 
931
- raise Buffered::Overflow, e.payloads + batched, cause: e.cause
1030
+ raise Buffered::Overflow, e.payloads + held, cause: e.cause
932
1031
  end
933
1032
  end
934
1033
 
data/lib/wurk/client.rb CHANGED
@@ -498,6 +498,26 @@ module Wurk
498
498
  track_enqueued(pipe, jobs, now)
499
499
  end
500
500
  mark_delivered(jobs)
501
+ rescue RedisClient::CommandError => e
502
+ mark_delivered(jobs) if lpush_applied?(e)
503
+ raise
504
+ end
505
+
506
+ # A pipeline raises its first error reply only after reading every reply,
507
+ # so a refused SADD or status row can sit next to an LPUSH that landed. The
508
+ # jobs are in Redis then, and must stay out of a reliable_push replay. The
509
+ # errors chain through `next_error` (redis-client >= 0.23); without it a
510
+ # refused SADD hides LPUSH's outcome, so that case counts as not landed, as
511
+ # does an error that names no command at all.
512
+ def lpush_applied?(error)
513
+ chained = error.respond_to?(:next_error)
514
+ until error.nil?
515
+ verb = Array(error.command).first.to_s.upcase
516
+ return false if verb.empty? || verb == 'LPUSH' || (verb == 'SADD' && !chained)
517
+
518
+ error = chained ? error.next_error : nil
519
+ end
520
+ true
501
521
  end
502
522
 
503
523
  # Ride the pipeline that is already open for the queue write, so a tracked
@@ -217,7 +217,7 @@ module Wurk
217
217
 
218
218
  # @param val [Integer] threads per worker process
219
219
  def concurrency=(val)
220
- default_capsule.concurrency = val
220
+ default_capsule.concurrency = Integer(val)
221
221
  end
222
222
 
223
223
  def queues = default_capsule.queues
@@ -813,7 +813,14 @@ module Wurk
813
813
  @logger ||= default_logger
814
814
  end
815
815
 
816
- attr_writer :logger
816
+ # nil silences the current logger instead of replacing it, as upstream does.
817
+ def logger=(logger)
818
+ if logger.nil?
819
+ self.logger.level = ::Logger::FATAL
820
+ else
821
+ @logger = logger
822
+ end
823
+ end
817
824
 
818
825
  def handle_exception(ex, ctx = {})
819
826
  ctx = redact_jobstr(ctx)
data/lib/wurk/cron.rb CHANGED
@@ -45,6 +45,7 @@ module Wurk
45
45
  HISTORY_CAP = 25
46
46
  DEFAULT_TICK_SECONDS = 60
47
47
  MISSED_TICK_THRESHOLD = 90
48
+ SKIPPED_COUNT_CAP = 1_000
48
49
 
49
50
  # Handed to the error handlers when a due loop names a class this process
50
51
  # cannot load, so the occurrence was skipped.
@@ -422,6 +423,22 @@ module Wurk
422
423
  next_fire_at(nxt) # fixed daily slot: drop the fold duplicate
423
424
  end
424
425
 
426
+ # For the poller's missed-tick line: the occurrences from `expected` (one
427
+ # itself) through `now`, less `firing`, the one the late tick still runs.
428
+ # Counted by walking the schedule, so a long outage stops at the cap and
429
+ # reads `1000+`.
430
+ def skipped_fires(expected, now, firing)
431
+ count = 0
432
+ occurrence = expected
433
+ while occurrence && occurrence <= now
434
+ return "#{SKIPPED_COUNT_CAP}+" if count == SKIPPED_COUNT_CAP
435
+
436
+ count += 1 unless occurrence == firing
437
+ occurrence = next_fire_at(occurrence)
438
+ end
439
+ count
440
+ end
441
+
425
442
  def local_components(epoch)
426
443
  parser.local_components(epoch, @tz)
427
444
  end
@@ -794,7 +811,7 @@ module Wurk
794
811
  future = loop_obj.next_fire_after(firing || slot, now)
795
812
  return unless claim_fire?(loop_obj, mark, now, future)
796
813
 
797
- skip_missed(loop_obj, slot, now) unless firing == slot
814
+ skip_missed(loop_obj, slot, now, firing) unless firing == slot
798
815
  return if firing.nil?
799
816
 
800
817
  fire_claimed(loop_obj, now)
@@ -896,10 +913,13 @@ module Wurk
896
913
  [@config[:cron_grace] || MISSED_TICK_THRESHOLD, @tick_interval * 1.5].max
897
914
  end
898
915
 
899
- def skip_missed(loop_obj, expected, now)
916
+ # One line however many occurrences the marks just advanced past, so it
917
+ # carries the count: an every-minute loop three minutes late drops three.
918
+ def skip_missed(loop_obj, expected, now, firing = nil)
900
919
  logger.warn(
901
920
  "[cron] missed tick lid=#{loop_obj.lid} klass=#{loop_obj.klass} " \
902
- "expected_at=#{expected} now=#{now} drift=#{now - expected}s — skipped, not backfilled"
921
+ "expected_at=#{expected} now=#{now} drift=#{now - expected}s " \
922
+ "skipped=#{loop_obj.skipped_fires(expected, now, firing)} — skipped, not backfilled"
903
923
  )
904
924
  nil
905
925
  end
@@ -1042,10 +1062,15 @@ module Wurk
1042
1062
  # the lid is still derived from (schedule, klass, opts) so the
1043
1063
  # call is idempotent. Callers that want the Sidekiq DSL should use
1044
1064
  # `Manager#register` via `config.periodic { |mgr| ... }`.
1065
+ #
1066
+ # `tz:` stays in the options as well as reaching the loop: it has always
1067
+ # been part of what this method hashes into the lid, and a lid that moved
1068
+ # would leave the old loop firing next to the new one.
1045
1069
  def register(name, cron, worker_class, args = [], **opts)
1046
1070
  merged = opts.merge(args: args)
1047
1071
  merged[:label] = name if name
1048
- Loop.new(schedule: cron, klass: worker_class.to_s, options: merged).tap { |lp| persist(lp) }
1072
+ loop_obj = Loop.new(schedule: cron, klass: worker_class.to_s, options: merged, tz: opts[:tz])
1073
+ persist(loop_obj)
1049
1074
  end
1050
1075
 
1051
1076
  # `paused` is written with HSETNX, not HSET: a code-declared `paused:`
@@ -1060,6 +1085,12 @@ module Wurk
1060
1085
  # #persist for many loops in one pipelined round trip: a booting process
1061
1086
  # (each swarm child) writes its whole `config.periodic` block at once.
1062
1087
  # Nothing here reads, so a pipeline is the same writes in the same order.
1088
+ #
1089
+ # The lid does not hash a Manager loop's zone, so an edited `tz:` lands on
1090
+ # the same hash and its stored `nf` still names the next occurrence in the
1091
+ # old zone: that one fire happens on the old zone's clock, and every one
1092
+ # after it on the new. Recomputing it here would cost every booting
1093
+ # process a read of every loop (bench/algo cron budget).
1063
1094
  def persist_all(loops)
1064
1095
  return loops if loops.empty?
1065
1096
 
@@ -145,12 +145,19 @@ module Wurk
145
145
  # time. A raise leaves the outcome unknown, and both outcomes are safe:
146
146
  # moved, or still in the private list, where Fetcher::SelfReconcile finds
147
147
  # it.
148
+ #
149
+ # The job goes back unrun, so its global-concurrency slot goes back with
150
+ # it: a caller outside the Processor (a throttling fetch wrapper) has no
151
+ # ensure to release it, and the heartbeat would refresh the orphaned
152
+ # hold for the life of the process. A second release from the
153
+ # Processor's own ensure frees nothing.
148
154
  def requeue
149
155
  config.redis do |conn|
150
156
  next conn.call_once('RPUSH', queue, job) unless private_queue
151
157
 
152
158
  Wurk::Lua::Loader.eval_once(conn, :requeue_unit, keys: [private_queue, queue], argv: [job])
153
159
  end
160
+ release_slot
154
161
  end
155
162
 
156
163
  # The Processor has settled this unit, one way or the other: stop
data/lib/wurk/health.rb CHANGED
@@ -158,8 +158,11 @@ module Wurk
158
158
  # nothing rebound until the pod restarted. Now a survivor takes the port
159
159
  # over within RETRY_INTERVAL of the owner's exit, so liveness/readiness
160
160
  # ride out ordinary child churn (crash-respawn, rolling restart, recycle).
161
+ # In a swarm one child owning the shared port is the normal case, so that
162
+ # logs at INFO; WARN is kept for a lone process, where the holder is
163
+ # something else.
161
164
  def start_retry_loop
162
- logger&.warn do
165
+ logger&.public_send(Health.fleet_size.to_i > 1 ? :info : :warn) do
163
166
  "Wurk::Health: port #{@port} in use; polling every #{@retry_interval}s to take it over"
164
167
  end
165
168
  @retry_thread = ::Thread.new do
@@ -7,7 +7,8 @@ require_relative 'iterable_job/active_record_enumerator'
7
7
 
8
8
  module Wurk
9
9
  # Iterable jobs split long-running work into small, idempotent chunks.
10
- # Override `#build_enumerator` (yielding `[item, new_cursor]` pairs) and
10
+ # Override `#build_enumerator` (yielding `[item, cursor]` pairs, the cursor
11
+ # being where a resume starts in order to run that item) and
11
12
  # `#each_iteration(item, *args)`; the framework drives the loop, persists
12
13
  # the cursor, and resumes after interruption.
13
14
  #
@@ -61,8 +62,9 @@ module Wurk
61
62
  base.singleton_class.prepend(MethodAddedGuard)
62
63
  end
63
64
 
64
- # User overrides — must return an Enumerator yielding `[item, new_cursor]`
65
- # pairs. The cursor must round-trip through JSON.
65
+ # User overrides — must return an Enumerator yielding `[item, cursor]`
66
+ # pairs, `cursor` being the value that makes a rebuilt enumerator start at
67
+ # `item`. The cursor must round-trip through JSON.
66
68
  def build_enumerator(*, cursor:)
67
69
  _ = cursor
68
70
  raise NotImplementedError, "#{self.class} must override #build_enumerator"
@@ -204,26 +206,50 @@ module Wurk
204
206
  end
205
207
  end
206
208
 
209
+ # The cursor an enumerator yields with an item is that item's own position,
210
+ # where a resume has to start to run it: `array_enumerator` yields the
211
+ # index and drops that many on resume. So it is recorded before the item
212
+ # runs, as Sidekiq does (job/iterable.rb `@_cursor = cursor`). An interrupt
213
+ # noticed between items then resumes at the first item not yet run, and an
214
+ # item that raises is the one the retry starts with. Recording it after the
215
+ # item instead re-ran the last completed item on every resume.
207
216
  def run_iterations(args)
208
217
  enum = build_enumerator(*args, cursor: @cursor)
209
- enum.each do |item, new_cursor|
218
+ enum.each do |item, item_cursor|
210
219
  return :cancelled if cancelled?
211
220
 
221
+ @cursor = item_cursor
222
+ @current_object = item
212
223
  # Cooperative shutdown. `interrupted?` (Wurk::Worker) is true once the
213
224
  # owning Processor is stopping — quiet, TERM, or a rolling restart.
214
225
  # Without this the loop would run until hard_shutdown raises
215
- # Wurk::Shutdown (an Interrupt, not a RuntimeError), which skips the
216
- # rescue below and loses everything since the last periodic flush.
226
+ # Wurk::Shutdown, with nothing saved since the last periodic flush.
217
227
  raise Interrupted if interrupted?
218
228
 
219
- @current_object = item
220
- around_iteration { each_iteration(item, *args) }
221
- @cursor = new_cursor
222
229
  maybe_flush_state
230
+ run_iteration(item, args)
223
231
  end
224
232
  :completed
225
233
  end
226
234
 
235
+ # Any exit from an iteration saves the cursor of the item in flight, so the
236
+ # retry (or the resume after a hard shutdown, hence Exception) starts there
237
+ # rather than at the last periodic flush. A save that fails too must not
238
+ # replace the job's own error: a Wurk::Shutdown turned into a Redis error
239
+ # would be booked as a retry.
240
+ def run_iteration(item, args)
241
+ around_iteration { each_iteration(item, *args) }
242
+ rescue Interrupted
243
+ raise
244
+ rescue Exception => e # rubocop:disable Lint/RescueException
245
+ begin
246
+ flush_state
247
+ rescue StandardError => flush_error
248
+ Wurk.configuration.handle_exception(flush_error, { context: 'iterable job state save', jid: jid })
249
+ end
250
+ raise e
251
+ end
252
+
227
253
  def finalize_complete
228
254
  flush_state(final: true)
229
255
  on_complete
@@ -38,6 +38,14 @@ module Wurk
38
38
  # short-circuits processing (e.g. interrupt-handler re-pushed the job).
39
39
  class Skip < Handled; end
40
40
 
41
+ # Raised by Processor when Redis stopped answering after `perform` had
42
+ # returned: the job did its work and only the bookkeeping behind it (a
43
+ # batch ack, a status row) failed. Counted as a failure it would be retried
44
+ # with a stale count or, on a last attempt, killed, and a batch would mark
45
+ # itself dead over a job that succeeded. Both guards let it through to the
46
+ # Processor, which puts the job back to run again. `cause` is the Redis error.
47
+ class StoreUnavailableAfterPerform < ::StandardError; end
48
+
41
49
  def initialize(capsule)
42
50
  @capsule = capsule
43
51
  @config = capsule
@@ -50,7 +58,7 @@ module Wurk
50
58
  # bubbles up so the swarm can drain.
51
59
  def global(jobstr, queue)
52
60
  yield
53
- rescue Handled, Wurk::Shutdown
61
+ rescue Handled, Wurk::Shutdown, StoreUnavailableAfterPerform
54
62
  raise
55
63
  rescue Exception => e # rubocop:disable Lint/RescueException
56
64
  raise Wurk::Shutdown if exception_caused_by_shutdown?(e)
@@ -71,7 +79,7 @@ module Wurk
71
79
  # circuit `global`'s rescue.
72
80
  def local(jobinst, jobstr, queue)
73
81
  yield
74
- rescue Handled, Wurk::Shutdown
82
+ rescue Handled, Wurk::Shutdown, StoreUnavailableAfterPerform
75
83
  raise
76
84
  rescue Exception => e # rubocop:disable Lint/RescueException
77
85
  raise Wurk::Shutdown if exception_caused_by_shutdown?(e)
data/lib/wurk/job_set.rb CHANGED
@@ -331,9 +331,13 @@ module Wurk
331
331
  # Returns the entries retried.
332
332
  def retry_page(entries)
333
333
  client = Client.new
334
- unwritten = take(entries).to_h { |entry| [entry, true] }.compare_by_identity
334
+ unwritten = remove_page(entries).to_h { |entry| [entry, true] }.compare_by_identity
335
335
  groups, halted = prepare_retries(client, unwritten)
336
- groups.each_value.sum(halted) { |pairs| write_group(client, pairs, unwritten) }
336
+ # Unbuffered for the reason SortedEntry#push_to_redis is: the page is
337
+ # already out of the set, so memory must not count as delivered.
338
+ Client::Buffered.unbuffered do
339
+ groups.each_value.sum(halted) { |pairs| write_group(client, pairs, unwritten) }
340
+ end
337
341
  ensure
338
342
  unwritten&.each_key(&:restore_after_failed_push)
339
343
  end
@@ -377,8 +381,9 @@ module Wurk
377
381
  # The pipeline has already removed the rest of the page when a fallback
378
382
  # runs, so a fallback that raises puts back everything removed so far, the
379
383
  # pipeline's hits and every earlier fallback, before it propagates:
380
- # #retry_page's restore only covers what #take returned.
381
- def take(entries)
384
+ # #retry_page's restore only covers what this returned. Not named `take`:
385
+ # that is Enumerable's, which upstream's sets answer (`RetrySet.new.take(5)`).
386
+ def remove_page(entries)
382
387
  taken, misses = split_by_zrem(entries)
383
388
  misses.each { |entry| taken << entry if delete_by_jid(entry.score, entry.jid) }
384
389
  taken
data/lib/wurk/logger.rb CHANGED
@@ -84,6 +84,13 @@ module Wurk
84
84
  end
85
85
  end
86
86
 
87
+ # Pretty without the ANSI colour codes (Sidekiq 8.0.8+).
88
+ class Plain < Base
89
+ def call(severity, time, _program_name, message)
90
+ "#{severity} #{time.utc.iso8601(3)} #{pid_tag} tid=#{tid}#{format_context}: #{message}\n"
91
+ end
92
+ end
93
+
87
94
  class WithoutTimestamp < Pretty
88
95
  def call(severity, _time, _program_name, message)
89
96
  "#{SEVERITY_COLORS[severity]} #{pid_tag} tid=#{tid}#{format_context}: #{message}\n"
@@ -9,7 +9,9 @@ local key = KEYS[1]
9
9
  local delta = tonumber(ARGV[1])
10
10
  local cap = tonumber(ARGV[2])
11
11
  local ttl = tonumber(ARGV[3])
12
- local current = tonumber(redis.call('HGET', key, 'points') or '0')
12
+ -- A missing key is a full bucket, as limiter_points_acquire.lua reads it: the
13
+ -- state was reset, or expired, while the caller's block was still running.
14
+ local current = tonumber(redis.call('HGET', key, 'points') or cap)
13
15
  local new_val = current + delta
14
16
  if new_val < 0 then new_val = 0 end
15
17
  if new_val > cap then new_val = cap end