From 01f2b795c04e59a8f709aff50c6503e1085559d4 Mon Sep 17 00:00:00 2001 From: Abel Lucas Date: Thu, 16 Jan 2025 16:57:53 +0100 Subject: [PATCH] backend: use v2 tables through views where possible (v2 phase 3) --- ...c9b31e857d5b805dd226e3c1c17825b81b3d3.json | 22 + ...8527f2440dd512f592d2265753a684395736b.json | 30 + ...5858c315bd3489366334f624e8a857e7a2520.json | 15 + ...52417a36c01702e9b56169919ef74ee8c3445.json | 23 + ...16d38ef746ef0d004dd939cc76010a80476c8.json | 17 + ...e310d1c4399fcbda69b93dd7bf15a93ce39ff.json | 35 + ...65df69f64f2023c102d0b55ced6d94d06b9f8.json | 23 + ...4ba8b1715d75012aa5ca7a834d627bd674ac2.json | 29 + ...6ed2a1f91f6cc5fb0a3cd55d1bb908068bf3c.json | 22 + ...174646b6bdd658b8461db1bb90a871d076718.json | 15 + ...0c912317b0d95589ecb827aea27eb0357291b.json | 16 + ...89ee2b5e9ebfc003fec10ebbc4298da58b805.json | 42 ++ ...24583dca58ae6ee4775930e6c1fbe85fd885b.json | 40 ++ ...0757c933fd5e16d7f61d4e3df228908d67750.json | 14 + ...4d71723acc9b39c86f644f8589b14c1b026cd.json | 15 + ...c56060ef60ff1a9e77cd2315940ca0a49253d.json | 14 + ...017a4b0501ea94ac284e9245c566d3d097925.json | 22 + ...37136fd123f80389abe6ebbcf12084da45868.json | 14 + ...9219817e66ec2aee939853af8df64048e813d.json | 17 + ...f25c2e0a96eb3a94a092f07afffa7e5ad9c70.json | 22 + ...b176073160cb4e6e27435520c23dd4974345a.json | 16 + ...6f7f9288dc6b349c2c46945e36fdd46401c6c.json | 29 + ...844552e5dd432f35e247241f660cb3c2f8c96.json | 34 + ...0f9d3de633cdc4f9e23c6d9bd27eba07b0cb2.json | 22 + ...7a43e15f0be227265f579eccc6e525939a648.json | 58 ++ ...794065e6e6bf70415d331ccea6038271a7fec.json | 24 + ...44c43b408f3f86da47141c973af1b9f549c0a.json | 16 + ...6f1d178813a682dfef6c21983077eb0848fdb.json | 15 + ...11081779292a92d283bc23e8268f46542b5d2.json | 22 + ...adf8d6d19cc6cf612c20f3fb27071bfce071a.json | 24 + ...c6d2a3fdc1f3cd8a13ffdef536cf8b6475634.json | 24 + ...a7dc0c2a8676b586d36e9f949b2a056dcf1e2.json | 14 + ...01e00776aa50f32e5cbd073d9aa1dcca944b2.json | 24 + ...e356286035fb1aeed6268cbcab16251bfde98.json | 14 + ...80561c90ee1ba82f10cc966882ecf7ec106cf.json | 17 + ...291b3294a6a7d1549d752f14acf5972552ba5.json | 15 + ...a468340f337869125f20d7078af1851209b2c.json | 25 + ...7189a35c4691769981a5f8218cc708bd038e3.json | 15 + ...b309800382d5173e36c5aa6cc430d46a90324.json | 23 + ...da69c278171633f8b05c29e9e91c82bf3c1c4.json | 28 + ...35f1c8eb1d742a423d78ea9351ea301cfa84a.json | 73 ++ ...5fb0adb7f383282897651500159fae4f6860a.json | 29 + ...a76b70a01ac2346d954daa5de2232fe234ce7.json | 15 + ...86d181e2c8f2bec2fbeb1cc296c1e7251264e.json | 15 + ...e45600f695149652362400db1f16724c04c6f.json | 20 + ...23decca8d6ba819fd076dcbd17001b9c5af8a.json | 26 + ...ec25a2d548cf832193f6c6ac922c1979ea7d1.json | 15 + ...c228d95574775a0824b29287e836f51433dc8.json | 16 + ...1db0d4077a186fab0a00f609bd16129f016f2.json | 30 + ...c4393d83e674e16d280c1281e6cba857ea65e.json | 16 + ...d827b38b9f55333a86cb45bbd4c6fe51af023.json | 16 + ...fe694c3b1aa2769a131d805600e764c458cdc.json | 14 + ...e75534db7e1f3e34d86de83c6a3f17cde492b.json | 23 + ...185ceecf81aaa9a2e4e53d926b70b1cde2771.json | 17 + ...204f9df256e03a588c23b33b4edab0d9c3e1a.json | 21 + ...954c76fc4bfcd0e7a465cab6ef1386f67b61c.json | 38 ++ ...df162960b9e35fe53f961d36f137453f854f0.json | 23 + ...4f4f46fec5640b63a13f9ffaad56d40a47812.json | 22 + ...06d62775fe3f8b68e054db73d1eaadaa53bfd.json | 23 + ...026d4d4e0d381b31fe02da7d2667c0cdc1a85.json | 15 + ...eeb25152c67b2a82c45ee4f64019076b1a167.json | 14 + ...45182e27141db8c7e2186d80c9948b302d531.json | 29 + ...c0991974385350bdc1d9cd11c211269242e70.json | 15 + ...c48a94ed020fb9398ed242610a190f809e12f.json | 41 ++ ...5af4f372c07263c6f86bc89b0d25cb573fa80.json | 14 + ...4daa3ef2610a53a8819d49d356431969975f3.json | 15 + ...cdde234625202448cc9a2131118975c4e3f31.json | 67 ++ ...075e03d2f64d826a3817fc74197eb960e35c9.json | 30 + ...d09e76b97ac5c96f604bdc1dfeb433ac5cffb.json | 15 + ...ae8790ce4982a3d619fc50c4a0a2ee368c2e7.json | 42 ++ ...a387ab71bc0c9d9ad0c3e7737138adb6cc224.json | 17 + ...1ea1747ffe28986055c01a4661628e47c0e51.json | 16 + ...bd3ec590384ed64dd738302df10a6a783c75f.json | 15 + ...c532d4e08d5416b0566c34be201e98deab75c.json | 23 + ...a062bcfe0d319a330969e4a97fb0a714be923.json | 15 + ...574fc2cbcb32fef9f44632a8bc4c5c487fc4f.json | 24 + ...572d971d5892b7dd4c8e824b953113bd6c4a9.json | 23 + ...42119537374a815c1292fac4c5b75bdd58898.json | 16 + ...1c63c345d443ce636114e30ad6a0da464aa50.json | 25 + ...3f82368534b77d3720200cb90829b03b55595.json | 70 ++ ...42788dd8a777d643d46d5086b5f8f33bbc97e.json | 12 + ...9181ff9fd37e4f716de4b52e5a5960b8e6d30.json | 25 + ...d76eab45b172da907b40fc87c6300944a0108.json | 14 + ...b92bb5bba659766d44ad769a9f36ad905627a.json | 23 + ...f1adb0555ab8caf7240fa97c1d4da55e6cc95.json | 22 + ...69b6d7287ca0b19cc2b400511434e7f57be07.json | 15 + ...bad5ff2221cde22000da636e7e33e7db6ddce.json | 14 + ...eec9c80e7fb29102a046792673c42f463c076.json | 16 + ...eaa210c01d980065864e5439ee726cf1f9bef.json | 75 +++ ...e754a0d64bc934a2b6434b9cb67f28d3ef950.json | 16 + ...e86cde5ffefb4578d6e091855bc7a4e94d1b0.json | 47 ++ ...366471a2945c4470712f512b5f82b12312109.json | 91 +++ ...c0dd85ca930a5a725e8c6a0682b2dcc7f8a0e.json | 16 + ...0178c73c6102f22971e6ce67b1b4473bc8c6f.json | 71 ++ ...b2d2deae208d7e95dd7d39884b7058a0512ff.json | 15 + ...0569807fb3690b008028c9a78b0ed56928a37.json | 23 + ...7b8d9ae95c194b201bd1ce1d8f90925d7dba8.json | 16 + ...09b889a584d03f12b8189c3e817b06ee4b459.json | 14 + ...f1bfbe4e2db85da9a478a07460733999e9beb.json | 20 + ...4c14ff1c98d08d22185e7db9fb042c2d95f97.json | 54 ++ ...cc151604feae83d4671dfb9ca77eb8fd8d4f1.json | 14 + ...947b1d235325f4e6f6cb32e51f9c97a0c6285.json | 25 + ...89c90f5fcf2905da0356fd015d9e9e9de6004.json | 23 + ...74aba094562f2c353f1cefe3af8c0d04d4687.json | 22 + ...3a72efddae2bda30fe27d3359ce848d6ffc98.json | 38 ++ ...c4cc6a3648992b590c6e0121e4d7434da516b.json | 16 + ...538590334508a4f6cdbbf759ee1e3a099bda4.json | 24 + ...d4eaa2ed964088f4f35a1f74f912867819bc8.json | 15 + ...fcc072a09c9d7624978b866a2e6c09b6f7422.json | 23 + ...d26c89cb78e4c877fd161073beadfa9c9251e.json | 16 + ...212a5bd4039b57fab20b163617e33a4c9dd46.json | 14 + ...275a7027a5936539d766ecffeed13eb0e2fc3.json | 23 + ...074b76e008f0acdd13720c84e987e8f7fc710.json | 24 + ...c528b709e47f628266a020a1e04db2facd6d7.json | 22 + ...01cd68b7bad0e5604d016ddc3e293ef5fd70e.json | 30 + ...d0b6ceae9de456d3ddb6008707589dbe30747.json | 22 + ...7ea70e3bff866a6f566c768408b5f527bef27.json | 22 + ...5057e2e03053a71440559d0806d4aca258797.json | 15 + ...f2242b439788840fee36cf03da7c8c0d888f5.json | 29 + ...69e14867957dfc518746f867dee1d5d06cb5a.json | 15 + ...3933aacc1572370059815f5abf69c7aba420f.json | 16 + ...1f477193992a3b1a417318c1747f955a85f3c.json | 22 + ...355ddee00bf30f9e4acd000fc820b6a63d682.json | 22 + ...58b795433b77f67560f4e53cf36e57439018c.json | 22 + ...39ab0ed411e9059a1541645c8014c466d77c2.json | 40 ++ ...aeca87ed9764bfa683b9d49294c24495ad392.json | 22 + ...be723ad0a17ad313844f75f6edbbddb5d6ef3.json | 29 + ...a261b6575faecd147926e0a742b8c893de1a3.json | 28 + ...31cd1299f0fb5a21613cb2069a9b4421a8069.json | 14 + ...35add06812722430f80bc5ddcf4a21dca9ca3.json | 25 + ...240a56ef7687335930d1587f934dd68d4ee81.json | 24 + ...863aba209ffe7160c7b5790aed987f1441104.json | 69 ++ ...ceb16d0174118fdc99132bcf7d9461ff998f8.json | 22 + ...6b6b5c227d100819c6d6231ffd606d1d2986e.json | 24 + ...ec4dd12900340d7ffcc076a4f969e0b73c4a8.json | 40 ++ ...635301be35d5d1813273bef13524f8fbec6b7.json | 24 + ...36f4441b038e9992eebd64fda43a3f5dd8b10.json | 48 ++ ...01f39cd4c22ee155d11f173f16ff23af2ffda.json | 198 ++++++ ...5590d5dea8c67f6ae7b14743ac4f265dd89a3.json | 14 + ...d8bfdf7f5cd9ad3865416e7aa0a09fd135a99.json | 15 + ...c0dfcb7feab3426b1365e6be960530973e3ef.json | 17 + ...283b63e99b0c7e1cdddac029e218bc31c5dcd.json | 22 + ...b3e78a9129aaacf24c84c6ecee7819845b3dc.json | 23 + ...9f3c5e8efd23a323194f2210ae4e98de52358.json | 29 + ...51be202adc8e6e591fca66df87d3dd7b74a2d.json | 68 ++ ...f587c9581ef407417ec979b8a3ab07816cc69.json | 16 + ...6e4490d6004ba58ae26c52a4f21f867e1df70.json | 111 ++++ ...0b1ed5e219c2392867d836bc29263cc57ff90.json | 28 + ...e2ce6dea9f667ff323f4db84e3553f0e0f49c.json | 35 + ...1c5947d2e22a10fc95401faa2d3704647830d.json | 23 + ...43010a95fb50a983a45dc72638a3ada1b83ff.json | 22 + backend/Cargo.lock | 1 + backend/ee-repo-ref.txt | 2 +- ...45630_v2_queue_compatibility_view.down.sql | 6 + ...7145630_v2_queue_compatibility_view.up.sql | 169 +++++ ..._completed_job_compatibility_view.down.sql | 6 + ...v2_completed_job_compatibility_view.up.sql | 107 +++ backend/src/monitor.rs | 18 +- backend/tests/fixtures/base.sql | 4 +- backend/tests/fixtures/result_format.sql | 6 + backend/tests/worker.rs | 51 +- backend/windmill-api/src/apps.rs | 2 +- .../windmill-api/src/concurrency_groups.rs | 8 +- backend/windmill-api/src/flows.rs | 2 +- backend/windmill-api/src/inputs.rs | 34 +- backend/windmill-api/src/job_metrics.rs | 2 +- backend/windmill-api/src/jobs.rs | 303 ++++----- backend/windmill-api/src/resources.rs | 4 +- backend/windmill-api/src/schedule.rs | 6 +- backend/windmill-api/src/slack_approvals.rs | 36 +- backend/windmill-api/src/users.rs | 91 +-- .../windmill-api/src/websocket_triggers.rs | 2 +- backend/windmill-api/src/workspaces_extra.rs | 20 +- backend/windmill-common/src/bench.rs | 213 ------ backend/windmill-common/src/cache.rs | 2 +- backend/windmill-common/src/jobs.rs | 17 +- backend/windmill-common/src/lib.rs | 2 - backend/windmill-common/src/queue.rs | 2 +- backend/windmill-common/src/worker.rs | 8 +- backend/windmill-queue/src/jobs.rs | 624 ++++++++++-------- backend/windmill-queue/src/schedule.rs | 2 +- backend/windmill-worker/Cargo.toml | 1 + backend/windmill-worker/src/bench.rs | 226 +++++++ backend/windmill-worker/src/common.rs | 4 +- backend/windmill-worker/src/handle_child.rs | 4 +- backend/windmill-worker/src/lib.rs | 3 + .../windmill-worker/src/python_executor.rs | 50 +- .../windmill-worker/src/result_processor.rs | 2 +- backend/windmill-worker/src/worker.rs | 33 +- backend/windmill-worker/src/worker_flow.rs | 160 ++--- .../windmill-worker/src/worker_lockfiles.rs | 4 +- 191 files changed, 5341 insertions(+), 938 deletions(-) create mode 100644 backend/.sqlx/query-00d1874fcbd5a7b50e730c2a1c6c9b31e857d5b805dd226e3c1c17825b81b3d3.json create mode 100644 backend/.sqlx/query-011241a9df1c5c3962844f85d898527f2440dd512f592d2265753a684395736b.json create mode 100644 backend/.sqlx/query-03e79a6b6dad733971c6b729dcf5858c315bd3489366334f624e8a857e7a2520.json create mode 100644 backend/.sqlx/query-0544992727a484837d5dd4366ae52417a36c01702e9b56169919ef74ee8c3445.json create mode 100644 backend/.sqlx/query-0616f6e1320626fc7e343b352f216d38ef746ef0d004dd939cc76010a80476c8.json create mode 100644 backend/.sqlx/query-068679795613c4fbfa77e4c96cfe310d1c4399fcbda69b93dd7bf15a93ce39ff.json create mode 100644 backend/.sqlx/query-079ee8e7d2c66ce04a47ac23a6265df69f64f2023c102d0b55ced6d94d06b9f8.json create mode 100644 backend/.sqlx/query-0db2d456de66648bc62764515f54ba8b1715d75012aa5ca7a834d627bd674ac2.json create mode 100644 backend/.sqlx/query-0dea444bfabee4cc67d100870786ed2a1f91f6cc5fb0a3cd55d1bb908068bf3c.json create mode 100644 backend/.sqlx/query-0ea5ba568ec0f62b808fe938a41174646b6bdd658b8461db1bb90a871d076718.json create mode 100644 backend/.sqlx/query-12443d540d4bbfb9f9f913d94b40c912317b0d95589ecb827aea27eb0357291b.json create mode 100644 backend/.sqlx/query-1639452901868c2ea759fe751fd89ee2b5e9ebfc003fec10ebbc4298da58b805.json create mode 100644 backend/.sqlx/query-16a8daddd13818addfb4d0a2e9c24583dca58ae6ee4775930e6c1fbe85fd885b.json create mode 100644 backend/.sqlx/query-16b46734348a373520cf04bd9730757c933fd5e16d7f61d4e3df228908d67750.json create mode 100644 backend/.sqlx/query-171edbdccc746e7c375b127738e4d71723acc9b39c86f644f8589b14c1b026cd.json create mode 100644 backend/.sqlx/query-188389a7c54ff87247b9a875752c56060ef60ff1a9e77cd2315940ca0a49253d.json create mode 100644 backend/.sqlx/query-19ffbc1d775bcef3ed787875aa6017a4b0501ea94ac284e9245c566d3d097925.json create mode 100644 backend/.sqlx/query-1a85ca0a6d0ba5ab3462907e35037136fd123f80389abe6ebbcf12084da45868.json create mode 100644 backend/.sqlx/query-1c790df0b801378743ac040c5599219817e66ec2aee939853af8df64048e813d.json create mode 100644 backend/.sqlx/query-1d45dedd57c2fafd53d3e425a9bf25c2e0a96eb3a94a092f07afffa7e5ad9c70.json create mode 100644 backend/.sqlx/query-2135a4034fb85e04d707051b134b176073160cb4e6e27435520c23dd4974345a.json create mode 100644 backend/.sqlx/query-227511aeb98cf02e49eba2acda16f7f9288dc6b349c2c46945e36fdd46401c6c.json create mode 100644 backend/.sqlx/query-231ece5db2fbf26d6fbe298b16f844552e5dd432f35e247241f660cb3c2f8c96.json create mode 100644 backend/.sqlx/query-28c40cfbe796c6fb942cc9f72e00f9d3de633cdc4f9e23c6d9bd27eba07b0cb2.json create mode 100644 backend/.sqlx/query-2c47c39cb7463ab3e15e062f2747a43e15f0be227265f579eccc6e525939a648.json create mode 100644 backend/.sqlx/query-2d6b581a9e5df008b2a0223eae6794065e6e6bf70415d331ccea6038271a7fec.json create mode 100644 backend/.sqlx/query-30606c485f46e737d2d0acc9deb44c43b408f3f86da47141c973af1b9f549c0a.json create mode 100644 backend/.sqlx/query-32662887109a0619b860551140a6f1d178813a682dfef6c21983077eb0848fdb.json create mode 100644 backend/.sqlx/query-382eb81b25154b3aff04e520e2611081779292a92d283bc23e8268f46542b5d2.json create mode 100644 backend/.sqlx/query-3843fa02ec86e57c1f13bc66e86adf8d6d19cc6cf612c20f3fb27071bfce071a.json create mode 100644 backend/.sqlx/query-3c4816f411277de2b94b65ab8d2c6d2a3fdc1f3cd8a13ffdef536cf8b6475634.json create mode 100644 backend/.sqlx/query-3c8f53194af72224d943adb5f38a7dc0c2a8676b586d36e9f949b2a056dcf1e2.json create mode 100644 backend/.sqlx/query-3d0e77e8a68fcd9ad6f1f27cb9f01e00776aa50f32e5cbd073d9aa1dcca944b2.json create mode 100644 backend/.sqlx/query-40e9002c4e2aa58722ba382e307e356286035fb1aeed6268cbcab16251bfde98.json create mode 100644 backend/.sqlx/query-41addab65f2ce7214dc7c28ed5780561c90ee1ba82f10cc966882ecf7ec106cf.json create mode 100644 backend/.sqlx/query-4244640e62fffb0f6978f8f7d78291b3294a6a7d1549d752f14acf5972552ba5.json create mode 100644 backend/.sqlx/query-45f6578656373d9838f1d28da40a468340f337869125f20d7078af1851209b2c.json create mode 100644 backend/.sqlx/query-4616976a089af7e58c312d0b5357189a35c4691769981a5f8218cc708bd038e3.json create mode 100644 backend/.sqlx/query-461bb76f9dc0a1d5f35e050d3fab309800382d5173e36c5aa6cc430d46a90324.json create mode 100644 backend/.sqlx/query-464c90d711899090eb3dc4054f5da69c278171633f8b05c29e9e91c82bf3c1c4.json create mode 100644 backend/.sqlx/query-4710cb3a00b54882619ad54d43235f1c8eb1d742a423d78ea9351ea301cfa84a.json create mode 100644 backend/.sqlx/query-490e8230628f3f966db05b728d25fb0adb7f383282897651500159fae4f6860a.json create mode 100644 backend/.sqlx/query-49592da5e205e949facc87946f3a76b70a01ac2346d954daa5de2232fe234ce7.json create mode 100644 backend/.sqlx/query-49d23dccfd132b6919f6084670886d181e2c8f2bec2fbeb1cc296c1e7251264e.json create mode 100644 backend/.sqlx/query-4cdbdd36bee7563ae7d09d20543e45600f695149652362400db1f16724c04c6f.json create mode 100644 backend/.sqlx/query-5102b5f5eedc9a5d59d67e141c523decca8d6ba819fd076dcbd17001b9c5af8a.json create mode 100644 backend/.sqlx/query-536556e00c2f7a05219adbbcf34ec25a2d548cf832193f6c6ac922c1979ea7d1.json create mode 100644 backend/.sqlx/query-58dd434aadbee8a55cf422246adc228d95574775a0824b29287e836f51433dc8.json create mode 100644 backend/.sqlx/query-596dcd11848e4196eb82f7fcf491db0d4077a186fab0a00f609bd16129f016f2.json create mode 100644 backend/.sqlx/query-5a335118fbe54a23269ef7a4ee1c4393d83e674e16d280c1281e6cba857ea65e.json create mode 100644 backend/.sqlx/query-5ac9630d8d339adb6023570875cd827b38b9f55333a86cb45bbd4c6fe51af023.json create mode 100644 backend/.sqlx/query-5acc194f4081cd81677eae9f1fbfe694c3b1aa2769a131d805600e764c458cdc.json create mode 100644 backend/.sqlx/query-5bedae1ed06d199f787158a724be75534db7e1f3e34d86de83c6a3f17cde492b.json create mode 100644 backend/.sqlx/query-5c45748ab3df322f6a5cf4b52d9185ceecf81aaa9a2e4e53d926b70b1cde2771.json create mode 100644 backend/.sqlx/query-5d0284028d0dc16fbbf353496a2204f9df256e03a588c23b33b4edab0d9c3e1a.json create mode 100644 backend/.sqlx/query-5e4d30de66cc4289013e1f2da6c954c76fc4bfcd0e7a465cab6ef1386f67b61c.json create mode 100644 backend/.sqlx/query-5fa2be2d293b8a215752642cf9ddf162960b9e35fe53f961d36f137453f854f0.json create mode 100644 backend/.sqlx/query-631beba7482e25cff1e89d00adf4f4f46fec5640b63a13f9ffaad56d40a47812.json create mode 100644 backend/.sqlx/query-67227115cc54ff3f8f8c539ea8906d62775fe3f8b68e054db73d1eaadaa53bfd.json create mode 100644 backend/.sqlx/query-6bdb3fcfe16fc40222dc7010a11026d4d4e0d381b31fe02da7d2667c0cdc1a85.json create mode 100644 backend/.sqlx/query-6cd65694d617ef381e592ef03fbeeb25152c67b2a82c45ee4f64019076b1a167.json create mode 100644 backend/.sqlx/query-6d5dceb0f6b2fe5287d0f7b158f45182e27141db8c7e2186d80c9948b302d531.json create mode 100644 backend/.sqlx/query-6f74f8befca28192ff457580922c0991974385350bdc1d9cd11c211269242e70.json create mode 100644 backend/.sqlx/query-70dc88f1af928fc2046bb216a31c48a94ed020fb9398ed242610a190f809e12f.json create mode 100644 backend/.sqlx/query-7463c1eb3f690239c9277b62d935af4f372c07263c6f86bc89b0d25cb573fa80.json create mode 100644 backend/.sqlx/query-75011df502302611691a9a332e64daa3ef2610a53a8819d49d356431969975f3.json create mode 100644 backend/.sqlx/query-768bf629de97958b8060188ae6ccdde234625202448cc9a2131118975c4e3f31.json create mode 100644 backend/.sqlx/query-786d6618eec56d41be7731f0f07075e03d2f64d826a3817fc74197eb960e35c9.json create mode 100644 backend/.sqlx/query-7907fb4b819090b16d44aefb08bd09e76b97ac5c96f604bdc1dfeb433ac5cffb.json create mode 100644 backend/.sqlx/query-7993b4f2d46b0cf56f4cb784237ae8790ce4982a3d619fc50c4a0a2ee368c2e7.json create mode 100644 backend/.sqlx/query-7a706906e461df376f5238fd1dda387ab71bc0c9d9ad0c3e7737138adb6cc224.json create mode 100644 backend/.sqlx/query-7c7234d8234fbaff4d42eb47d1e1ea1747ffe28986055c01a4661628e47c0e51.json create mode 100644 backend/.sqlx/query-7e95417c9bf5812d5c24ff3ffaebd3ec590384ed64dd738302df10a6a783c75f.json create mode 100644 backend/.sqlx/query-7f7feb429e0a7b4540469fb5e8ec532d4e08d5416b0566c34be201e98deab75c.json create mode 100644 backend/.sqlx/query-82057acdd9bce4c67598e410dbca062bcfe0d319a330969e4a97fb0a714be923.json create mode 100644 backend/.sqlx/query-8381cee8bec06f8eff847b22d25574fc2cbcb32fef9f44632a8bc4c5c487fc4f.json create mode 100644 backend/.sqlx/query-8440081df15fa7874dded86b8af572d971d5892b7dd4c8e824b953113bd6c4a9.json create mode 100644 backend/.sqlx/query-8512298656d6872a2123c2801d842119537374a815c1292fac4c5b75bdd58898.json create mode 100644 backend/.sqlx/query-867a864a81c9d649acc13c6c91b1c63c345d443ce636114e30ad6a0da464aa50.json create mode 100644 backend/.sqlx/query-86d5b121a8ae458ae3b050ecf6e3f82368534b77d3720200cb90829b03b55595.json create mode 100644 backend/.sqlx/query-86e730a3481868a8d63824904df42788dd8a777d643d46d5086b5f8f33bbc97e.json create mode 100644 backend/.sqlx/query-8995f08b2e3097b21bfc519d0b89181ff9fd37e4f716de4b52e5a5960b8e6d30.json create mode 100644 backend/.sqlx/query-8a5e36ed9dcc1712ec9b8ebc26cd76eab45b172da907b40fc87c6300944a0108.json create mode 100644 backend/.sqlx/query-8b244ce1a4ff15ed50163b9b48cb92bb5bba659766d44ad769a9f36ad905627a.json create mode 100644 backend/.sqlx/query-8b882b7bb74443972929e0805d4f1adb0555ab8caf7240fa97c1d4da55e6cc95.json create mode 100644 backend/.sqlx/query-8d0b19f20452acb51a2ddaa1aca69b6d7287ca0b19cc2b400511434e7f57be07.json create mode 100644 backend/.sqlx/query-8d368d944beb43e0e8c32e83fe2bad5ff2221cde22000da636e7e33e7db6ddce.json create mode 100644 backend/.sqlx/query-8d3ded447c42747c9018053a068eec9c80e7fb29102a046792673c42f463c076.json create mode 100644 backend/.sqlx/query-8e2a03ebe1311e98b855a57693deaa210c01d980065864e5439ee726cf1f9bef.json create mode 100644 backend/.sqlx/query-902a16d9e7ac34e7f1a0ad633bae754a0d64bc934a2b6434b9cb67f28d3ef950.json create mode 100644 backend/.sqlx/query-90d1c1ed47f1a9186cdde2f720fe86cde5ffefb4578d6e091855bc7a4e94d1b0.json create mode 100644 backend/.sqlx/query-95d12525781746a0deb60572242366471a2945c4470712f512b5f82b12312109.json create mode 100644 backend/.sqlx/query-971a9eeb3d20be893655d972d51c0dd85ca930a5a725e8c6a0682b2dcc7f8a0e.json create mode 100644 backend/.sqlx/query-979549eec044480a4d8d21a22530178c73c6102f22971e6ce67b1b4473bc8c6f.json create mode 100644 backend/.sqlx/query-992ebe3a73d0bd3b2122c08ca41b2d2deae208d7e95dd7d39884b7058a0512ff.json create mode 100644 backend/.sqlx/query-9a90bbbb2cb5e99bdfdc475fbf80569807fb3690b008028c9a78b0ed56928a37.json create mode 100644 backend/.sqlx/query-9b2c42327378963b16eec5037537b8d9ae95c194b201bd1ce1d8f90925d7dba8.json create mode 100644 backend/.sqlx/query-9e3985087c66b5bf64a48f4f77409b889a584d03f12b8189c3e817b06ee4b459.json create mode 100644 backend/.sqlx/query-a0c35cb515a842067b294343c90f1bfbe4e2db85da9a478a07460733999e9beb.json create mode 100644 backend/.sqlx/query-a1eae6af90a6ee03b86fb1b96224c14ff1c98d08d22185e7db9fb042c2d95f97.json create mode 100644 backend/.sqlx/query-a2b7d364705468bd9dfb8f10e0bcc151604feae83d4671dfb9ca77eb8fd8d4f1.json create mode 100644 backend/.sqlx/query-a3ef2d382a5584d47915296c131947b1d235325f4e6f6cb32e51f9c97a0c6285.json create mode 100644 backend/.sqlx/query-a49314e28fc285aac3a73bf4c5689c90f5fcf2905da0356fd015d9e9e9de6004.json create mode 100644 backend/.sqlx/query-a4ebd27fad738b9320d1a2b4b3674aba094562f2c353f1cefe3af8c0d04d4687.json create mode 100644 backend/.sqlx/query-a4f55c2450e5bd55aaf2bc4348c3a72efddae2bda30fe27d3359ce848d6ffc98.json create mode 100644 backend/.sqlx/query-aaacf51f3a43617b60e4253549ec4cc6a3648992b590c6e0121e4d7434da516b.json create mode 100644 backend/.sqlx/query-ab093b3bef1cd60395cc763bfdb538590334508a4f6cdbbf759ee1e3a099bda4.json create mode 100644 backend/.sqlx/query-afc40924751740054bd9a02f4fad4eaa2ed964088f4f35a1f74f912867819bc8.json create mode 100644 backend/.sqlx/query-b41c93f22d5fd5813c24b34e28dfcc072a09c9d7624978b866a2e6c09b6f7422.json create mode 100644 backend/.sqlx/query-b4900c683bffc10b9cbd035208ad26c89cb78e4c877fd161073beadfa9c9251e.json create mode 100644 backend/.sqlx/query-b4a9abcb38997587b28655b0f4a212a5bd4039b57fab20b163617e33a4c9dd46.json create mode 100644 backend/.sqlx/query-b544bb25abf9562738851c25711275a7027a5936539d766ecffeed13eb0e2fc3.json create mode 100644 backend/.sqlx/query-b86590a0f3825889b930f584eba074b76e008f0acdd13720c84e987e8f7fc710.json create mode 100644 backend/.sqlx/query-bba2f9b0ae5024c4cd3522eeb56c528b709e47f628266a020a1e04db2facd6d7.json create mode 100644 backend/.sqlx/query-bedfb7153d8fcc936263372cc0001cd68b7bad0e5604d016ddc3e293ef5fd70e.json create mode 100644 backend/.sqlx/query-c03b4c5878bd0a0c545cb66b146d0b6ceae9de456d3ddb6008707589dbe30747.json create mode 100644 backend/.sqlx/query-c2f2ae011a42a1d4d9f29d34e4c7ea70e3bff866a6f566c768408b5f527bef27.json create mode 100644 backend/.sqlx/query-c33664546c6114d04bfaeaeb5215057e2e03053a71440559d0806d4aca258797.json create mode 100644 backend/.sqlx/query-c68af2428470b30146bd9a8e119f2242b439788840fee36cf03da7c8c0d888f5.json create mode 100644 backend/.sqlx/query-cd83b6127846baf104de3be4f7a69e14867957dfc518746f867dee1d5d06cb5a.json create mode 100644 backend/.sqlx/query-cf65514f25af5a85d455be52f373933aacc1572370059815f5abf69c7aba420f.json create mode 100644 backend/.sqlx/query-d25e94bc84aa182c760259078d21f477193992a3b1a417318c1747f955a85f3c.json create mode 100644 backend/.sqlx/query-d29c07b81377d4617289e9e7bd6355ddee00bf30f9e4acd000fc820b6a63d682.json create mode 100644 backend/.sqlx/query-d357006fe927cab6cfc51b5087358b795433b77f67560f4e53cf36e57439018c.json create mode 100644 backend/.sqlx/query-d5522859ae6234eaed85d75e0f139ab0ed411e9059a1541645c8014c466d77c2.json create mode 100644 backend/.sqlx/query-d99ae453289ae967ce92a221375aeca87ed9764bfa683b9d49294c24495ad392.json create mode 100644 backend/.sqlx/query-d9f7f5e82b32d3c0fbc1757e238be723ad0a17ad313844f75f6edbbddb5d6ef3.json create mode 100644 backend/.sqlx/query-dbfbb6f56ce9bc832ac8f529cd2a261b6575faecd147926e0a742b8c893de1a3.json create mode 100644 backend/.sqlx/query-dd10cbb77c6137cd8bde7a3ab0531cd1299f0fb5a21613cb2069a9b4421a8069.json create mode 100644 backend/.sqlx/query-dd810de496870aa3f211e2d89e335add06812722430f80bc5ddcf4a21dca9ca3.json create mode 100644 backend/.sqlx/query-e0fffa04a21586fe01ea575373f240a56ef7687335930d1587f934dd68d4ee81.json create mode 100644 backend/.sqlx/query-e1339acd0338c02e6f92edddd57863aba209ffe7160c7b5790aed987f1441104.json create mode 100644 backend/.sqlx/query-e19d0f30bd84680302ff26dd037ceb16d0174118fdc99132bcf7d9461ff998f8.json create mode 100644 backend/.sqlx/query-e336b19cd0e4717fe1eb49c8ddd6b6b5c227d100819c6d6231ffd606d1d2986e.json create mode 100644 backend/.sqlx/query-e47b00656e5a3321fefef0e02cdec4dd12900340d7ffcc076a4f969e0b73c4a8.json create mode 100644 backend/.sqlx/query-e495f9817420619cdec4e54f920635301be35d5d1813273bef13524f8fbec6b7.json create mode 100644 backend/.sqlx/query-eb499eb563839de4c94d9ffb88936f4441b038e9992eebd64fda43a3f5dd8b10.json create mode 100644 backend/.sqlx/query-ecbfd613827163b2e7963a7436a01f39cd4c22ee155d11f173f16ff23af2ffda.json create mode 100644 backend/.sqlx/query-ecd62c48fe2fba2fc2582e9e7ae5590d5dea8c67f6ae7b14743ac4f265dd89a3.json create mode 100644 backend/.sqlx/query-ef20932aac9dec17eef7853aeacd8bfdf7f5cd9ad3865416e7aa0a09fd135a99.json create mode 100644 backend/.sqlx/query-ef387687bd247fccdab8b0f8086c0dfcb7feab3426b1365e6be960530973e3ef.json create mode 100644 backend/.sqlx/query-efe6d8ff451eeab03bdad90d1b2283b63e99b0c7e1cdddac029e218bc31c5dcd.json create mode 100644 backend/.sqlx/query-f03794eda2e3ad0b2d30854120cb3e78a9129aaacf24c84c6ecee7819845b3dc.json create mode 100644 backend/.sqlx/query-f1280cedcac66a0257b45c2d1ec9f3c5e8efd23a323194f2210ae4e98de52358.json create mode 100644 backend/.sqlx/query-f23941db8b1bac5964788985c3651be202adc8e6e591fca66df87d3dd7b74a2d.json create mode 100644 backend/.sqlx/query-f746c5d2ffa24dd75124b5f8d04f587c9581ef407417ec979b8a3ab07816cc69.json create mode 100644 backend/.sqlx/query-f8e0103dae8d80682a6b694762b6e4490d6004ba58ae26c52a4f21f867e1df70.json create mode 100644 backend/.sqlx/query-fb9e98f5a4da2918146cff7c04d0b1ed5e219c2392867d836bc29263cc57ff90.json create mode 100644 backend/.sqlx/query-fc8bc1bdaf75bd5e1054698963be2ce6dea9f667ff323f4db84e3553f0e0f49c.json create mode 100644 backend/.sqlx/query-fee633fcf73f6253d07938cbf8e1c5947d2e22a10fc95401faa2d3704647830d.json create mode 100644 backend/.sqlx/query-fefcb942f0fbf57e7ba6e879f7843010a95fb50a983a45dc72638a3ada1b83ff.json create mode 100644 backend/migrations/20250117145630_v2_queue_compatibility_view.down.sql create mode 100644 backend/migrations/20250117145630_v2_queue_compatibility_view.up.sql create mode 100644 backend/migrations/20250117145631_v2_completed_job_compatibility_view.down.sql create mode 100644 backend/migrations/20250117145631_v2_completed_job_compatibility_view.up.sql delete mode 100644 backend/windmill-common/src/bench.rs create mode 100644 backend/windmill-worker/src/bench.rs diff --git a/backend/.sqlx/query-00d1874fcbd5a7b50e730c2a1c6c9b31e857d5b805dd226e3c1c17825b81b3d3.json b/backend/.sqlx/query-00d1874fcbd5a7b50e730c2a1c6c9b31e857d5b805dd226e3c1c17825b81b3d3.json new file mode 100644 index 0000000000..aac0401853 --- /dev/null +++ b/backend/.sqlx/query-00d1874fcbd5a7b50e730c2a1c6c9b31e857d5b805dd226e3c1c17825b81b3d3.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM v2_completed_job WHERE created_at <= now() - ($1::bigint::text || ' s')::interval AND started_at + ((duration_ms/1000 + $1::bigint) || ' s')::interval <= now() RETURNING id AS \"id!\"", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [ + true + ] + }, + "hash": "00d1874fcbd5a7b50e730c2a1c6c9b31e857d5b805dd226e3c1c17825b81b3d3" +} diff --git a/backend/.sqlx/query-011241a9df1c5c3962844f85d898527f2440dd512f592d2265753a684395736b.json b/backend/.sqlx/query-011241a9df1c5c3962844f85d898527f2440dd512f592d2265753a684395736b.json new file mode 100644 index 0000000000..96f730a114 --- /dev/null +++ b/backend/.sqlx/query-011241a9df1c5c3962844f85d898527f2440dd512f592d2265753a684395736b.json @@ -0,0 +1,30 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT leaf_jobs->$1::text AS \"leaf_jobs: Json>\", parent_job\n FROM v2_queue\n WHERE COALESCE((SELECT root_job FROM v2_queue WHERE id = $2), $2) = id AND workspace_id = $3", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "leaf_jobs: Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "parent_job", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Text", + "Uuid", + "Text" + ] + }, + "nullable": [ + null, + true + ] + }, + "hash": "011241a9df1c5c3962844f85d898527f2440dd512f592d2265753a684395736b" +} diff --git a/backend/.sqlx/query-03e79a6b6dad733971c6b729dcf5858c315bd3489366334f624e8a857e7a2520.json b/backend/.sqlx/query-03e79a6b6dad733971c6b729dcf5858c315bd3489366334f624e8a857e7a2520.json new file mode 100644 index 0000000000..6e355dfa66 --- /dev/null +++ b/backend/.sqlx/query-03e79a6b6dad733971c6b729dcf5858c315bd3489366334f624e8a857e7a2520.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue SET last_ping = now() WHERE id = $1 AND workspace_id = $2 AND canceled = false", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [] + }, + "hash": "03e79a6b6dad733971c6b729dcf5858c315bd3489366334f624e8a857e7a2520" +} diff --git a/backend/.sqlx/query-0544992727a484837d5dd4366ae52417a36c01702e9b56169919ef74ee8c3445.json b/backend/.sqlx/query-0544992727a484837d5dd4366ae52417a36c01702e9b56169919ef74ee8c3445.json new file mode 100644 index 0000000000..7beefb8af7 --- /dev/null +++ b/backend/.sqlx/query-0544992727a484837d5dd4366ae52417a36c01702e9b56169919ef74ee8c3445.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\" FROM v2_queue WHERE id = ANY($1) AND schedule_path IS NULL AND ($2::text[] IS NULL OR tag = ANY($2))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "UuidArray", + "TextArray" + ] + }, + "nullable": [ + true + ] + }, + "hash": "0544992727a484837d5dd4366ae52417a36c01702e9b56169919ef74ee8c3445" +} diff --git a/backend/.sqlx/query-0616f6e1320626fc7e343b352f216d38ef746ef0d004dd939cc76010a80476c8.json b/backend/.sqlx/query-0616f6e1320626fc7e343b352f216d38ef746ef0d004dd939cc76010a80476c8.json new file mode 100644 index 0000000000..2db85130eb --- /dev/null +++ b/backend/.sqlx/query-0616f6e1320626fc7e343b352f216d38ef746ef0d004dd939cc76010a80476c8.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(\n JSONB_SET(flow_status, ARRAY['modules', $1::TEXT], $2), ARRAY['step'], $3)\n WHERE id = $4", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Jsonb", + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "0616f6e1320626fc7e343b352f216d38ef746ef0d004dd939cc76010a80476c8" +} diff --git a/backend/.sqlx/query-068679795613c4fbfa77e4c96cfe310d1c4399fcbda69b93dd7bf15a93ce39ff.json b/backend/.sqlx/query-068679795613c4fbfa77e4c96cfe310d1c4399fcbda69b93dd7bf15a93ce39ff.json new file mode 100644 index 0000000000..d118aca234 --- /dev/null +++ b/backend/.sqlx/query-068679795613c4fbfa77e4c96cfe310d1c4399fcbda69b93dd7bf15a93ce39ff.json @@ -0,0 +1,35 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH runtime AS (\n SELECT GREATEST($8, r.memory_peak) AS memory_peak, flow_status\n FROM v2_job_runtime r\n LEFT JOIN v2_job_flow_runtime f USING (id)\n WHERE r.id = $1\n ), queued AS (\n DELETE FROM v2_job_queue q\n WHERE q.id = $1\n RETURNING\n q.id, q.workspace_id, q.started_at, q.worker,\n COALESCE($5, q.canceled_by) AS canceled_by,\n COALESCE($6, q.canceled_reason) AS canceled_reason\n ) INSERT INTO v2_job_completed (\n id, workspace_id, started_at, worker, memory_peak, flow_status, result,\n canceled_by, canceled_reason,\n duration_ms,\n status\n ) SELECT\n id, workspace_id, started_at, worker, memory_peak, flow_status, $7,\n canceled_by, canceled_reason,\n COALESCE($2::bigint, CASE\n WHEN started_at IS NULL THEN 0\n ELSE (EXTRACT('epoch' FROM NOW()) - EXTRACT('epoch' FROM started_at)) * 1000\n END) AS duration_ms,\n CASE\n WHEN $4::BOOLEAN THEN 'skipped'::job_status\n WHEN canceled_by IS NOT NULL THEN 'canceled'::job_status\n WHEN $3::BOOLEAN THEN 'success'::job_status\n ELSE 'failure'::job_status\n END AS status\n FROM queued, runtime\n ON CONFLICT (id) DO UPDATE SET status = EXCLUDED.status, result = EXCLUDED.result\n RETURNING status = 'canceled' AS \"canceled!\", duration_ms", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "canceled!", + "type_info": "Bool" + }, + { + "ordinal": 1, + "name": "duration_ms", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Bool", + "Bool", + "Varchar", + "Text", + "Jsonb", + "Int4" + ] + }, + "nullable": [ + null, + false + ] + }, + "hash": "068679795613c4fbfa77e4c96cfe310d1c4399fcbda69b93dd7bf15a93ce39ff" +} diff --git a/backend/.sqlx/query-079ee8e7d2c66ce04a47ac23a6265df69f64f2023c102d0b55ced6d94d06b9f8.json b/backend/.sqlx/query-079ee8e7d2c66ce04a47ac23a6265df69f64f2023c102d0b55ced6d94d06b9f8.json new file mode 100644 index 0000000000..9f135c0f5a --- /dev/null +++ b/backend/.sqlx/query-079ee8e7d2c66ce04a47ac23a6265df69f64f2023c102d0b55ced6d94d06b9f8.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT result AS \"result!: Json>\" FROM v2_completed_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result!: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "079ee8e7d2c66ce04a47ac23a6265df69f64f2023c102d0b55ced6d94d06b9f8" +} diff --git a/backend/.sqlx/query-0db2d456de66648bc62764515f54ba8b1715d75012aa5ca7a834d627bd674ac2.json b/backend/.sqlx/query-0db2d456de66648bc62764515f54ba8b1715d75012aa5ca7a834d627bd674ac2.json new file mode 100644 index 0000000000..fb88a53013 --- /dev/null +++ b/backend/.sqlx/query-0db2d456de66648bc62764515f54ba8b1715d75012aa5ca7a834d627bd674ac2.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\", result AS \"result: Json>\"\n FROM v2_completed_job WHERE id = ANY($1) AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "result: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "UuidArray", + "Text" + ] + }, + "nullable": [ + true, + true + ] + }, + "hash": "0db2d456de66648bc62764515f54ba8b1715d75012aa5ca7a834d627bd674ac2" +} diff --git a/backend/.sqlx/query-0dea444bfabee4cc67d100870786ed2a1f91f6cc5fb0a3cd55d1bb908068bf3c.json b/backend/.sqlx/query-0dea444bfabee4cc67d100870786ed2a1f91f6cc5fb0a3cd55d1bb908068bf3c.json new file mode 100644 index 0000000000..4eb1f04712 --- /dev/null +++ b/backend/.sqlx/query-0dea444bfabee4cc67d100870786ed2a1f91f6cc5fb0a3cd55d1bb908068bf3c.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(id) FROM v2_queue WHERE running = true AND email = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "0dea444bfabee4cc67d100870786ed2a1f91f6cc5fb0a3cd55d1bb908068bf3c" +} diff --git a/backend/.sqlx/query-0ea5ba568ec0f62b808fe938a41174646b6bdd658b8461db1bb90a871d076718.json b/backend/.sqlx/query-0ea5ba568ec0f62b808fe938a41174646b6bdd658b8461db1bb90a871d076718.json new file mode 100644 index 0000000000..19fe394067 --- /dev/null +++ b/backend/.sqlx/query-0ea5ba568ec0f62b808fe938a41174646b6bdd658b8461db1bb90a871d076718.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_queue SET workspace_id = $1 WHERE workspace_id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Text" + ] + }, + "nullable": [] + }, + "hash": "0ea5ba568ec0f62b808fe938a41174646b6bdd658b8461db1bb90a871d076718" +} diff --git a/backend/.sqlx/query-12443d540d4bbfb9f9f913d94b40c912317b0d95589ecb827aea27eb0357291b.json b/backend/.sqlx/query-12443d540d4bbfb9f9f913d94b40c912317b0d95589ecb827aea27eb0357291b.json new file mode 100644 index 0000000000..990d57d51e --- /dev/null +++ b/backend/.sqlx/query-12443d540d4bbfb9f9f913d94b40c912317b0d95589ecb827aea27eb0357291b.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT], $2)\n WHERE id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "12443d540d4bbfb9f9f913d94b40c912317b0d95589ecb827aea27eb0357291b" +} diff --git a/backend/.sqlx/query-1639452901868c2ea759fe751fd89ee2b5e9ebfc003fec10ebbc4298da58b805.json b/backend/.sqlx/query-1639452901868c2ea759fe751fd89ee2b5e9ebfc003fec10ebbc4298da58b805.json new file mode 100644 index 0000000000..c9cfcd54c6 --- /dev/null +++ b/backend/.sqlx/query-1639452901868c2ea759fe751fd89ee2b5e9ebfc003fec10ebbc4298da58b805.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT created_by AS \"created_by!\", CONCAT(coalesce(v2_queue.logs, ''), coalesce(job_logs.logs, '')) as logs, coalesce(job_logs.log_offset, 0) as log_offset, job_logs.log_file_index\n FROM v2_queue \n LEFT JOIN job_logs ON job_logs.job_id = v2_queue.id \n WHERE v2_queue.id = $1 AND v2_queue.workspace_id = $2 AND ($3::text[] IS NULL OR v2_queue.tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "logs", + "type_info": "Text" + }, + { + "ordinal": 2, + "name": "log_offset", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "log_file_index", + "type_info": "TextArray" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + true, + null, + null, + true + ] + }, + "hash": "1639452901868c2ea759fe751fd89ee2b5e9ebfc003fec10ebbc4298da58b805" +} diff --git a/backend/.sqlx/query-16a8daddd13818addfb4d0a2e9c24583dca58ae6ee4775930e6c1fbe85fd885b.json b/backend/.sqlx/query-16a8daddd13818addfb4d0a2e9c24583dca58ae6ee4775930e6c1fbe85fd885b.json new file mode 100644 index 0000000000..42816cb37f --- /dev/null +++ b/backend/.sqlx/query-16a8daddd13818addfb4d0a2e9c24583dca58ae6ee4775930e6c1fbe85fd885b.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "\n DELETE\n FROM parallel_monitor_lock\n WHERE last_ping IS NOT NULL AND last_ping < NOW() - ($1 || ' seconds')::interval \n RETURNING parent_flow_id, job_id, last_ping, (SELECT workspace_id FROM v2_queue q\n WHERE q.id = parent_flow_id AND q.running = true AND q.canceled = false) AS workspace_id\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "parent_flow_id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "job_id", + "type_info": "Uuid" + }, + { + "ordinal": 2, + "name": "last_ping", + "type_info": "Timestamptz" + }, + { + "ordinal": 3, + "name": "workspace_id", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + false, + true, + null + ] + }, + "hash": "16a8daddd13818addfb4d0a2e9c24583dca58ae6ee4775930e6c1fbe85fd885b" +} diff --git a/backend/.sqlx/query-16b46734348a373520cf04bd9730757c933fd5e16d7f61d4e3df228908d67750.json b/backend/.sqlx/query-16b46734348a373520cf04bd9730757c933fd5e16d7f61d4e3df228908d67750.json new file mode 100644 index 0000000000..317a8ebc5d --- /dev/null +++ b/backend/.sqlx/query-16b46734348a373520cf04bd9730757c933fd5e16d7f61d4e3df228908d67750.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_completed_job\n SET logs = '##DELETED##', args = '{}'::jsonb, result = '{}'::jsonb\n WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "16b46734348a373520cf04bd9730757c933fd5e16d7f61d4e3df228908d67750" +} diff --git a/backend/.sqlx/query-171edbdccc746e7c375b127738e4d71723acc9b39c86f644f8589b14c1b026cd.json b/backend/.sqlx/query-171edbdccc746e7c375b127738e4d71723acc9b39c86f644f8589b14c1b026cd.json new file mode 100644 index 0000000000..11c6b64dcd --- /dev/null +++ b/backend/.sqlx/query-171edbdccc746e7c375b127738e4d71723acc9b39c86f644f8589b14c1b026cd.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET last_ping = null\n WHERE id = $1 AND last_ping = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "171edbdccc746e7c375b127738e4d71723acc9b39c86f644f8589b14c1b026cd" +} diff --git a/backend/.sqlx/query-188389a7c54ff87247b9a875752c56060ef60ff1a9e77cd2315940ca0a49253d.json b/backend/.sqlx/query-188389a7c54ff87247b9a875752c56060ef60ff1a9e77cd2315940ca0a49253d.json new file mode 100644 index 0000000000..fab4f1b101 --- /dev/null +++ b/backend/.sqlx/query-188389a7c54ff87247b9a875752c56060ef60ff1a9e77cd2315940ca0a49253d.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = flow_status - 'approval_conditions'\n WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "188389a7c54ff87247b9a875752c56060ef60ff1a9e77cd2315940ca0a49253d" +} diff --git a/backend/.sqlx/query-19ffbc1d775bcef3ed787875aa6017a4b0501ea94ac284e9245c566d3d097925.json b/backend/.sqlx/query-19ffbc1d775bcef3ed787875aa6017a4b0501ea94ac284e9245c566d3d097925.json new file mode 100644 index 0000000000..57d5a3f676 --- /dev/null +++ b/backend/.sqlx/query-19ffbc1d775bcef3ed787875aa6017a4b0501ea94ac284e9245c566d3d097925.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT script_path FROM v2_queue WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "script_path", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "19ffbc1d775bcef3ed787875aa6017a4b0501ea94ac284e9245c566d3d097925" +} diff --git a/backend/.sqlx/query-1a85ca0a6d0ba5ab3462907e35037136fd123f80389abe6ebbcf12084da45868.json b/backend/.sqlx/query-1a85ca0a6d0ba5ab3462907e35037136fd123f80389abe6ebbcf12084da45868.json new file mode 100644 index 0000000000..1d83c36fd8 --- /dev/null +++ b/backend/.sqlx/query-1a85ca0a6d0ba5ab3462907e35037136fd123f80389abe6ebbcf12084da45868.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM v2_job_queue WHERE workspace_id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [] + }, + "hash": "1a85ca0a6d0ba5ab3462907e35037136fd123f80389abe6ebbcf12084da45868" +} diff --git a/backend/.sqlx/query-1c790df0b801378743ac040c5599219817e66ec2aee939853af8df64048e813d.json b/backend/.sqlx/query-1c790df0b801378743ac040c5599219817e66ec2aee939853af8df64048e813d.json new file mode 100644 index 0000000000..7b27e98020 --- /dev/null +++ b/backend/.sqlx/query-1c790df0b801378743ac040c5599219817e66ec2aee939853af8df64048e813d.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'flow_jobs_success', $3::TEXT], $4) WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Uuid", + "Text", + "Jsonb" + ] + }, + "nullable": [] + }, + "hash": "1c790df0b801378743ac040c5599219817e66ec2aee939853af8df64048e813d" +} diff --git a/backend/.sqlx/query-1d45dedd57c2fafd53d3e425a9bf25c2e0a96eb3a94a092f07afffa7e5ad9c70.json b/backend/.sqlx/query-1d45dedd57c2fafd53d3e425a9bf25c2e0a96eb3a94a092f07afffa7e5ad9c70.json new file mode 100644 index 0000000000..ea788d2146 --- /dev/null +++ b/backend/.sqlx/query-1d45dedd57c2fafd53d3e425a9bf25c2e0a96eb3a94a092f07afffa7e5ad9c70.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n args AS \"args: Json>>\"\n FROM v2_queue\n WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "args: Json>>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "1d45dedd57c2fafd53d3e425a9bf25c2e0a96eb3a94a092f07afffa7e5ad9c70" +} diff --git a/backend/.sqlx/query-2135a4034fb85e04d707051b134b176073160cb4e6e27435520c23dd4974345a.json b/backend/.sqlx/query-2135a4034fb85e04d707051b134b176073160cb4e6e27435520c23dd4974345a.json new file mode 100644 index 0000000000..19ef49f51b --- /dev/null +++ b/backend/.sqlx/query-2135a4034fb85e04d707051b134b176073160cb4e6e27435520c23dd4974345a.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue SET flow_status = jsonb_set(jsonb_set(COALESCE(flow_status, '{}'::jsonb), array[$1], COALESCE(flow_status->$1, '{}'::jsonb)), array[$1, 'started_at'], to_jsonb(now()::text)) WHERE id = $2 AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Uuid", + "Text" + ] + }, + "nullable": [] + }, + "hash": "2135a4034fb85e04d707051b134b176073160cb4e6e27435520c23dd4974345a" +} diff --git a/backend/.sqlx/query-227511aeb98cf02e49eba2acda16f7f9288dc6b349c2c46945e36fdd46401c6c.json b/backend/.sqlx/query-227511aeb98cf02e49eba2acda16f7f9288dc6b349c2c46945e36fdd46401c6c.json new file mode 100644 index 0000000000..c9007a2356 --- /dev/null +++ b/backend/.sqlx/query-227511aeb98cf02e49eba2acda16f7f9288dc6b349c2c46945e36fdd46401c6c.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\", flow_status AS \"flow_status!: Json\"\n FROM v2_completed_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "flow_status!: Json", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true + ] + }, + "hash": "227511aeb98cf02e49eba2acda16f7f9288dc6b349c2c46945e36fdd46401c6c" +} diff --git a/backend/.sqlx/query-231ece5db2fbf26d6fbe298b16f844552e5dd432f35e247241f660cb3c2f8c96.json b/backend/.sqlx/query-231ece5db2fbf26d6fbe298b16f844552e5dd432f35e247241f660cb3c2f8c96.json new file mode 100644 index 0000000000..e8704d13ab --- /dev/null +++ b/backend/.sqlx/query-231ece5db2fbf26d6fbe298b16f844552e5dd432f35e247241f660cb3c2f8c96.json @@ -0,0 +1,34 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue SET running = false, started_at = null\n WHERE last_ping < now() - ($1 || ' seconds')::interval\n AND running = true AND job_kind NOT IN ('flow', 'flowpreview', 'flownode', 'singlescriptflow') AND same_worker = false RETURNING id AS \"id!\", workspace_id AS \"workspace_id!\", last_ping", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "workspace_id!", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "last_ping", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + true, + true, + true + ] + }, + "hash": "231ece5db2fbf26d6fbe298b16f844552e5dd432f35e247241f660cb3c2f8c96" +} diff --git a/backend/.sqlx/query-28c40cfbe796c6fb942cc9f72e00f9d3de633cdc4f9e23c6d9bd27eba07b0cb2.json b/backend/.sqlx/query-28c40cfbe796c6fb942cc9f72e00f9d3de633cdc4f9e23c6d9bd27eba07b0cb2.json new file mode 100644 index 0000000000..b39b9ef58a --- /dev/null +++ b/backend/.sqlx/query-28c40cfbe796c6fb942cc9f72e00f9d3de633cdc4f9e23c6d9bd27eba07b0cb2.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT null FROM v2_job_queue WHERE id = $1 FOR UPDATE", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Text" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "28c40cfbe796c6fb942cc9f72e00f9d3de633cdc4f9e23c6d9bd27eba07b0cb2" +} diff --git a/backend/.sqlx/query-2c47c39cb7463ab3e15e062f2747a43e15f0be227265f579eccc6e525939a648.json b/backend/.sqlx/query-2c47c39cb7463ab3e15e062f2747a43e15f0be227265f579eccc6e525939a648.json new file mode 100644 index 0000000000..e75bac0371 --- /dev/null +++ b/backend/.sqlx/query-2c47c39cb7463ab3e15e062f2747a43e15f0be227265f579eccc6e525939a648.json @@ -0,0 +1,58 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n id AS \"id!\", workspace_id AS \"workspace_id!\", parent_job, is_flow_step,\n flow_status AS \"flow_status: Box\", last_ping, same_worker\n FROM v2_queue\n WHERE running = true AND suspend = 0 AND suspend_until IS null AND scheduled_for <= now()\n AND (job_kind = 'flow' OR job_kind = 'flowpreview' OR job_kind = 'flownode')\n AND last_ping IS NOT NULL AND last_ping < NOW() - ($1 || ' seconds')::interval\n AND canceled = false\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "workspace_id!", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "parent_job", + "type_info": "Uuid" + }, + { + "ordinal": 3, + "name": "is_flow_step", + "type_info": "Bool" + }, + { + "ordinal": 4, + "name": "flow_status: Box", + "type_info": "Jsonb" + }, + { + "ordinal": 5, + "name": "last_ping", + "type_info": "Timestamptz" + }, + { + "ordinal": 6, + "name": "same_worker", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true, + true, + true, + true + ] + }, + "hash": "2c47c39cb7463ab3e15e062f2747a43e15f0be227265f579eccc6e525939a648" +} diff --git a/backend/.sqlx/query-2d6b581a9e5df008b2a0223eae6794065e6e6bf70415d331ccea6038271a7fec.json b/backend/.sqlx/query-2d6b581a9e5df008b2a0223eae6794065e6e6bf70415d331ccea6038271a7fec.json new file mode 100644 index 0000000000..b8c75b4cce --- /dev/null +++ b/backend/.sqlx/query-2d6b581a9e5df008b2a0223eae6794065e6e6bf70415d331ccea6038271a7fec.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT \n flow_status->>'step' = '0' \n AND (\n jsonb_array_length(flow_status->'modules') = 0 \n OR flow_status->'modules'->0->>'type' = 'WaitingForPriorSteps' \n OR (\n flow_status->'modules'->0->>'type' = 'Failure' \n AND flow_status->'modules'->0->>'job' = $1\n )\n )\n FROM v2_completed_job WHERE id = $2 AND workspace_id = $3", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Text", + "Uuid", + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "2d6b581a9e5df008b2a0223eae6794065e6e6bf70415d331ccea6038271a7fec" +} diff --git a/backend/.sqlx/query-30606c485f46e737d2d0acc9deb44c43b408f3f86da47141c973af1b9f549c0a.json b/backend/.sqlx/query-30606c485f46e737d2d0acc9deb44c43b408f3f86da47141c973af1b9f549c0a.json new file mode 100644 index 0000000000..e6e750510b --- /dev/null +++ b/backend/.sqlx/query-30606c485f46e737d2d0acc9deb44c43b408f3f86da47141c973af1b9f549c0a.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET leaf_jobs = JSONB_SET(coalesce(leaf_jobs, '{}'::jsonb), ARRAY[$1::TEXT], $2)\n WHERE COALESCE((SELECT root_job FROM v2_queue WHERE id = $3), $3) = id", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "30606c485f46e737d2d0acc9deb44c43b408f3f86da47141c973af1b9f549c0a" +} diff --git a/backend/.sqlx/query-32662887109a0619b860551140a6f1d178813a682dfef6c21983077eb0848fdb.json b/backend/.sqlx/query-32662887109a0619b860551140a6f1d178813a682dfef6c21983077eb0848fdb.json new file mode 100644 index 0000000000..849ca88ecc --- /dev/null +++ b/backend/.sqlx/query-32662887109a0619b860551140a6f1d178813a682dfef6c21983077eb0848fdb.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(flow_status, ARRAY['modules', flow_status->>'step', 'progress'], $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "32662887109a0619b860551140a6f1d178813a682dfef6c21983077eb0848fdb" +} diff --git a/backend/.sqlx/query-382eb81b25154b3aff04e520e2611081779292a92d283bc23e8268f46542b5d2.json b/backend/.sqlx/query-382eb81b25154b3aff04e520e2611081779292a92d283bc23e8268f46542b5d2.json new file mode 100644 index 0000000000..34c56c37d2 --- /dev/null +++ b/backend/.sqlx/query-382eb81b25154b3aff04e520e2611081779292a92d283bc23e8268f46542b5d2.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT success AS \"success!\" FROM v2_completed_job WHERE id = ANY($1)", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "success!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "UuidArray" + ] + }, + "nullable": [ + true + ] + }, + "hash": "382eb81b25154b3aff04e520e2611081779292a92d283bc23e8268f46542b5d2" +} diff --git a/backend/.sqlx/query-3843fa02ec86e57c1f13bc66e86adf8d6d19cc6cf612c20f3fb27071bfce071a.json b/backend/.sqlx/query-3843fa02ec86e57c1f13bc66e86adf8d6d19cc6cf612c20f3fb27071bfce071a.json new file mode 100644 index 0000000000..e83c3674ca --- /dev/null +++ b/backend/.sqlx/query-3843fa02ec86e57c1f13bc66e86adf8d6d19cc6cf612c20f3fb27071bfce071a.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\" FROM v2_queue WHERE schedule_path = $1 AND workspace_id = $2 AND id != $3 AND running = true", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Text", + "Text", + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "3843fa02ec86e57c1f13bc66e86adf8d6d19cc6cf612c20f3fb27071bfce071a" +} diff --git a/backend/.sqlx/query-3c4816f411277de2b94b65ab8d2c6d2a3fdc1f3cd8a13ffdef536cf8b6475634.json b/backend/.sqlx/query-3c4816f411277de2b94b65ab8d2c6d2a3fdc1f3cd8a13ffdef536cf8b6475634.json new file mode 100644 index 0000000000..ffb0b4c5c4 --- /dev/null +++ b/backend/.sqlx/query-3c4816f411277de2b94b65ab8d2c6d2a3fdc1f3cd8a13ffdef536cf8b6475634.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT EXISTS (SELECT 1 FROM v2_queue WHERE workspace_id = $1 AND schedule_path = $2 AND scheduled_for = $3)", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "exists", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Text", + "Text", + "Timestamptz" + ] + }, + "nullable": [ + null + ] + }, + "hash": "3c4816f411277de2b94b65ab8d2c6d2a3fdc1f3cd8a13ffdef536cf8b6475634" +} diff --git a/backend/.sqlx/query-3c8f53194af72224d943adb5f38a7dc0c2a8676b586d36e9f949b2a056dcf1e2.json b/backend/.sqlx/query-3c8f53194af72224d943adb5f38a7dc0c2a8676b586d36e9f949b2a056dcf1e2.json new file mode 100644 index 0000000000..2d0950f91a --- /dev/null +++ b/backend/.sqlx/query-3c8f53194af72224d943adb5f38a7dc0c2a8676b586d36e9f949b2a056dcf1e2.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET last_ping = now()\n WHERE id = $1 AND last_ping < now()", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "3c8f53194af72224d943adb5f38a7dc0c2a8676b586d36e9f949b2a056dcf1e2" +} diff --git a/backend/.sqlx/query-3d0e77e8a68fcd9ad6f1f27cb9f01e00776aa50f32e5cbd073d9aa1dcca944b2.json b/backend/.sqlx/query-3d0e77e8a68fcd9ad6f1f27cb9f01e00776aa50f32e5cbd073d9aa1dcca944b2.json new file mode 100644 index 0000000000..01ce4de114 --- /dev/null +++ b/backend/.sqlx/query-3d0e77e8a68fcd9ad6f1f27cb9f01e00776aa50f32e5cbd073d9aa1dcca944b2.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM v2_completed_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "args", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "Bool" + ] + }, + "nullable": [ + null + ] + }, + "hash": "3d0e77e8a68fcd9ad6f1f27cb9f01e00776aa50f32e5cbd073d9aa1dcca944b2" +} diff --git a/backend/.sqlx/query-40e9002c4e2aa58722ba382e307e356286035fb1aeed6268cbcab16251bfde98.json b/backend/.sqlx/query-40e9002c4e2aa58722ba382e307e356286035fb1aeed6268cbcab16251bfde98.json new file mode 100644 index 0000000000..49439bd447 --- /dev/null +++ b/backend/.sqlx/query-40e9002c4e2aa58722ba382e307e356286035fb1aeed6268cbcab16251bfde98.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue SET running = false, started_at = null WHERE id = $1 AND canceled = false", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "40e9002c4e2aa58722ba382e307e356286035fb1aeed6268cbcab16251bfde98" +} diff --git a/backend/.sqlx/query-41addab65f2ce7214dc7c28ed5780561c90ee1ba82f10cc966882ecf7ec106cf.json b/backend/.sqlx/query-41addab65f2ce7214dc7c28ed5780561c90ee1ba82f10cc966882ecf7ec106cf.json new file mode 100644 index 0000000000..e3a09adc10 --- /dev/null +++ b/backend/.sqlx/query-41addab65f2ce7214dc7c28ed5780561c90ee1ba82f10cc966882ecf7ec106cf.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(JSONB_SET(flow_status, ARRAY['retry'], $1), ARRAY['modules', $3::TEXT, 'failed_retries'], $4)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid", + "Text", + "Jsonb" + ] + }, + "nullable": [] + }, + "hash": "41addab65f2ce7214dc7c28ed5780561c90ee1ba82f10cc966882ecf7ec106cf" +} diff --git a/backend/.sqlx/query-4244640e62fffb0f6978f8f7d78291b3294a6a7d1549d752f14acf5972552ba5.json b/backend/.sqlx/query-4244640e62fffb0f6978f8f7d78291b3294a6a7d1549d752f14acf5972552ba5.json new file mode 100644 index 0000000000..841d549e20 --- /dev/null +++ b/backend/.sqlx/query-4244640e62fffb0f6978f8f7d78291b3294a6a7d1549d752f14acf5972552ba5.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET workspace_id = $1 WHERE workspace_id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Text" + ] + }, + "nullable": [] + }, + "hash": "4244640e62fffb0f6978f8f7d78291b3294a6a7d1549d752f14acf5972552ba5" +} diff --git a/backend/.sqlx/query-45f6578656373d9838f1d28da40a468340f337869125f20d7078af1851209b2c.json b/backend/.sqlx/query-45f6578656373d9838f1d28da40a468340f337869125f20d7078af1851209b2c.json new file mode 100644 index 0000000000..6521f5e9bb --- /dev/null +++ b/backend/.sqlx/query-45f6578656373d9838f1d28da40a468340f337869125f20d7078af1851209b2c.json @@ -0,0 +1,25 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue SET canceled = true, canceled_by = $1, canceled_reason = $2, scheduled_for = now(), suspend = 0 WHERE id = $3 AND workspace_id = $4 AND (canceled = false OR canceled_reason != $2) RETURNING id AS \"id!\"", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Varchar", + "Text", + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "45f6578656373d9838f1d28da40a468340f337869125f20d7078af1851209b2c" +} diff --git a/backend/.sqlx/query-4616976a089af7e58c312d0b5357189a35c4691769981a5f8218cc708bd038e3.json b/backend/.sqlx/query-4616976a089af7e58c312d0b5357189a35c4691769981a5f8218cc708bd038e3.json new file mode 100644 index 0000000000..f7ae58295b --- /dev/null +++ b/backend/.sqlx/query-4616976a089af7e58c312d0b5357189a35c4691769981a5f8218cc708bd038e3.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue SET suspend = $1 WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int4", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "4616976a089af7e58c312d0b5357189a35c4691769981a5f8218cc708bd038e3" +} diff --git a/backend/.sqlx/query-461bb76f9dc0a1d5f35e050d3fab309800382d5173e36c5aa6cc430d46a90324.json b/backend/.sqlx/query-461bb76f9dc0a1d5f35e050d3fab309800382d5173e36c5aa6cc430d46a90324.json new file mode 100644 index 0000000000..baf71a4847 --- /dev/null +++ b/backend/.sqlx/query-461bb76f9dc0a1d5f35e050d3fab309800382d5173e36c5aa6cc430d46a90324.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT parent_job FROM v2_queue WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "parent_job", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "461bb76f9dc0a1d5f35e050d3fab309800382d5173e36c5aa6cc430d46a90324" +} diff --git a/backend/.sqlx/query-464c90d711899090eb3dc4054f5da69c278171633f8b05c29e9e91c82bf3c1c4.json b/backend/.sqlx/query-464c90d711899090eb3dc4054f5da69c278171633f8b05c29e9e91c82bf3c1c4.json new file mode 100644 index 0000000000..a8c03d21d2 --- /dev/null +++ b/backend/.sqlx/query-464c90d711899090eb3dc4054f5da69c278171633f8b05c29e9e91c82bf3c1c4.json @@ -0,0 +1,28 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT (flow_status->'step')::integer as step, jsonb_array_length(flow_status->'modules') as len FROM v2_queue WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "step", + "type_info": "Int4" + }, + { + "ordinal": 1, + "name": "len", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null, + null + ] + }, + "hash": "464c90d711899090eb3dc4054f5da69c278171633f8b05c29e9e91c82bf3c1c4" +} diff --git a/backend/.sqlx/query-4710cb3a00b54882619ad54d43235f1c8eb1d742a423d78ea9351ea301cfa84a.json b/backend/.sqlx/query-4710cb3a00b54882619ad54d43235f1c8eb1d742a423d78ea9351ea301cfa84a.json new file mode 100644 index 0000000000..b23328762a --- /dev/null +++ b/backend/.sqlx/query-4710cb3a00b54882619ad54d43235f1c8eb1d742a423d78ea9351ea301cfa84a.json @@ -0,0 +1,73 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n script_path, script_hash AS \"script_hash: ScriptHash\",\n job_kind AS \"job_kind!: JobKind\",\n flow_status AS \"flow_status: Json>\",\n raw_flow AS \"raw_flow: Json>\"\n FROM v2_completed_job WHERE id = $1 and workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "script_path", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "script_hash: ScriptHash", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "job_kind!: JobKind", + "type_info": { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + } + }, + { + "ordinal": 3, + "name": "flow_status: Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "raw_flow: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true, + true + ] + }, + "hash": "4710cb3a00b54882619ad54d43235f1c8eb1d742a423d78ea9351ea301cfa84a" +} diff --git a/backend/.sqlx/query-490e8230628f3f966db05b728d25fb0adb7f383282897651500159fae4f6860a.json b/backend/.sqlx/query-490e8230628f3f966db05b728d25fb0adb7f383282897651500159fae4f6860a.json new file mode 100644 index 0000000000..60486554a0 --- /dev/null +++ b/backend/.sqlx/query-490e8230628f3f966db05b728d25fb0adb7f383282897651500159fae4f6860a.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT tag as \"tag!\", COUNT(*) as \"count!\"\n FROM v2_completed_job\n WHERE started_at > NOW() - make_interval(secs => $1) AND ($2::text IS NULL OR workspace_id = $2)\n GROUP BY tag\n ORDER BY \"count!\" DESC\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "tag!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "count!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Float8", + "Text" + ] + }, + "nullable": [ + true, + null + ] + }, + "hash": "490e8230628f3f966db05b728d25fb0adb7f383282897651500159fae4f6860a" +} diff --git a/backend/.sqlx/query-49592da5e205e949facc87946f3a76b70a01ac2346d954daa5de2232fe234ce7.json b/backend/.sqlx/query-49592da5e205e949facc87946f3a76b70a01ac2346d954daa5de2232fe234ce7.json new file mode 100644 index 0000000000..420ef21a74 --- /dev/null +++ b/backend/.sqlx/query-49592da5e205e949facc87946f3a76b70a01ac2346d954daa5de2232fe234ce7.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET suspend = $1, suspend_until = now() + interval '14 day', running = true\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int4", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "49592da5e205e949facc87946f3a76b70a01ac2346d954daa5de2232fe234ce7" +} diff --git a/backend/.sqlx/query-49d23dccfd132b6919f6084670886d181e2c8f2bec2fbeb1cc296c1e7251264e.json b/backend/.sqlx/query-49d23dccfd132b6919f6084670886d181e2c8f2bec2fbeb1cc296c1e7251264e.json new file mode 100644 index 0000000000..81dac196ad --- /dev/null +++ b/backend/.sqlx/query-49d23dccfd132b6919f6084670886d181e2c8f2bec2fbeb1cc296c1e7251264e.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO metrics (id, value)\n VALUES ($1, to_jsonb((SELECT EXTRACT(EPOCH FROM now() - scheduled_for)\n FROM v2_queue WHERE tag = $2 AND running = false AND scheduled_for <= now() - ('3 seconds')::interval\n ORDER BY priority DESC NULLS LAST, scheduled_for LIMIT 1)))", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Text" + ] + }, + "nullable": [] + }, + "hash": "49d23dccfd132b6919f6084670886d181e2c8f2bec2fbeb1cc296c1e7251264e" +} diff --git a/backend/.sqlx/query-4cdbdd36bee7563ae7d09d20543e45600f695149652362400db1f16724c04c6f.json b/backend/.sqlx/query-4cdbdd36bee7563ae7d09d20543e45600f695149652362400db1f16724c04c6f.json new file mode 100644 index 0000000000..107287a6f9 --- /dev/null +++ b/backend/.sqlx/query-4cdbdd36bee7563ae7d09d20543e45600f695149652362400db1f16724c04c6f.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(*) FROM v2_queue WHERE canceled = false AND (scheduled_for <= now()\n OR (suspend_until IS NOT NULL\n AND ( suspend <= 0\n OR suspend_until <= now())))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + null + ] + }, + "hash": "4cdbdd36bee7563ae7d09d20543e45600f695149652362400db1f16724c04c6f" +} diff --git a/backend/.sqlx/query-5102b5f5eedc9a5d59d67e141c523decca8d6ba819fd076dcbd17001b9c5af8a.json b/backend/.sqlx/query-5102b5f5eedc9a5d59d67e141c523decca8d6ba819fd076dcbd17001b9c5af8a.json new file mode 100644 index 0000000000..457e0f56d9 --- /dev/null +++ b/backend/.sqlx/query-5102b5f5eedc9a5d59d67e141c523decca8d6ba819fd076dcbd17001b9c5af8a.json @@ -0,0 +1,26 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT tag AS \"tag!\", count(*) AS \"count!\" FROM v2_queue WHERE\n scheduled_for <= now() - ('3 seconds')::interval AND running = false\n GROUP BY tag", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "tag!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "count!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + true, + null + ] + }, + "hash": "5102b5f5eedc9a5d59d67e141c523decca8d6ba819fd076dcbd17001b9c5af8a" +} diff --git a/backend/.sqlx/query-536556e00c2f7a05219adbbcf34ec25a2d548cf832193f6c6ac922c1979ea7d1.json b/backend/.sqlx/query-536556e00c2f7a05219adbbcf34ec25a2d548cf832193f6c6ac922c1979ea7d1.json new file mode 100644 index 0000000000..129a3355bf --- /dev/null +++ b/backend/.sqlx/query-536556e00c2f7a05219adbbcf34ec25a2d548cf832193f6c6ac922c1979ea7d1.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue SET suspend = 0 WHERE parent_job = $1 AND suspend = $2 AND (flow_status->'step')::int = 0", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Int4" + ] + }, + "nullable": [] + }, + "hash": "536556e00c2f7a05219adbbcf34ec25a2d548cf832193f6c6ac922c1979ea7d1" +} diff --git a/backend/.sqlx/query-58dd434aadbee8a55cf422246adc228d95574775a0824b29287e836f51433dc8.json b/backend/.sqlx/query-58dd434aadbee8a55cf422246adc228d95574775a0824b29287e836f51433dc8.json new file mode 100644 index 0000000000..f4e9b9c3b3 --- /dev/null +++ b/backend/.sqlx/query-58dd434aadbee8a55cf422246adc228d95574775a0824b29287e836f51433dc8.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(\n JSONB_SET(flow_status, ARRAY['preprocessor_module'], $1), ARRAY['step'], $2)\n WHERE id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "58dd434aadbee8a55cf422246adc228d95574775a0824b29287e836f51433dc8" +} diff --git a/backend/.sqlx/query-596dcd11848e4196eb82f7fcf491db0d4077a186fab0a00f609bd16129f016f2.json b/backend/.sqlx/query-596dcd11848e4196eb82f7fcf491db0d4077a186fab0a00f609bd16129f016f2.json new file mode 100644 index 0000000000..a663cedf6e --- /dev/null +++ b/backend/.sqlx/query-596dcd11848e4196eb82f7fcf491db0d4077a186fab0a00f609bd16129f016f2.json @@ -0,0 +1,30 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT created_by AS \"created_by!\", args as \"args: sqlx::types::Json>\"\n FROM v2_queue\n WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "args: sqlx::types::Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + true, + true + ] + }, + "hash": "596dcd11848e4196eb82f7fcf491db0d4077a186fab0a00f609bd16129f016f2" +} diff --git a/backend/.sqlx/query-5a335118fbe54a23269ef7a4ee1c4393d83e674e16d280c1281e6cba857ea65e.json b/backend/.sqlx/query-5a335118fbe54a23269ef7a4ee1c4393d83e674e16d280c1281e6cba857ea65e.json new file mode 100644 index 0000000000..cf500e5bc7 --- /dev/null +++ b/backend/.sqlx/query-5a335118fbe54a23269ef7a4ee1c4393d83e674e16d280c1281e6cba857ea65e.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = jsonb_set(\n jsonb_set(flow_status, ARRAY['preprocessor_module', 'job'], to_jsonb($1::UUID::TEXT)),\n ARRAY['preprocessor_module', 'type'],\n to_jsonb('InProgress'::text)\n )\n WHERE id = $2 AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Text" + ] + }, + "nullable": [] + }, + "hash": "5a335118fbe54a23269ef7a4ee1c4393d83e674e16d280c1281e6cba857ea65e" +} diff --git a/backend/.sqlx/query-5ac9630d8d339adb6023570875cd827b38b9f55333a86cb45bbd4c6fe51af023.json b/backend/.sqlx/query-5ac9630d8d339adb6023570875cd827b38b9f55333a86cb45bbd4c6fe51af023.json new file mode 100644 index 0000000000..2810a877bd --- /dev/null +++ b/backend/.sqlx/query-5ac9630d8d339adb6023570875cd827b38b9f55333a86cb45bbd4c6fe51af023.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT], $2)\n WHERE id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "5ac9630d8d339adb6023570875cd827b38b9f55333a86cb45bbd4c6fe51af023" +} diff --git a/backend/.sqlx/query-5acc194f4081cd81677eae9f1fbfe694c3b1aa2769a131d805600e764c458cdc.json b/backend/.sqlx/query-5acc194f4081cd81677eae9f1fbfe694c3b1aa2769a131d805600e764c458cdc.json new file mode 100644 index 0000000000..fd787fdf3b --- /dev/null +++ b/backend/.sqlx/query-5acc194f4081cd81677eae9f1fbfe694c3b1aa2769a131d805600e764c458cdc.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_completed_job\n SET logs = '##DELETED##', args = '{}'::jsonb, result = '{}'::jsonb\n WHERE id = ANY($1)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "UuidArray" + ] + }, + "nullable": [] + }, + "hash": "5acc194f4081cd81677eae9f1fbfe694c3b1aa2769a131d805600e764c458cdc" +} diff --git a/backend/.sqlx/query-5bedae1ed06d199f787158a724be75534db7e1f3e34d86de83c6a3f17cde492b.json b/backend/.sqlx/query-5bedae1ed06d199f787158a724be75534db7e1f3e34d86de83c6a3f17cde492b.json new file mode 100644 index 0000000000..b3f4300d29 --- /dev/null +++ b/backend/.sqlx/query-5bedae1ed06d199f787158a724be75534db7e1f3e34d86de83c6a3f17cde492b.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'branchall', 'branch'], ((flow_status->'modules'->$1::int->'branchall'->>'branch')::int + 1)::text::jsonb),\n last_ping = NULL\n WHERE id = $2\n RETURNING (flow_status->'modules'->$1::int->'branchall'->>'branch')::int", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "int4", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Int4", + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "5bedae1ed06d199f787158a724be75534db7e1f3e34d86de83c6a3f17cde492b" +} diff --git a/backend/.sqlx/query-5c45748ab3df322f6a5cf4b52d9185ceecf81aaa9a2e4e53d926b70b1cde2771.json b/backend/.sqlx/query-5c45748ab3df322f6a5cf4b52d9185ceecf81aaa9a2e4e53d926b70b1cde2771.json new file mode 100644 index 0000000000..f37cf1381d --- /dev/null +++ b/backend/.sqlx/query-5c45748ab3df322f6a5cf4b52d9185ceecf81aaa9a2e4e53d926b70b1cde2771.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue SET\n flow_status = JSONB_SET(flow_status, ARRAY['modules', flow_status->>'step'::text], $1),\n suspend = $2,\n suspend_until = now() + $3\n WHERE id = $4", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Int4", + "Interval", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "5c45748ab3df322f6a5cf4b52d9185ceecf81aaa9a2e4e53d926b70b1cde2771" +} diff --git a/backend/.sqlx/query-5d0284028d0dc16fbbf353496a2204f9df256e03a588c23b33b4edab0d9c3e1a.json b/backend/.sqlx/query-5d0284028d0dc16fbbf353496a2204f9df256e03a588c23b33b4edab0d9c3e1a.json new file mode 100644 index 0000000000..981c595d69 --- /dev/null +++ b/backend/.sqlx/query-5d0284028d0dc16fbbf353496a2204f9df256e03a588c23b33b4edab0d9c3e1a.json @@ -0,0 +1,21 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO v2_job_queue (\n id, workspace_id, started_at, scheduled_for, running, created_at, tag, priority\n ) SELECT unnest($1::uuid[]), $2, $3, $4, $5, $6, $7, $8", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "UuidArray", + "Varchar", + "Timestamptz", + "Timestamptz", + "Bool", + "Timestamptz", + "Varchar", + "Int2" + ] + }, + "nullable": [] + }, + "hash": "5d0284028d0dc16fbbf353496a2204f9df256e03a588c23b33b4edab0d9c3e1a" +} diff --git a/backend/.sqlx/query-5e4d30de66cc4289013e1f2da6c954c76fc4bfcd0e7a465cab6ef1386f67b61c.json b/backend/.sqlx/query-5e4d30de66cc4289013e1f2da6c954c76fc4bfcd0e7a465cab6ef1386f67b61c.json new file mode 100644 index 0000000000..31c5f018ad --- /dev/null +++ b/backend/.sqlx/query-5e4d30de66cc4289013e1f2da6c954c76fc4bfcd0e7a465cab6ef1386f67b61c.json @@ -0,0 +1,38 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n success AS \"success!\",\n result AS \"result: Json>\",\n started_at AS \"started_at!\"FROM v2_completed_job WHERE workspace_id = $1 AND schedule_path = $2 AND script_path = $3 AND id != $4\n ORDER BY created_at DESC\n LIMIT $5", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "success!", + "type_info": "Bool" + }, + { + "ordinal": 1, + "name": "result: Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "started_at!", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text", + "Text", + "Text", + "Uuid", + "Int8" + ] + }, + "nullable": [ + true, + true, + true + ] + }, + "hash": "5e4d30de66cc4289013e1f2da6c954c76fc4bfcd0e7a465cab6ef1386f67b61c" +} diff --git a/backend/.sqlx/query-5fa2be2d293b8a215752642cf9ddf162960b9e35fe53f961d36f137453f854f0.json b/backend/.sqlx/query-5fa2be2d293b8a215752642cf9ddf162960b9e35fe53f961d36f137453f854f0.json new file mode 100644 index 0000000000..621cf4e31f --- /dev/null +++ b/backend/.sqlx/query-5fa2be2d293b8a215752642cf9ddf162960b9e35fe53f961d36f137453f854f0.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT running AS \"running!\" FROM v2_queue WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "running!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "5fa2be2d293b8a215752642cf9ddf162960b9e35fe53f961d36f137453f854f0" +} diff --git a/backend/.sqlx/query-631beba7482e25cff1e89d00adf4f4f46fec5640b63a13f9ffaad56d40a47812.json b/backend/.sqlx/query-631beba7482e25cff1e89d00adf4f4f46fec5640b63a13f9ffaad56d40a47812.json new file mode 100644 index 0000000000..f477a9ebc8 --- /dev/null +++ b/backend/.sqlx/query-631beba7482e25cff1e89d00adf4f4f46fec5640b63a13f9ffaad56d40a47812.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT root_job FROM v2_queue WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "root_job", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "631beba7482e25cff1e89d00adf4f4f46fec5640b63a13f9ffaad56d40a47812" +} diff --git a/backend/.sqlx/query-67227115cc54ff3f8f8c539ea8906d62775fe3f8b68e054db73d1eaadaa53bfd.json b/backend/.sqlx/query-67227115cc54ff3f8f8c539ea8906d62775fe3f8b68e054db73d1eaadaa53bfd.json new file mode 100644 index 0000000000..8b8abcd8a3 --- /dev/null +++ b/backend/.sqlx/query-67227115cc54ff3f8f8c539ea8906d62775fe3f8b68e054db73d1eaadaa53bfd.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT success AS \"success!\"\n FROM v2_completed_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "success!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "67227115cc54ff3f8f8c539ea8906d62775fe3f8b68e054db73d1eaadaa53bfd" +} diff --git a/backend/.sqlx/query-6bdb3fcfe16fc40222dc7010a11026d4d4e0d381b31fe02da7d2667c0cdc1a85.json b/backend/.sqlx/query-6bdb3fcfe16fc40222dc7010a11026d4d4e0d381b31fe02da7d2667c0cdc1a85.json new file mode 100644 index 0000000000..c498b1790a --- /dev/null +++ b/backend/.sqlx/query-6bdb3fcfe16fc40222dc7010a11026d4d4e0d381b31fe02da7d2667c0cdc1a85.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_completed SET workspace_id = $1 WHERE workspace_id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Text" + ] + }, + "nullable": [] + }, + "hash": "6bdb3fcfe16fc40222dc7010a11026d4d4e0d381b31fe02da7d2667c0cdc1a85" +} diff --git a/backend/.sqlx/query-6cd65694d617ef381e592ef03fbeeb25152c67b2a82c45ee4f64019076b1a167.json b/backend/.sqlx/query-6cd65694d617ef381e592ef03fbeeb25152c67b2a82c45ee4f64019076b1a167.json new file mode 100644 index 0000000000..90ab5ca8ee --- /dev/null +++ b/backend/.sqlx/query-6cd65694d617ef381e592ef03fbeeb25152c67b2a82c45ee4f64019076b1a167.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = flow_status - 'retry'\n WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "6cd65694d617ef381e592ef03fbeeb25152c67b2a82c45ee4f64019076b1a167" +} diff --git a/backend/.sqlx/query-6d5dceb0f6b2fe5287d0f7b158f45182e27141db8c7e2186d80c9948b302d531.json b/backend/.sqlx/query-6d5dceb0f6b2fe5287d0f7b158f45182e27141db8c7e2186d80c9948b302d531.json new file mode 100644 index 0000000000..fa816e300f --- /dev/null +++ b/backend/.sqlx/query-6d5dceb0f6b2fe5287d0f7b158f45182e27141db8c7e2186d80c9948b302d531.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\", flow_status AS \"flow_status!: Json\"\n FROM v2_completed_job\n WHERE parent_job = $1 AND workspace_id = $2 AND flow_status IS NOT NULL", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "flow_status!: Json", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true + ] + }, + "hash": "6d5dceb0f6b2fe5287d0f7b158f45182e27141db8c7e2186d80c9948b302d531" +} diff --git a/backend/.sqlx/query-6f74f8befca28192ff457580922c0991974385350bdc1d9cd11c211269242e70.json b/backend/.sqlx/query-6f74f8befca28192ff457580922c0991974385350bdc1d9cd11c211269242e70.json new file mode 100644 index 0000000000..730045955e --- /dev/null +++ b/backend/.sqlx/query-6f74f8befca28192ff457580922c0991974385350bdc1d9cd11c211269242e70.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue SET args = (select result FROM v2_completed_job WHERE id = $1) WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "6f74f8befca28192ff457580922c0991974385350bdc1d9cd11c211269242e70" +} diff --git a/backend/.sqlx/query-70dc88f1af928fc2046bb216a31c48a94ed020fb9398ed242610a190f809e12f.json b/backend/.sqlx/query-70dc88f1af928fc2046bb216a31c48a94ed020fb9398ed242610a190f809e12f.json new file mode 100644 index 0000000000..34a4ec9df9 --- /dev/null +++ b/backend/.sqlx/query-70dc88f1af928fc2046bb216a31c48a94ed020fb9398ed242610a190f809e12f.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n script_path, args AS \"args: sqlx::types::Json>>\",\n tag AS \"tag!\", priority\n FROM v2_completed_job\n WHERE id = $1 and workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "script_path", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "args: sqlx::types::Json>>", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "tag!", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "priority", + "type_info": "Int2" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true + ] + }, + "hash": "70dc88f1af928fc2046bb216a31c48a94ed020fb9398ed242610a190f809e12f" +} diff --git a/backend/.sqlx/query-7463c1eb3f690239c9277b62d935af4f372c07263c6f86bc89b0d25cb573fa80.json b/backend/.sqlx/query-7463c1eb3f690239c9277b62d935af4f372c07263c6f86bc89b0d25cb573fa80.json new file mode 100644 index 0000000000..77ab2c28bd --- /dev/null +++ b/backend/.sqlx/query-7463c1eb3f690239c9277b62d935af4f372c07263c6f86bc89b0d25cb573fa80.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM v2_job WHERE workspace_id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [] + }, + "hash": "7463c1eb3f690239c9277b62d935af4f372c07263c6f86bc89b0d25cb573fa80" +} diff --git a/backend/.sqlx/query-75011df502302611691a9a332e64daa3ef2610a53a8819d49d356431969975f3.json b/backend/.sqlx/query-75011df502302611691a9a332e64daa3ef2610a53a8819d49d356431969975f3.json new file mode 100644 index 0000000000..ec4f9e1dd8 --- /dev/null +++ b/backend/.sqlx/query-75011df502302611691a9a332e64daa3ef2610a53a8819d49d356431969975f3.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(flow_status, ARRAY['step'], $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "75011df502302611691a9a332e64daa3ef2610a53a8819d49d356431969975f3" +} diff --git a/backend/.sqlx/query-768bf629de97958b8060188ae6ccdde234625202448cc9a2131118975c4e3f31.json b/backend/.sqlx/query-768bf629de97958b8060188ae6ccdde234625202448cc9a2131118975c4e3f31.json new file mode 100644 index 0000000000..d30b280e0a --- /dev/null +++ b/backend/.sqlx/query-768bf629de97958b8060188ae6ccdde234625202448cc9a2131118975c4e3f31.json @@ -0,0 +1,67 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n job_kind AS \"job_kind!: JobKind\",\n script_hash AS \"script_hash: ScriptHash\",\n flow_status AS \"flow_status!: Json>\",\n raw_flow AS \"raw_flow: Json>\"\n FROM v2_queue WHERE id = $1 AND workspace_id = $2 LIMIT 1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "job_kind!: JobKind", + "type_info": { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + } + }, + { + "ordinal": 1, + "name": "script_hash: ScriptHash", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "flow_status!: Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "raw_flow: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true + ] + }, + "hash": "768bf629de97958b8060188ae6ccdde234625202448cc9a2131118975c4e3f31" +} diff --git a/backend/.sqlx/query-786d6618eec56d41be7731f0f07075e03d2f64d826a3817fc74197eb960e35c9.json b/backend/.sqlx/query-786d6618eec56d41be7731f0f07075e03d2f64d826a3817fc74197eb960e35c9.json new file mode 100644 index 0000000000..45107e9721 --- /dev/null +++ b/backend/.sqlx/query-786d6618eec56d41be7731f0f07075e03d2f64d826a3817fc74197eb960e35c9.json @@ -0,0 +1,30 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COALESCE((SELECT MIN(started_at) as min_started_at\n FROM v2_queue\n WHERE script_path = $1 AND job_kind != 'dependencies' AND running = true AND workspace_id = $2 AND canceled = false AND concurrent_limit > 0), $3) as min_started_at, now() AS now", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "min_started_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 1, + "name": "now", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text", + "Text", + "Timestamptz" + ] + }, + "nullable": [ + null, + null + ] + }, + "hash": "786d6618eec56d41be7731f0f07075e03d2f64d826a3817fc74197eb960e35c9" +} diff --git a/backend/.sqlx/query-7907fb4b819090b16d44aefb08bd09e76b97ac5c96f604bdc1dfeb433ac5cffb.json b/backend/.sqlx/query-7907fb4b819090b16d44aefb08bd09e76b97ac5c96f604bdc1dfeb433ac5cffb.json new file mode 100644 index 0000000000..a6d052d5b3 --- /dev/null +++ b/backend/.sqlx/query-7907fb4b819090b16d44aefb08bd09e76b97ac5c96f604bdc1dfeb433ac5cffb.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET running = false\n , started_at = null\n , scheduled_for = $1\n , last_ping = null\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Timestamptz", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "7907fb4b819090b16d44aefb08bd09e76b97ac5c96f604bdc1dfeb433ac5cffb" +} diff --git a/backend/.sqlx/query-7993b4f2d46b0cf56f4cb784237ae8790ce4982a3d619fc50c4a0a2ee368c2e7.json b/backend/.sqlx/query-7993b4f2d46b0cf56f4cb784237ae8790ce4982a3d619fc50c4a0a2ee368c2e7.json new file mode 100644 index 0000000000..6926189c24 --- /dev/null +++ b/backend/.sqlx/query-7993b4f2d46b0cf56f4cb784237ae8790ce4982a3d619fc50c4a0a2ee368c2e7.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT created_by AS \"created_by!\", CONCAT(coalesce(v2_completed_job.logs, ''), coalesce(job_logs.logs, '')) as logs, job_logs.log_offset, job_logs.log_file_index\n FROM v2_completed_job \n LEFT JOIN job_logs ON job_logs.job_id = v2_completed_job.id \n WHERE v2_completed_job.id = $1 AND v2_completed_job.workspace_id = $2 AND ($3::text[] IS NULL OR v2_completed_job.tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "logs", + "type_info": "Text" + }, + { + "ordinal": 2, + "name": "log_offset", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "log_file_index", + "type_info": "TextArray" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + true, + null, + false, + true + ] + }, + "hash": "7993b4f2d46b0cf56f4cb784237ae8790ce4982a3d619fc50c4a0a2ee368c2e7" +} diff --git a/backend/.sqlx/query-7a706906e461df376f5238fd1dda387ab71bc0c9d9ad0c3e7737138adb6cc224.json b/backend/.sqlx/query-7a706906e461df376f5238fd1dda387ab71bc0c9d9ad0c3e7737138adb6cc224.json new file mode 100644 index 0000000000..d1db543ca0 --- /dev/null +++ b/backend/.sqlx/query-7a706906e461df376f5238fd1dda387ab71bc0c9d9ad0c3e7737138adb6cc224.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue SET flow_status = jsonb_set(COALESCE(flow_status, '{}'::jsonb), array[$1], jsonb_set(jsonb_set('{}'::jsonb, '{scheduled_for}', to_jsonb(now()::text)), '{name}', to_jsonb($4::text))) WHERE id = $2 AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Uuid", + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "7a706906e461df376f5238fd1dda387ab71bc0c9d9ad0c3e7737138adb6cc224" +} diff --git a/backend/.sqlx/query-7c7234d8234fbaff4d42eb47d1e1ea1747ffe28986055c01a4661628e47c0e51.json b/backend/.sqlx/query-7c7234d8234fbaff4d42eb47d1e1ea1747ffe28986055c01a4661628e47c0e51.json new file mode 100644 index 0000000000..b1ace4f315 --- /dev/null +++ b/backend/.sqlx/query-7c7234d8234fbaff4d42eb47d1e1ea1747ffe28986055c01a4661628e47c0e51.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_completed SET canceled_by = $1 WHERE canceled_by = $2 AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "7c7234d8234fbaff4d42eb47d1e1ea1747ffe28986055c01a4661628e47c0e51" +} diff --git a/backend/.sqlx/query-7e95417c9bf5812d5c24ff3ffaebd3ec590384ed64dd738302df10a6a783c75f.json b/backend/.sqlx/query-7e95417c9bf5812d5c24ff3ffaebd3ec590384ed64dd738302df10a6a783c75f.json new file mode 100644 index 0000000000..07799d5196 --- /dev/null +++ b/backend/.sqlx/query-7e95417c9bf5812d5c24ff3ffaebd3ec590384ed64dd738302df10a6a783c75f.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(flow_status, ARRAY['preprocessor_module'], $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "7e95417c9bf5812d5c24ff3ffaebd3ec590384ed64dd738302df10a6a783c75f" +} diff --git a/backend/.sqlx/query-7f7feb429e0a7b4540469fb5e8ec532d4e08d5416b0566c34be201e98deab75c.json b/backend/.sqlx/query-7f7feb429e0a7b4540469fb5e8ec532d4e08d5416b0566c34be201e98deab75c.json new file mode 100644 index 0000000000..e9c7d4acd8 --- /dev/null +++ b/backend/.sqlx/query-7f7feb429e0a7b4540469fb5e8ec532d4e08d5416b0566c34be201e98deab75c.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT EXISTS(SELECT 1 FROM v2_completed_job WHERE id = $1 AND workspace_id = $2)", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "exists", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "7f7feb429e0a7b4540469fb5e8ec532d4e08d5416b0566c34be201e98deab75c" +} diff --git a/backend/.sqlx/query-82057acdd9bce4c67598e410dbca062bcfe0d319a330969e4a97fb0a714be923.json b/backend/.sqlx/query-82057acdd9bce4c67598e410dbca062bcfe0d319a330969e4a97fb0a714be923.json new file mode 100644 index 0000000000..1d1526099a --- /dev/null +++ b/backend/.sqlx/query-82057acdd9bce4c67598e410dbca062bcfe0d319a330969e4a97fb0a714be923.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(flow_status, ARRAY['failure_module'], $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "82057acdd9bce4c67598e410dbca062bcfe0d319a330969e4a97fb0a714be923" +} diff --git a/backend/.sqlx/query-8381cee8bec06f8eff847b22d25574fc2cbcb32fef9f44632a8bc4c5c487fc4f.json b/backend/.sqlx/query-8381cee8bec06f8eff847b22d25574fc2cbcb32fef9f44632a8bc4c5c487fc4f.json new file mode 100644 index 0000000000..0a5c7ae2c8 --- /dev/null +++ b/backend/.sqlx/query-8381cee8bec06f8eff847b22d25574fc2cbcb32fef9f44632a8bc4c5c487fc4f.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM v2_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "args", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "Bool" + ] + }, + "nullable": [ + null + ] + }, + "hash": "8381cee8bec06f8eff847b22d25574fc2cbcb32fef9f44632a8bc4c5c487fc4f" +} diff --git a/backend/.sqlx/query-8440081df15fa7874dded86b8af572d971d5892b7dd4c8e824b953113bd6c4a9.json b/backend/.sqlx/query-8440081df15fa7874dded86b8af572d971d5892b7dd4c8e824b953113bd6c4a9.json new file mode 100644 index 0000000000..4a7ebbc0f7 --- /dev/null +++ b/backend/.sqlx/query-8440081df15fa7874dded86b8af572d971d5892b7dd4c8e824b953113bd6c4a9.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT parent_job\n FROM v2_job\n WHERE id = $1 AND workspace_id = $2\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "parent_job", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "8440081df15fa7874dded86b8af572d971d5892b7dd4c8e824b953113bd6c4a9" +} diff --git a/backend/.sqlx/query-8512298656d6872a2123c2801d842119537374a815c1292fac4c5b75bdd58898.json b/backend/.sqlx/query-8512298656d6872a2123c2801d842119537374a815c1292fac4c5b75bdd58898.json new file mode 100644 index 0000000000..8390708116 --- /dev/null +++ b/backend/.sqlx/query-8512298656d6872a2123c2801d842119537374a815c1292fac4c5b75bdd58898.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET runnable_path = REGEXP_REPLACE(runnable_path,'u/' || $2 || '/(.*)','u/' || $1 || '/\\1') WHERE runnable_path LIKE ('u/' || $2 || '/%') AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "8512298656d6872a2123c2801d842119537374a815c1292fac4c5b75bdd58898" +} diff --git a/backend/.sqlx/query-867a864a81c9d649acc13c6c91b1c63c345d443ce636114e30ad6a0da464aa50.json b/backend/.sqlx/query-867a864a81c9d649acc13c6c91b1c63c345d443ce636114e30ad6a0da464aa50.json new file mode 100644 index 0000000000..2a48be3e97 --- /dev/null +++ b/backend/.sqlx/query-867a864a81c9d649acc13c6c91b1c63c345d443ce636114e30ad6a0da464aa50.json @@ -0,0 +1,25 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE v2_queue SET flow_status = JSONB_SET(flow_status, ARRAY['user_states'], JSONB_SET(COALESCE(flow_status->'user_states', '{}'::jsonb), ARRAY[$1], $2))\n WHERE id = $3 AND workspace_id = $4 AND job_kind IN ('flow', 'flowpreview', 'flownode') RETURNING 1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Text", + "Jsonb", + "Uuid", + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "867a864a81c9d649acc13c6c91b1c63c345d443ce636114e30ad6a0da464aa50" +} diff --git a/backend/.sqlx/query-86d5b121a8ae458ae3b050ecf6e3f82368534b77d3720200cb90829b03b55595.json b/backend/.sqlx/query-86d5b121a8ae458ae3b050ecf6e3f82368534b77d3720200cb90829b03b55595.json new file mode 100644 index 0000000000..95e8f1c24a --- /dev/null +++ b/backend/.sqlx/query-86d5b121a8ae458ae3b050ecf6e3f82368534b77d3720200cb90829b03b55595.json @@ -0,0 +1,70 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n result #> $3 AS \"result: sqlx::types::Json>\",\n flow_status AS \"flow_status: sqlx::types::Json>\",\n language AS \"language: ScriptLang\",\n created_by AS \"created_by!\"\n FROM v2_completed_job\n WHERE id = $1 AND workspace_id = $2 AND ($4::text[] IS NULL OR tag = ANY($4))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "flow_status: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "language: ScriptLang", + "type_info": { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + } + }, + { + "ordinal": 3, + "name": "created_by!", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray", + "TextArray" + ] + }, + "nullable": [ + null, + true, + true, + true + ] + }, + "hash": "86d5b121a8ae458ae3b050ecf6e3f82368534b77d3720200cb90829b03b55595" +} diff --git a/backend/.sqlx/query-86e730a3481868a8d63824904df42788dd8a777d643d46d5086b5f8f33bbc97e.json b/backend/.sqlx/query-86e730a3481868a8d63824904df42788dd8a777d643d46d5086b5f8f33bbc97e.json new file mode 100644 index 0000000000..70406daddd --- /dev/null +++ b/backend/.sqlx/query-86e730a3481868a8d63824904df42788dd8a777d643d46d5086b5f8f33bbc97e.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "VACUUM (skip_locked) v2_job_queue, v2_job_runtime, v2_job_flow_runtime", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "86e730a3481868a8d63824904df42788dd8a777d643d46d5086b5f8f33bbc97e" +} diff --git a/backend/.sqlx/query-8995f08b2e3097b21bfc519d0b89181ff9fd37e4f716de4b52e5a5960b8e6d30.json b/backend/.sqlx/query-8995f08b2e3097b21bfc519d0b89181ff9fd37e4f716de4b52e5a5960b8e6d30.json new file mode 100644 index 0000000000..6946d2774b --- /dev/null +++ b/backend/.sqlx/query-8995f08b2e3097b21bfc519d0b89181ff9fd37e4f716de4b52e5a5960b8e6d30.json @@ -0,0 +1,25 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(\n JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'flow_jobs_success', $3::TEXT], $4),\n ARRAY['modules', $1::TEXT, 'iterator', 'index'],\n ((flow_status->'modules'->$1::int->'iterator'->>'index')::int + 1)::text::jsonb\n ),\n last_ping = NULL\n WHERE id = $2\n RETURNING (flow_status->'modules'->$1::int->'iterator'->>'index')::int", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "int4", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Int4", + "Uuid", + "Text", + "Jsonb" + ] + }, + "nullable": [ + null + ] + }, + "hash": "8995f08b2e3097b21bfc519d0b89181ff9fd37e4f716de4b52e5a5960b8e6d30" +} diff --git a/backend/.sqlx/query-8a5e36ed9dcc1712ec9b8ebc26cd76eab45b172da907b40fc87c6300944a0108.json b/backend/.sqlx/query-8a5e36ed9dcc1712ec9b8ebc26cd76eab45b172da907b40fc87c6300944a0108.json new file mode 100644 index 0000000000..4a0022b5c0 --- /dev/null +++ b/backend/.sqlx/query-8a5e36ed9dcc1712ec9b8ebc26cd76eab45b172da907b40fc87c6300944a0108.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue SET suspend = 0 WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "8a5e36ed9dcc1712ec9b8ebc26cd76eab45b172da907b40fc87c6300944a0108" +} diff --git a/backend/.sqlx/query-8b244ce1a4ff15ed50163b9b48cb92bb5bba659766d44ad769a9f36ad905627a.json b/backend/.sqlx/query-8b244ce1a4ff15ed50163b9b48cb92bb5bba659766d44ad769a9f36ad905627a.json new file mode 100644 index 0000000000..ec1068258c --- /dev/null +++ b/backend/.sqlx/query-8b244ce1a4ff15ed50163b9b48cb92bb5bba659766d44ad769a9f36ad905627a.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM v2_queue WHERE workspace_id = $1 AND id = $2 RETURNING 1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Text", + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "8b244ce1a4ff15ed50163b9b48cb92bb5bba659766d44ad769a9f36ad905627a" +} diff --git a/backend/.sqlx/query-8b882b7bb74443972929e0805d4f1adb0555ab8caf7240fa97c1d4da55e6cc95.json b/backend/.sqlx/query-8b882b7bb74443972929e0805d4f1adb0555ab8caf7240fa97c1d4da55e6cc95.json new file mode 100644 index 0000000000..bb24c3f5ae --- /dev/null +++ b/backend/.sqlx/query-8b882b7bb74443972929e0805d4f1adb0555ab8caf7240fa97c1d4da55e6cc95.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT CAST(ROUND(AVG(duration_ms), 0) AS BIGINT) AS avg_duration_s FROM\n (SELECT duration_ms FROM concurrency_key LEFT JOIN v2_completed_job ON v2_completed_job.id = concurrency_key.job_id WHERE key = $1 AND ended_at IS NOT NULL\n ORDER BY ended_at\n DESC LIMIT 10) AS t", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "avg_duration_s", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "8b882b7bb74443972929e0805d4f1adb0555ab8caf7240fa97c1d4da55e6cc95" +} diff --git a/backend/.sqlx/query-8d0b19f20452acb51a2ddaa1aca69b6d7287ca0b19cc2b400511434e7f57be07.json b/backend/.sqlx/query-8d0b19f20452acb51a2ddaa1aca69b6d7287ca0b19cc2b400511434e7f57be07.json new file mode 100644 index 0000000000..dcd01c4834 --- /dev/null +++ b/backend/.sqlx/query-8d0b19f20452acb51a2ddaa1aca69b6d7287ca0b19cc2b400511434e7f57be07.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(flow_status, ARRAY['cleanup_module', 'flow_jobs_to_clean'], COALESCE(flow_status->'cleanup_module'->'flow_jobs_to_clean', '[]'::jsonb) || $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "8d0b19f20452acb51a2ddaa1aca69b6d7287ca0b19cc2b400511434e7f57be07" +} diff --git a/backend/.sqlx/query-8d368d944beb43e0e8c32e83fe2bad5ff2221cde22000da636e7e33e7db6ddce.json b/backend/.sqlx/query-8d368d944beb43e0e8c32e83fe2bad5ff2221cde22000da636e7e33e7db6ddce.json new file mode 100644 index 0000000000..5a8c755632 --- /dev/null +++ b/backend/.sqlx/query-8d368d944beb43e0e8c32e83fe2bad5ff2221cde22000da636e7e33e7db6ddce.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_completed_job SET args = '{\"reason\":\"PREPROCESSOR_ARGS_ARE_DISCARDED\"}'::jsonb WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "8d368d944beb43e0e8c32e83fe2bad5ff2221cde22000da636e7e33e7db6ddce" +} diff --git a/backend/.sqlx/query-8d3ded447c42747c9018053a068eec9c80e7fb29102a046792673c42f463c076.json b/backend/.sqlx/query-8d3ded447c42747c9018053a068eec9c80e7fb29102a046792673c42f463c076.json new file mode 100644 index 0000000000..c94fae87ec --- /dev/null +++ b/backend/.sqlx/query-8d3ded447c42747c9018053a068eec9c80e7fb29102a046792673c42f463c076.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = jsonb_set(\n jsonb_set(flow_status, ARRAY['failure_module', 'job'], to_jsonb($1::UUID::TEXT)),\n ARRAY['failure_module', 'type'],\n to_jsonb('InProgress'::text)\n )\n WHERE id = $2 AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Text" + ] + }, + "nullable": [] + }, + "hash": "8d3ded447c42747c9018053a068eec9c80e7fb29102a046792673c42f463c076" +} diff --git a/backend/.sqlx/query-8e2a03ebe1311e98b855a57693deaa210c01d980065864e5439ee726cf1f9bef.json b/backend/.sqlx/query-8e2a03ebe1311e98b855a57693deaa210c01d980065864e5439ee726cf1f9bef.json new file mode 100644 index 0000000000..4d50f9e1df --- /dev/null +++ b/backend/.sqlx/query-8e2a03ebe1311e98b855a57693deaa210c01d980065864e5439ee726cf1f9bef.json @@ -0,0 +1,75 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n result AS \"result: sqlx::types::Json>\", success AS \"success!\",\n language AS \"language: ScriptLang\",\n flow_status AS \"flow_status: sqlx::types::Json>\",\n created_by AS \"created_by!\"\n FROM v2_completed_job\n WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "success!", + "type_info": "Bool" + }, + { + "ordinal": 2, + "name": "language: ScriptLang", + "type_info": { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + } + }, + { + "ordinal": 3, + "name": "flow_status: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "created_by!", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + true, + true, + true, + true, + true + ] + }, + "hash": "8e2a03ebe1311e98b855a57693deaa210c01d980065864e5439ee726cf1f9bef" +} diff --git a/backend/.sqlx/query-902a16d9e7ac34e7f1a0ad633bae754a0d64bc934a2b6434b9cb67f28d3ef950.json b/backend/.sqlx/query-902a16d9e7ac34e7f1a0ad633bae754a0d64bc934a2b6434b9cb67f28d3ef950.json new file mode 100644 index 0000000000..7a6d47ba81 --- /dev/null +++ b/backend/.sqlx/query-902a16d9e7ac34e7f1a0ad633bae754a0d64bc934a2b6434b9cb67f28d3ef950.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_queue SET canceled_by = $1 WHERE canceled_by = $2 AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "902a16d9e7ac34e7f1a0ad633bae754a0d64bc934a2b6434b9cb67f28d3ef950" +} diff --git a/backend/.sqlx/query-90d1c1ed47f1a9186cdde2f720fe86cde5ffefb4578d6e091855bc7a4e94d1b0.json b/backend/.sqlx/query-90d1c1ed47f1a9186cdde2f720fe86cde5ffefb4578d6e091855bc7a4e94d1b0.json new file mode 100644 index 0000000000..259d59e3ea --- /dev/null +++ b/backend/.sqlx/query-90d1c1ed47f1a9186cdde2f720fe86cde5ffefb4578d6e091855bc7a4e94d1b0.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO script (\n summary, description, dedicated_worker, content, workspace_id, path, hash,\n language, tag, created_by, lock\n ) VALUES ('', '', true, $1, $2, $3, $4, $5, $6, $7, '')\n ON CONFLICT (workspace_id, hash) DO NOTHING", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Varchar", + "Varchar", + "Int8", + { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + }, + "Varchar", + "Varchar" + ] + }, + "nullable": [] + }, + "hash": "90d1c1ed47f1a9186cdde2f720fe86cde5ffefb4578d6e091855bc7a4e94d1b0" +} diff --git a/backend/.sqlx/query-95d12525781746a0deb60572242366471a2945c4470712f512b5f82b12312109.json b/backend/.sqlx/query-95d12525781746a0deb60572242366471a2945c4470712f512b5f82b12312109.json new file mode 100644 index 0000000000..bddbb520a0 --- /dev/null +++ b/backend/.sqlx/query-95d12525781746a0deb60572242366471a2945c4470712f512b5f82b12312109.json @@ -0,0 +1,91 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n v2_queue.job_kind AS \"job_kind!: JobKind\",\n v2_queue.script_hash AS \"script_hash: ScriptHash\",\n v2_queue.raw_flow AS \"raw_flow: sqlx::types::Json>\",\n v2_completed_job.parent_job AS \"parent_job: Uuid\",\n v2_completed_job.created_at AS \"created_at!: chrono::NaiveDateTime\",\n v2_completed_job.created_by AS \"created_by!\",\n v2_queue.script_path,\n v2_queue.args AS \"args: sqlx::types::Json>\"\n FROM v2_queue\n JOIN v2_completed_job ON v2_completed_job.parent_job = v2_queue.id\n WHERE v2_completed_job.id = $1 AND v2_completed_job.workspace_id = $2\n LIMIT 1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "job_kind!: JobKind", + "type_info": { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + } + }, + { + "ordinal": 1, + "name": "script_hash: ScriptHash", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "raw_flow: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "parent_job: Uuid", + "type_info": "Uuid" + }, + { + "ordinal": 4, + "name": "created_at!: chrono::NaiveDateTime", + "type_info": "Timestamptz" + }, + { + "ordinal": 5, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 6, + "name": "script_path", + "type_info": "Varchar" + }, + { + "ordinal": 7, + "name": "args: sqlx::types::Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true, + true, + true, + true, + true + ] + }, + "hash": "95d12525781746a0deb60572242366471a2945c4470712f512b5f82b12312109" +} diff --git a/backend/.sqlx/query-971a9eeb3d20be893655d972d51c0dd85ca930a5a725e8c6a0682b2dcc7f8a0e.json b/backend/.sqlx/query-971a9eeb3d20be893655d972d51c0dd85ca930a5a725e8c6a0682b2dcc7f8a0e.json new file mode 100644 index 0000000000..f841dcedb1 --- /dev/null +++ b/backend/.sqlx/query-971a9eeb3d20be893655d972d51c0dd85ca930a5a725e8c6a0682b2dcc7f8a0e.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(\n JSONB_SET(flow_status, ARRAY['failure_module'], $1), ARRAY['step'], $2)\n WHERE id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "971a9eeb3d20be893655d972d51c0dd85ca930a5a725e8c6a0682b2dcc7f8a0e" +} diff --git a/backend/.sqlx/query-979549eec044480a4d8d21a22530178c73c6102f22971e6ce67b1b4473bc8c6f.json b/backend/.sqlx/query-979549eec044480a4d8d21a22530178c73c6102f22971e6ce67b1b4473bc8c6f.json new file mode 100644 index 0000000000..e5d1ab2cca --- /dev/null +++ b/backend/.sqlx/query-979549eec044480a4d8d21a22530178c73c6102f22971e6ce67b1b4473bc8c6f.json @@ -0,0 +1,71 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n email AS \"email!\",\n created_by AS \"created_by!\",\n parent_job, permissioned_as AS \"permissioned_as!\",\n script_path, schedule_path, flow_step_id, root_job,\n scheduled_for AS \"scheduled_for!: chrono::DateTime\"\n FROM v2_queue WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "email!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "parent_job", + "type_info": "Uuid" + }, + { + "ordinal": 3, + "name": "permissioned_as!", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "script_path", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "schedule_path", + "type_info": "Varchar" + }, + { + "ordinal": 6, + "name": "flow_step_id", + "type_info": "Varchar" + }, + { + "ordinal": 7, + "name": "root_job", + "type_info": "Uuid" + }, + { + "ordinal": 8, + "name": "scheduled_for!: chrono::DateTime", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true, + true, + true, + true, + true, + true + ] + }, + "hash": "979549eec044480a4d8d21a22530178c73c6102f22971e6ce67b1b4473bc8c6f" +} diff --git a/backend/.sqlx/query-992ebe3a73d0bd3b2122c08ca41b2d2deae208d7e95dd7d39884b7058a0512ff.json b/backend/.sqlx/query-992ebe3a73d0bd3b2122c08ca41b2d2deae208d7e95dd7d39884b7058a0512ff.json new file mode 100644 index 0000000000..16e45505b8 --- /dev/null +++ b/backend/.sqlx/query-992ebe3a73d0bd3b2122c08ca41b2d2deae208d7e95dd7d39884b7058a0512ff.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO v2_job_flow_runtime (id, flow_status) SELECT unnest($1::uuid[]), $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "UuidArray", + "Jsonb" + ] + }, + "nullable": [] + }, + "hash": "992ebe3a73d0bd3b2122c08ca41b2d2deae208d7e95dd7d39884b7058a0512ff" +} diff --git a/backend/.sqlx/query-9a90bbbb2cb5e99bdfdc475fbf80569807fb3690b008028c9a78b0ed56928a37.json b/backend/.sqlx/query-9a90bbbb2cb5e99bdfdc475fbf80569807fb3690b008028c9a78b0ed56928a37.json new file mode 100644 index 0000000000..ffcee2afe7 --- /dev/null +++ b/backend/.sqlx/query-9a90bbbb2cb5e99bdfdc475fbf80569807fb3690b008028c9a78b0ed56928a37.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id as \"id!\" FROM v2_queue WHERE workspace_id = $1 AND script_path = $2 AND canceled = false", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Text", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "9a90bbbb2cb5e99bdfdc475fbf80569807fb3690b008028c9a78b0ed56928a37" +} diff --git a/backend/.sqlx/query-9b2c42327378963b16eec5037537b8d9ae95c194b201bd1ce1d8f90925d7dba8.json b/backend/.sqlx/query-9b2c42327378963b16eec5037537b8d9ae95c194b201bd1ce1d8f90925d7dba8.json new file mode 100644 index 0000000000..e73b49d4b0 --- /dev/null +++ b/backend/.sqlx/query-9b2c42327378963b16eec5037537b8d9ae95c194b201bd1ce1d8f90925d7dba8.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET permissioned_as = ('u/' || $1) WHERE permissioned_as = ('u/' || $2) AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "9b2c42327378963b16eec5037537b8d9ae95c194b201bd1ce1d8f90925d7dba8" +} diff --git a/backend/.sqlx/query-9e3985087c66b5bf64a48f4f77409b889a584d03f12b8189c3e817b06ee4b459.json b/backend/.sqlx/query-9e3985087c66b5bf64a48f4f77409b889a584d03f12b8189c3e817b06ee4b459.json new file mode 100644 index 0000000000..9d63b24a7b --- /dev/null +++ b/backend/.sqlx/query-9e3985087c66b5bf64a48f4f77409b889a584d03f12b8189c3e817b06ee4b459.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue SET canceled = true WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "9e3985087c66b5bf64a48f4f77409b889a584d03f12b8189c3e817b06ee4b459" +} diff --git a/backend/.sqlx/query-a0c35cb515a842067b294343c90f1bfbe4e2db85da9a478a07460733999e9beb.json b/backend/.sqlx/query-a0c35cb515a842067b294343c90f1bfbe4e2db85da9a478a07460733999e9beb.json new file mode 100644 index 0000000000..298a66c89c --- /dev/null +++ b/backend/.sqlx/query-a0c35cb515a842067b294343c90f1bfbe4e2db85da9a478a07460733999e9beb.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT count(*) AS \"count!\" FROM resume_job", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + null + ] + }, + "hash": "a0c35cb515a842067b294343c90f1bfbe4e2db85da9a478a07460733999e9beb" +} diff --git a/backend/.sqlx/query-a1eae6af90a6ee03b86fb1b96224c14ff1c98d08d22185e7db9fb042c2d95f97.json b/backend/.sqlx/query-a1eae6af90a6ee03b86fb1b96224c14ff1c98d08d22185e7db9fb042c2d95f97.json new file mode 100644 index 0000000000..08282518d2 --- /dev/null +++ b/backend/.sqlx/query-a1eae6af90a6ee03b86fb1b96224c14ff1c98d08d22185e7db9fb042c2d95f97.json @@ -0,0 +1,54 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n running AS \"running!\",\n substr(concat(coalesce(v2_queue.logs, ''), job_logs.logs), greatest($1 - job_logs.log_offset, 0)) AS logs,\n mem_peak,\n CASE WHEN is_flow_step is true then NULL else flow_status END AS \"flow_status: sqlx::types::Json>\",\n job_logs.log_offset + char_length(job_logs.logs) + 1 AS log_offset,\n created_by AS \"created_by!\"\n FROM v2_queue\n LEFT JOIN job_logs ON job_logs.job_id = v2_queue.id \n WHERE v2_queue.workspace_id = $2 AND v2_queue.id = $3", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "running!", + "type_info": "Bool" + }, + { + "ordinal": 1, + "name": "logs", + "type_info": "Text" + }, + { + "ordinal": 2, + "name": "mem_peak", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "flow_status: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "log_offset", + "type_info": "Int4" + }, + { + "ordinal": 5, + "name": "created_by!", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Int4", + "Text", + "Uuid" + ] + }, + "nullable": [ + true, + null, + true, + null, + null, + true + ] + }, + "hash": "a1eae6af90a6ee03b86fb1b96224c14ff1c98d08d22185e7db9fb042c2d95f97" +} diff --git a/backend/.sqlx/query-a2b7d364705468bd9dfb8f10e0bcc151604feae83d4671dfb9ca77eb8fd8d4f1.json b/backend/.sqlx/query-a2b7d364705468bd9dfb8f10e0bcc151604feae83d4671dfb9ca77eb8fd8d4f1.json new file mode 100644 index 0000000000..fffd61d360 --- /dev/null +++ b/backend/.sqlx/query-a2b7d364705468bd9dfb8f10e0bcc151604feae83d4671dfb9ca77eb8fd8d4f1.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM v2_job_completed WHERE workspace_id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [] + }, + "hash": "a2b7d364705468bd9dfb8f10e0bcc151604feae83d4671dfb9ca77eb8fd8d4f1" +} diff --git a/backend/.sqlx/query-a3ef2d382a5584d47915296c131947b1d235325f4e6f6cb32e51f9c97a0c6285.json b/backend/.sqlx/query-a3ef2d382a5584d47915296c131947b1d235325f4e6f6cb32e51f9c97a0c6285.json new file mode 100644 index 0000000000..3c5a32c66c --- /dev/null +++ b/backend/.sqlx/query-a3ef2d382a5584d47915296c131947b1d235325f4e6f6cb32e51f9c97a0c6285.json @@ -0,0 +1,25 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(\n JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'flow_jobs_success', $3::TEXT], $4),\n ARRAY['modules', $1::TEXT, 'branchall', 'branch'], ((flow_status->'modules'->$1::int->'branchall'->>'branch')::int + 1)::text::jsonb),\n last_ping = NULL\n WHERE id = $2\n RETURNING (flow_status->'modules'->$1::int->'branchall'->>'branch')::int", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "int4", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Int4", + "Uuid", + "Text", + "Jsonb" + ] + }, + "nullable": [ + null + ] + }, + "hash": "a3ef2d382a5584d47915296c131947b1d235325f4e6f6cb32e51f9c97a0c6285" +} diff --git a/backend/.sqlx/query-a49314e28fc285aac3a73bf4c5689c90f5fcf2905da0356fd015d9e9e9de6004.json b/backend/.sqlx/query-a49314e28fc285aac3a73bf4c5689c90f5fcf2905da0356fd015d9e9e9de6004.json new file mode 100644 index 0000000000..d18e9d9606 --- /dev/null +++ b/backend/.sqlx/query-a49314e28fc285aac3a73bf4c5689c90f5fcf2905da0356fd015d9e9e9de6004.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\" FROM v2_queue WHERE parent_job = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "a49314e28fc285aac3a73bf4c5689c90f5fcf2905da0356fd015d9e9e9de6004" +} diff --git a/backend/.sqlx/query-a4ebd27fad738b9320d1a2b4b3674aba094562f2c353f1cefe3af8c0d04d4687.json b/backend/.sqlx/query-a4ebd27fad738b9320d1a2b4b3674aba094562f2c353f1cefe3af8c0d04d4687.json new file mode 100644 index 0000000000..7f19c49cee --- /dev/null +++ b/backend/.sqlx/query-a4ebd27fad738b9320d1a2b4b3674aba094562f2c353f1cefe3af8c0d04d4687.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(id) FROM v2_queue WHERE workspace_id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "a4ebd27fad738b9320d1a2b4b3674aba094562f2c353f1cefe3af8c0d04d4687" +} diff --git a/backend/.sqlx/query-a4f55c2450e5bd55aaf2bc4348c3a72efddae2bda30fe27d3359ce848d6ffc98.json b/backend/.sqlx/query-a4f55c2450e5bd55aaf2bc4348c3a72efddae2bda30fe27d3359ce848d6ffc98.json new file mode 100644 index 0000000000..21fe2cc3ce --- /dev/null +++ b/backend/.sqlx/query-a4f55c2450e5bd55aaf2bc4348c3a72efddae2bda30fe27d3359ce848d6ffc98.json @@ -0,0 +1,38 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n success AS \"success!\",\n result AS \"result: Json>\",\n started_at AS \"started_at!\"\n FROM v2_completed_job\n WHERE workspace_id = $1 AND schedule_path = $2 AND script_path = $3 AND id != $4\n ORDER BY created_at DESC\n LIMIT $5", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "success!", + "type_info": "Bool" + }, + { + "ordinal": 1, + "name": "result: Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "started_at!", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text", + "Text", + "Text", + "Uuid", + "Int8" + ] + }, + "nullable": [ + true, + true, + true + ] + }, + "hash": "a4f55c2450e5bd55aaf2bc4348c3a72efddae2bda30fe27d3359ce848d6ffc98" +} diff --git a/backend/.sqlx/query-aaacf51f3a43617b60e4253549ec4cc6a3648992b590c6e0121e4d7434da516b.json b/backend/.sqlx/query-aaacf51f3a43617b60e4253549ec4cc6a3648992b590c6e0121e4d7434da516b.json new file mode 100644 index 0000000000..5ce9a0ea5b --- /dev/null +++ b/backend/.sqlx/query-aaacf51f3a43617b60e4253549ec4cc6a3648992b590c6e0121e4d7434da516b.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET created_by = $1 WHERE created_by = $2 AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "aaacf51f3a43617b60e4253549ec4cc6a3648992b590c6e0121e4d7434da516b" +} diff --git a/backend/.sqlx/query-ab093b3bef1cd60395cc763bfdb538590334508a4f6cdbbf759ee1e3a099bda4.json b/backend/.sqlx/query-ab093b3bef1cd60395cc763bfdb538590334508a4f6cdbbf759ee1e3a099bda4.json new file mode 100644 index 0000000000..94181f2a4d --- /dev/null +++ b/backend/.sqlx/query-ab093b3bef1cd60395cc763bfdb538590334508a4f6cdbbf759ee1e3a099bda4.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT flow_status->'user_states'->$1\n FROM v2_queue\n WHERE id = $2 AND workspace_id = $3\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Text", + "Uuid", + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "ab093b3bef1cd60395cc763bfdb538590334508a4f6cdbbf759ee1e3a099bda4" +} diff --git a/backend/.sqlx/query-afc40924751740054bd9a02f4fad4eaa2ed964088f4f35a1f74f912867819bc8.json b/backend/.sqlx/query-afc40924751740054bd9a02f4fad4eaa2ed964088f4f35a1f74f912867819bc8.json new file mode 100644 index 0000000000..0ba28d2b3e --- /dev/null +++ b/backend/.sqlx/query-afc40924751740054bd9a02f4fad4eaa2ed964088f4f35a1f74f912867819bc8.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(flow_status, ARRAY['approval_conditions'], $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "afc40924751740054bd9a02f4fad4eaa2ed964088f4f35a1f74f912867819bc8" +} diff --git a/backend/.sqlx/query-b41c93f22d5fd5813c24b34e28dfcc072a09c9d7624978b866a2e6c09b6f7422.json b/backend/.sqlx/query-b41c93f22d5fd5813c24b34e28dfcc072a09c9d7624978b866a2e6c09b6f7422.json new file mode 100644 index 0000000000..641cc1971c --- /dev/null +++ b/backend/.sqlx/query-b41c93f22d5fd5813c24b34e28dfcc072a09c9d7624978b866a2e6c09b6f7422.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE v2_queue \n SET last_ping = now()\n , mem_peak = $1\n WHERE id = $2\n RETURNING canceled AS \"canceled!\"\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "canceled!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Int4", + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "b41c93f22d5fd5813c24b34e28dfcc072a09c9d7624978b866a2e6c09b6f7422" +} diff --git a/backend/.sqlx/query-b4900c683bffc10b9cbd035208ad26c89cb78e4c877fd161073beadfa9c9251e.json b/backend/.sqlx/query-b4900c683bffc10b9cbd035208ad26c89cb78e4c877fd161073beadfa9c9251e.json new file mode 100644 index 0000000000..76a10ae529 --- /dev/null +++ b/backend/.sqlx/query-b4900c683bffc10b9cbd035208ad26c89cb78e4c877fd161073beadfa9c9251e.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'approvers'], $2)\n WHERE id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "b4900c683bffc10b9cbd035208ad26c89cb78e4c877fd161073beadfa9c9251e" +} diff --git a/backend/.sqlx/query-b4a9abcb38997587b28655b0f4a212a5bd4039b57fab20b163617e33a4c9dd46.json b/backend/.sqlx/query-b4a9abcb38997587b28655b0f4a212a5bd4039b57fab20b163617e33a4c9dd46.json new file mode 100644 index 0000000000..a49baeefaf --- /dev/null +++ b/backend/.sqlx/query-b4a9abcb38997587b28655b0f4a212a5bd4039b57fab20b163617e33a4c9dd46.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO v2_job_runtime (id) SELECT unnest($1::uuid[])", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "UuidArray" + ] + }, + "nullable": [] + }, + "hash": "b4a9abcb38997587b28655b0f4a212a5bd4039b57fab20b163617e33a4c9dd46" +} diff --git a/backend/.sqlx/query-b544bb25abf9562738851c25711275a7027a5936539d766ecffeed13eb0e2fc3.json b/backend/.sqlx/query-b544bb25abf9562738851c25711275a7027a5936539d766ecffeed13eb0e2fc3.json new file mode 100644 index 0000000000..48e072973f --- /dev/null +++ b/backend/.sqlx/query-b544bb25abf9562738851c25711275a7027a5936539d766ecffeed13eb0e2fc3.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT args AS \"args: Json>>\"\n FROM v2_completed_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "args: Json>>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "b544bb25abf9562738851c25711275a7027a5936539d766ecffeed13eb0e2fc3" +} diff --git a/backend/.sqlx/query-b86590a0f3825889b930f584eba074b76e008f0acdd13720c84e987e8f7fc710.json b/backend/.sqlx/query-b86590a0f3825889b930f584eba074b76e008f0acdd13720c84e987e8f7fc710.json new file mode 100644 index 0000000000..9f5ef95947 --- /dev/null +++ b/backend/.sqlx/query-b86590a0f3825889b930f584eba074b76e008f0acdd13720c84e987e8f7fc710.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(*) FROM v2_queue LEFT JOIN concurrency_key ON concurrency_key.job_id = v2_queue.id\n WHERE key = $1 AND running = false AND canceled = false AND scheduled_for >= $2 AND scheduled_for < $3", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text", + "Timestamptz", + "Timestamptz" + ] + }, + "nullable": [ + null + ] + }, + "hash": "b86590a0f3825889b930f584eba074b76e008f0acdd13720c84e987e8f7fc710" +} diff --git a/backend/.sqlx/query-bba2f9b0ae5024c4cd3522eeb56c528b709e47f628266a020a1e04db2facd6d7.json b/backend/.sqlx/query-bba2f9b0ae5024c4cd3522eeb56c528b709e47f628266a020a1e04db2facd6d7.json new file mode 100644 index 0000000000..09f6347fb9 --- /dev/null +++ b/backend/.sqlx/query-bba2f9b0ae5024c4cd3522eeb56c528b709e47f628266a020a1e04db2facd6d7.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(id) FROM v2_queue WHERE email = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "bba2f9b0ae5024c4cd3522eeb56c528b709e47f628266a020a1e04db2facd6d7" +} diff --git a/backend/.sqlx/query-bedfb7153d8fcc936263372cc0001cd68b7bad0e5604d016ddc3e293ef5fd70e.json b/backend/.sqlx/query-bedfb7153d8fcc936263372cc0001cd68b7bad0e5604d016ddc3e293ef5fd70e.json new file mode 100644 index 0000000000..80810625be --- /dev/null +++ b/backend/.sqlx/query-bedfb7153d8fcc936263372cc0001cd68b7bad0e5604d016ddc3e293ef5fd70e.json @@ -0,0 +1,30 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT created_by AS \"created_by!\", args as \"args: sqlx::types::Json>\"\n FROM v2_completed_job \n WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "args: sqlx::types::Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + true, + true + ] + }, + "hash": "bedfb7153d8fcc936263372cc0001cd68b7bad0e5604d016ddc3e293ef5fd70e" +} diff --git a/backend/.sqlx/query-c03b4c5878bd0a0c545cb66b146d0b6ceae9de456d3ddb6008707589dbe30747.json b/backend/.sqlx/query-c03b4c5878bd0a0c545cb66b146d0b6ceae9de456d3ddb6008707589dbe30747.json new file mode 100644 index 0000000000..5cb05f49a0 --- /dev/null +++ b/backend/.sqlx/query-c03b4c5878bd0a0c545cb66b146d0b6ceae9de456d3ddb6008707589dbe30747.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT 1 FROM v2_job WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "c03b4c5878bd0a0c545cb66b146d0b6ceae9de456d3ddb6008707589dbe30747" +} diff --git a/backend/.sqlx/query-c2f2ae011a42a1d4d9f29d34e4c7ea70e3bff866a6f566c768408b5f527bef27.json b/backend/.sqlx/query-c2f2ae011a42a1d4d9f29d34e4c7ea70e3bff866a6f566c768408b5f527bef27.json new file mode 100644 index 0000000000..8417e24d02 --- /dev/null +++ b/backend/.sqlx/query-c2f2ae011a42a1d4d9f29d34e4c7ea70e3bff866a6f566c768408b5f527bef27.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT suspend > 0 AS \"r!\" FROM v2_queue WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "r!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "c2f2ae011a42a1d4d9f29d34e4c7ea70e3bff866a6f566c768408b5f527bef27" +} diff --git a/backend/.sqlx/query-c33664546c6114d04bfaeaeb5215057e2e03053a71440559d0806d4aca258797.json b/backend/.sqlx/query-c33664546c6114d04bfaeaeb5215057e2e03053a71440559d0806d4aca258797.json new file mode 100644 index 0000000000..3f9db2b73e --- /dev/null +++ b/backend/.sqlx/query-c33664546c6114d04bfaeaeb5215057e2e03053a71440559d0806d4aca258797.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(flow_status, ARRAY['retry'], $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "c33664546c6114d04bfaeaeb5215057e2e03053a71440559d0806d4aca258797" +} diff --git a/backend/.sqlx/query-c68af2428470b30146bd9a8e119f2242b439788840fee36cf03da7c8c0d888f5.json b/backend/.sqlx/query-c68af2428470b30146bd9a8e119f2242b439788840fee36cf03da7c8c0d888f5.json new file mode 100644 index 0000000000..6fa80b6aca --- /dev/null +++ b/backend/.sqlx/query-c68af2428470b30146bd9a8e119f2242b439788840fee36cf03da7c8c0d888f5.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n id As \"id!\",\n flow_status->'restarted_from'->'flow_job_id' AS \"restarted_from: Json\"\n FROM v2_queue\n WHERE COALESCE((SELECT root_job FROM v2_queue WHERE id = $1), $1) = id AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "restarted_from: Json", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + null + ] + }, + "hash": "c68af2428470b30146bd9a8e119f2242b439788840fee36cf03da7c8c0d888f5" +} diff --git a/backend/.sqlx/query-cd83b6127846baf104de3be4f7a69e14867957dfc518746f867dee1d5d06cb5a.json b/backend/.sqlx/query-cd83b6127846baf104de3be4f7a69e14867957dfc518746f867dee1d5d06cb5a.json new file mode 100644 index 0000000000..518ba5906f --- /dev/null +++ b/backend/.sqlx/query-cd83b6127846baf104de3be4f7a69e14867957dfc518746f867dee1d5d06cb5a.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM v2_queue WHERE schedule_path = $1 AND running = false AND workspace_id = $2 AND is_flow_step = false", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "cd83b6127846baf104de3be4f7a69e14867957dfc518746f867dee1d5d06cb5a" +} diff --git a/backend/.sqlx/query-cf65514f25af5a85d455be52f373933aacc1572370059815f5abf69c7aba420f.json b/backend/.sqlx/query-cf65514f25af5a85d455be52f373933aacc1572370059815f5abf69c7aba420f.json new file mode 100644 index 0000000000..5b1fffd103 --- /dev/null +++ b/backend/.sqlx/query-cf65514f25af5a85d455be52f373933aacc1572370059815f5abf69c7aba420f.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_flow_runtime SET flow_status = jsonb_set(\n jsonb_set(\n COALESCE(flow_status, '{}'::jsonb),\n array[$1],\n COALESCE(flow_status->$1, '{}'::jsonb)\n ),\n array[$1, 'duration_ms'],\n to_jsonb($2::bigint)\n ) WHERE id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Int8", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "cf65514f25af5a85d455be52f373933aacc1572370059815f5abf69c7aba420f" +} diff --git a/backend/.sqlx/query-d25e94bc84aa182c760259078d21f477193992a3b1a417318c1747f955a85f3c.json b/backend/.sqlx/query-d25e94bc84aa182c760259078d21f477193992a3b1a417318c1747f955a85f3c.json new file mode 100644 index 0000000000..a727f03c84 --- /dev/null +++ b/backend/.sqlx/query-d25e94bc84aa182c760259078d21f477193992a3b1a417318c1747f955a85f3c.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT script_path FROM v2_completed_job WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "script_path", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "d25e94bc84aa182c760259078d21f477193992a3b1a417318c1747f955a85f3c" +} diff --git a/backend/.sqlx/query-d29c07b81377d4617289e9e7bd6355ddee00bf30f9e4acd000fc820b6a63d682.json b/backend/.sqlx/query-d29c07b81377d4617289e9e7bd6355ddee00bf30f9e4acd000fc820b6a63d682.json new file mode 100644 index 0000000000..e557995075 --- /dev/null +++ b/backend/.sqlx/query-d29c07b81377d4617289e9e7bd6355ddee00bf30f9e4acd000fc820b6a63d682.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT job_kind = 'identity' FROM v2_completed_job WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "d29c07b81377d4617289e9e7bd6355ddee00bf30f9e4acd000fc820b6a63d682" +} diff --git a/backend/.sqlx/query-d357006fe927cab6cfc51b5087358b795433b77f67560f4e53cf36e57439018c.json b/backend/.sqlx/query-d357006fe927cab6cfc51b5087358b795433b77f67560f4e53cf36e57439018c.json new file mode 100644 index 0000000000..4ba8cbc9e7 --- /dev/null +++ b/backend/.sqlx/query-d357006fe927cab6cfc51b5087358b795433b77f67560f4e53cf36e57439018c.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT script_path FROM v2_completed_job WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "script_path", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "d357006fe927cab6cfc51b5087358b795433b77f67560f4e53cf36e57439018c" +} diff --git a/backend/.sqlx/query-d5522859ae6234eaed85d75e0f139ab0ed411e9059a1541645c8014c466d77c2.json b/backend/.sqlx/query-d5522859ae6234eaed85d75e0f139ab0ed411e9059a1541645c8014c466d77c2.json new file mode 100644 index 0000000000..6bcb1cddd0 --- /dev/null +++ b/backend/.sqlx/query-d5522859ae6234eaed85d75e0f139ab0ed411e9059a1541645c8014c466d77c2.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT id AS \"id!\", flow_status, suspend AS \"suspend!\", script_path\n FROM v2_queue\n WHERE id = $1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "flow_status", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "suspend!", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "script_path", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true, + true, + true, + true + ] + }, + "hash": "d5522859ae6234eaed85d75e0f139ab0ed411e9059a1541645c8014c466d77c2" +} diff --git a/backend/.sqlx/query-d99ae453289ae967ce92a221375aeca87ed9764bfa683b9d49294c24495ad392.json b/backend/.sqlx/query-d99ae453289ae967ce92a221375aeca87ed9764bfa683b9d49294c24495ad392.json new file mode 100644 index 0000000000..739ec47346 --- /dev/null +++ b/backend/.sqlx/query-d99ae453289ae967ce92a221375aeca87ed9764bfa683b9d49294c24495ad392.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT raw_flow->'failure_module' != 'null'::jsonb FROM v2_job WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "d99ae453289ae967ce92a221375aeca87ed9764bfa683b9d49294c24495ad392" +} diff --git a/backend/.sqlx/query-d9f7f5e82b32d3c0fbc1757e238be723ad0a17ad313844f75f6edbbddb5d6ef3.json b/backend/.sqlx/query-d9f7f5e82b32d3c0fbc1757e238be723ad0a17ad313844f75f6edbbddb5d6ef3.json new file mode 100644 index 0000000000..de40f2989d --- /dev/null +++ b/backend/.sqlx/query-d9f7f5e82b32d3c0fbc1757e238be723ad0a17ad313844f75f6edbbddb5d6ef3.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT result AS \"result: SqlxJson>\", success AS \"success!\"\n FROM v2_completed_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: SqlxJson>", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "success!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true + ] + }, + "hash": "d9f7f5e82b32d3c0fbc1757e238be723ad0a17ad313844f75f6edbbddb5d6ef3" +} diff --git a/backend/.sqlx/query-dbfbb6f56ce9bc832ac8f529cd2a261b6575faecd147926e0a742b8c893de1a3.json b/backend/.sqlx/query-dbfbb6f56ce9bc832ac8f529cd2a261b6575faecd147926e0a742b8c893de1a3.json new file mode 100644 index 0000000000..85e2ec011d --- /dev/null +++ b/backend/.sqlx/query-dbfbb6f56ce9bc832ac8f529cd2a261b6575faecd147926e0a742b8c893de1a3.json @@ -0,0 +1,28 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT usr.email, usage.executions\n FROM usr\n , LATERAL (\n SELECT COALESCE(SUM(duration_ms + 1000)/1000 , 0)::BIGINT executions\n FROM v2_completed_job\n WHERE workspace_id = $1\n AND job_kind NOT IN ('flow', 'flowpreview', 'flownode')\n AND email = usr.email\n AND now() - '1 week'::interval < created_at \n ) usage\n WHERE workspace_id = $1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "email", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "executions", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + null + ] + }, + "hash": "dbfbb6f56ce9bc832ac8f529cd2a261b6575faecd147926e0a742b8c893de1a3" +} diff --git a/backend/.sqlx/query-dd10cbb77c6137cd8bde7a3ab0531cd1299f0fb5a21613cb2069a9b4421a8069.json b/backend/.sqlx/query-dd10cbb77c6137cd8bde7a3ab0531cd1299f0fb5a21613cb2069a9b4421a8069.json new file mode 100644 index 0000000000..1c535f156c --- /dev/null +++ b/backend/.sqlx/query-dd10cbb77c6137cd8bde7a3ab0531cd1299f0fb5a21613cb2069a9b4421a8069.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET last_ping = null\n WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "dd10cbb77c6137cd8bde7a3ab0531cd1299f0fb5a21613cb2069a9b4421a8069" +} diff --git a/backend/.sqlx/query-dd810de496870aa3f211e2d89e335add06812722430f80bc5ddcf4a21dca9ca3.json b/backend/.sqlx/query-dd810de496870aa3f211e2d89e335add06812722430f80bc5ddcf4a21dca9ca3.json new file mode 100644 index 0000000000..cd938a88ed --- /dev/null +++ b/backend/.sqlx/query-dd810de496870aa3f211e2d89e335add06812722430f80bc5ddcf4a21dca9ca3.json @@ -0,0 +1,25 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH queued AS (\n DELETE FROM v2_job_queue q\n USING v2_job j\n WHERE\n q.id = ANY ($2) AND q.id = j.id\n AND q.running = false AND j.parent_job IS NULL AND q.workspace_id = $3\n AND j.trigger IS NULL\n RETURNING\n q.id, q.workspace_id, q.started_at, q.worker\n ), queued_and_runtime AS (\n SELECT queued.*, memory_peak, flow_status\n FROM queued\n JOIN v2_job_runtime USING (id)\n LEFT JOIN v2_job_flow_runtime USING (id)\n ) INSERT INTO v2_job_completed (\n id, workspace_id,\n duration_ms, result, canceled_by, canceled_reason, status,\n flow_status, started_at, memory_peak, worker\n ) SELECT\n id, workspace_id,\n 0, $4, $1, 'cancel all', 'canceled'::job_status,\n flow_status, started_at, memory_peak, worker\n FROM queued_and_runtime\n ON CONFLICT (id) DO NOTHING RETURNING id", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Varchar", + "UuidArray", + "Text", + "Jsonb" + ] + }, + "nullable": [ + false + ] + }, + "hash": "dd810de496870aa3f211e2d89e335add06812722430f80bc5ddcf4a21dca9ca3" +} diff --git a/backend/.sqlx/query-e0fffa04a21586fe01ea575373f240a56ef7687335930d1587f934dd68d4ee81.json b/backend/.sqlx/query-e0fffa04a21586fe01ea575373f240a56ef7687335930d1587f934dd68d4ee81.json new file mode 100644 index 0000000000..4306b4a622 --- /dev/null +++ b/backend/.sqlx/query-e0fffa04a21586fe01ea575373f240a56ef7687335930d1587f934dd68d4ee81.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT EXISTS (\n SELECT 1 FROM v2_completed_job \n WHERE workspace_id = $2 \n AND (job_kind = 'appscript' OR job_kind = 'preview')\n AND created_by = 'anonymous' \n AND started_at > now() - interval '3 hours'\n AND script_path LIKE $3 || '/%' \n AND result @> ('{\"s3\":\"' || $1 || '\"}')::jsonb \n )", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "exists", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Text", + "Text", + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "e0fffa04a21586fe01ea575373f240a56ef7687335930d1587f934dd68d4ee81" +} diff --git a/backend/.sqlx/query-e1339acd0338c02e6f92edddd57863aba209ffe7160c7b5790aed987f1441104.json b/backend/.sqlx/query-e1339acd0338c02e6f92edddd57863aba209ffe7160c7b5790aed987f1441104.json new file mode 100644 index 0000000000..e2c9f12369 --- /dev/null +++ b/backend/.sqlx/query-e1339acd0338c02e6f92edddd57863aba209ffe7160c7b5790aed987f1441104.json @@ -0,0 +1,69 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n result AS \"result: sqlx::types::Json>\",\n flow_status AS \"flow_status: sqlx::types::Json>\",\n language AS \"language: ScriptLang\",\n created_by AS \"created_by!\"\n FROM v2_completed_job\n WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "flow_status: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "language: ScriptLang", + "type_info": { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + } + }, + { + "ordinal": 3, + "name": "created_by!", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + true, + true, + true, + true + ] + }, + "hash": "e1339acd0338c02e6f92edddd57863aba209ffe7160c7b5790aed987f1441104" +} diff --git a/backend/.sqlx/query-e19d0f30bd84680302ff26dd037ceb16d0174118fdc99132bcf7d9461ff998f8.json b/backend/.sqlx/query-e19d0f30bd84680302ff26dd037ceb16d0174118fdc99132bcf7d9461ff998f8.json new file mode 100644 index 0000000000..87e9c3aa79 --- /dev/null +++ b/backend/.sqlx/query-e19d0f30bd84680302ff26dd037ceb16d0174118fdc99132bcf7d9461ff998f8.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT flow_status->'failure_module'->>'parent_module' FROM v2_queue WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Text" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "e19d0f30bd84680302ff26dd037ceb16d0174118fdc99132bcf7d9461ff998f8" +} diff --git a/backend/.sqlx/query-e336b19cd0e4717fe1eb49c8ddd6b6b5c227d100819c6d6231ffd606d1d2986e.json b/backend/.sqlx/query-e336b19cd0e4717fe1eb49c8ddd6b6b5c227d100819c6d6231ffd606d1d2986e.json new file mode 100644 index 0000000000..87e75979d5 --- /dev/null +++ b/backend/.sqlx/query-e336b19cd0e4717fe1eb49c8ddd6b6b5c227d100819c6d6231ffd606d1d2986e.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT result #> $3 AS \"result: Json>\"\n FROM v2_completed_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + null + ] + }, + "hash": "e336b19cd0e4717fe1eb49c8ddd6b6b5c227d100819c6d6231ffd606d1d2986e" +} diff --git a/backend/.sqlx/query-e47b00656e5a3321fefef0e02cdec4dd12900340d7ffcc076a4f969e0b73c4a8.json b/backend/.sqlx/query-e47b00656e5a3321fefef0e02cdec4dd12900340d7ffcc076a4f969e0b73c4a8.json new file mode 100644 index 0000000000..b14b7ce59d --- /dev/null +++ b/backend/.sqlx/query-e47b00656e5a3321fefef0e02cdec4dd12900340d7ffcc076a4f969e0b73c4a8.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT q.id, f.flow_status, q.suspend, j.runnable_path AS script_path\n FROM v2_job_queue q\n JOIN v2_job j USING (id)\n JOIN v2_job_flow_runtime f USING (id)\n WHERE id = ( SELECT parent_job FROM v2_job WHERE id = $1 )\n FOR UPDATE\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "flow_status", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "suspend", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "script_path", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + true + ] + }, + "hash": "e47b00656e5a3321fefef0e02cdec4dd12900340d7ffcc076a4f969e0b73c4a8" +} diff --git a/backend/.sqlx/query-e495f9817420619cdec4e54f920635301be35d5d1813273bef13524f8fbec6b7.json b/backend/.sqlx/query-e495f9817420619cdec4e54f920635301be35d5d1813273bef13524f8fbec6b7.json new file mode 100644 index 0000000000..4eae891537 --- /dev/null +++ b/backend/.sqlx/query-e495f9817420619cdec4e54f920635301be35d5d1813273bef13524f8fbec6b7.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT result #> $3 AS \"result: Json>\"\n FROM v2_completed_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + null + ] + }, + "hash": "e495f9817420619cdec4e54f920635301be35d5d1813273bef13524f8fbec6b7" +} diff --git a/backend/.sqlx/query-eb499eb563839de4c94d9ffb88936f4441b038e9992eebd64fda43a3f5dd8b10.json b/backend/.sqlx/query-eb499eb563839de4c94d9ffb88936f4441b038e9992eebd64fda43a3f5dd8b10.json new file mode 100644 index 0000000000..9d2ed125e6 --- /dev/null +++ b/backend/.sqlx/query-eb499eb563839de4c94d9ffb88936f4441b038e9992eebd64fda43a3f5dd8b10.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n substr(concat(coalesce(v2_completed_job.logs, ''), job_logs.logs), greatest($1 - job_logs.log_offset, 0)) AS logs,\n mem_peak,\n CASE WHEN is_flow_step is true then NULL else flow_status END AS \"flow_status: sqlx::types::Json>\",\n job_logs.log_offset + char_length(job_logs.logs) + 1 AS log_offset,\n created_by AS \"created_by!\"\n FROM v2_completed_job\n LEFT JOIN job_logs ON job_logs.job_id = v2_completed_job.id \n WHERE v2_completed_job.workspace_id = $2 AND v2_completed_job.id = $3", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "logs", + "type_info": "Text" + }, + { + "ordinal": 1, + "name": "mem_peak", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "flow_status: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "log_offset", + "type_info": "Int4" + }, + { + "ordinal": 4, + "name": "created_by!", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Int4", + "Text", + "Uuid" + ] + }, + "nullable": [ + null, + true, + null, + null, + true + ] + }, + "hash": "eb499eb563839de4c94d9ffb88936f4441b038e9992eebd64fda43a3f5dd8b10" +} diff --git a/backend/.sqlx/query-ecbfd613827163b2e7963a7436a01f39cd4c22ee155d11f173f16ff23af2ffda.json b/backend/.sqlx/query-ecbfd613827163b2e7963a7436a01f39cd4c22ee155d11f173f16ff23af2ffda.json new file mode 100644 index 0000000000..e8e0aceb74 --- /dev/null +++ b/backend/.sqlx/query-ecbfd613827163b2e7963a7436a01f39cd4c22ee155d11f173f16ff23af2ffda.json @@ -0,0 +1,198 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT schedule.*, t.jobs FROM schedule, LATERAL ( SELECT ARRAY (SELECT json_build_object('id', id, 'success', success, 'duration_ms', duration_ms) FROM v2_completed_job WHERE\n v2_completed_job.schedule_path = schedule.path AND v2_completed_job.workspace_id = $1 AND parent_job IS NULL AND is_skipped = False ORDER BY started_at DESC LIMIT 20) AS jobs ) t\n WHERE schedule.workspace_id = $1 ORDER BY schedule.edited_at desc LIMIT $2 OFFSET $3", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "workspace_id", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "path", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "edited_by", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "edited_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 4, + "name": "schedule", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "enabled", + "type_info": "Bool" + }, + { + "ordinal": 6, + "name": "script_path", + "type_info": "Varchar" + }, + { + "ordinal": 7, + "name": "args", + "type_info": "Jsonb" + }, + { + "ordinal": 8, + "name": "extra_perms", + "type_info": "Jsonb" + }, + { + "ordinal": 9, + "name": "is_flow", + "type_info": "Bool" + }, + { + "ordinal": 10, + "name": "email", + "type_info": "Varchar" + }, + { + "ordinal": 11, + "name": "error", + "type_info": "Text" + }, + { + "ordinal": 12, + "name": "timezone", + "type_info": "Varchar" + }, + { + "ordinal": 13, + "name": "on_failure", + "type_info": "Varchar" + }, + { + "ordinal": 14, + "name": "on_recovery", + "type_info": "Varchar" + }, + { + "ordinal": 15, + "name": "on_failure_times", + "type_info": "Int4" + }, + { + "ordinal": 16, + "name": "on_failure_exact", + "type_info": "Bool" + }, + { + "ordinal": 17, + "name": "on_failure_extra_args", + "type_info": "Json" + }, + { + "ordinal": 18, + "name": "on_recovery_times", + "type_info": "Int4" + }, + { + "ordinal": 19, + "name": "on_recovery_extra_args", + "type_info": "Json" + }, + { + "ordinal": 20, + "name": "ws_error_handler_muted", + "type_info": "Bool" + }, + { + "ordinal": 21, + "name": "retry", + "type_info": "Jsonb" + }, + { + "ordinal": 22, + "name": "summary", + "type_info": "Varchar" + }, + { + "ordinal": 23, + "name": "no_flow_overlap", + "type_info": "Bool" + }, + { + "ordinal": 24, + "name": "tag", + "type_info": "Varchar" + }, + { + "ordinal": 25, + "name": "paused_until", + "type_info": "Timestamptz" + }, + { + "ordinal": 26, + "name": "on_success", + "type_info": "Varchar" + }, + { + "ordinal": 27, + "name": "on_success_extra_args", + "type_info": "Json" + }, + { + "ordinal": 28, + "name": "cron_version", + "type_info": "Text" + }, + { + "ordinal": 29, + "name": "jobs", + "type_info": "JsonArray" + } + ], + "parameters": { + "Left": [ + "Text", + "Int8", + "Int8" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + false, + false, + true, + false, + false, + false, + true, + false, + true, + true, + true, + true, + true, + true, + true, + false, + true, + true, + false, + true, + true, + true, + true, + true, + null + ] + }, + "hash": "ecbfd613827163b2e7963a7436a01f39cd4c22ee155d11f173f16ff23af2ffda" +} diff --git a/backend/.sqlx/query-ecd62c48fe2fba2fc2582e9e7ae5590d5dea8c67f6ae7b14743ac4f265dd89a3.json b/backend/.sqlx/query-ecd62c48fe2fba2fc2582e9e7ae5590d5dea8c67f6ae7b14743ac4f265dd89a3.json new file mode 100644 index 0000000000..7431f3e1fb --- /dev/null +++ b/backend/.sqlx/query-ecd62c48fe2fba2fc2582e9e7ae5590d5dea8c67f6ae7b14743ac4f265dd89a3.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM v2_job WHERE id = ANY($1)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "UuidArray" + ] + }, + "nullable": [] + }, + "hash": "ecd62c48fe2fba2fc2582e9e7ae5590d5dea8c67f6ae7b14743ac4f265dd89a3" +} diff --git a/backend/.sqlx/query-ef20932aac9dec17eef7853aeacd8bfdf7f5cd9ad3865416e7aa0a09fd135a99.json b/backend/.sqlx/query-ef20932aac9dec17eef7853aeacd8bfdf7f5cd9ad3865416e7aa0a09fd135a99.json new file mode 100644 index 0000000000..cbf7ed056a --- /dev/null +++ b/backend/.sqlx/query-ef20932aac9dec17eef7853aeacd8bfdf7f5cd9ad3865416e7aa0a09fd135a99.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE v2_queue\n SET canceled = true\n , canceled_by = 'timeout'\n , canceled_reason = $1\n WHERE id = $2\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "ef20932aac9dec17eef7853aeacd8bfdf7f5cd9ad3865416e7aa0a09fd135a99" +} diff --git a/backend/.sqlx/query-ef387687bd247fccdab8b0f8086c0dfcb7feab3426b1365e6be960530973e3ef.json b/backend/.sqlx/query-ef387687bd247fccdab8b0f8086c0dfcb7feab3426b1365e6be960530973e3ef.json new file mode 100644 index 0000000000..5d0c0f90f4 --- /dev/null +++ b/backend/.sqlx/query-ef387687bd247fccdab8b0f8086c0dfcb7feab3426b1365e6be960530973e3ef.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = jsonb_set(\n jsonb_set(flow_status, ARRAY['modules', $4::INTEGER::TEXT, 'job'], to_jsonb($1::UUID::TEXT)),\n ARRAY['modules', $4::INTEGER::TEXT, 'type'],\n to_jsonb('InProgress'::text)\n )\n WHERE id = $2 AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Text", + "Int4" + ] + }, + "nullable": [] + }, + "hash": "ef387687bd247fccdab8b0f8086c0dfcb7feab3426b1365e6be960530973e3ef" +} diff --git a/backend/.sqlx/query-efe6d8ff451eeab03bdad90d1b2283b63e99b0c7e1cdddac029e218bc31c5dcd.json b/backend/.sqlx/query-efe6d8ff451eeab03bdad90d1b2283b63e99b0c7e1cdddac029e218bc31c5dcd.json new file mode 100644 index 0000000000..643701e2ff --- /dev/null +++ b/backend/.sqlx/query-efe6d8ff451eeab03bdad90d1b2283b63e99b0c7e1cdddac029e218bc31c5dcd.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT canceled AS \"canceled!\" FROM v2_queue WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "canceled!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "efe6d8ff451eeab03bdad90d1b2283b63e99b0c7e1cdddac029e218bc31c5dcd" +} diff --git a/backend/.sqlx/query-f03794eda2e3ad0b2d30854120cb3e78a9129aaacf24c84c6ecee7819845b3dc.json b/backend/.sqlx/query-f03794eda2e3ad0b2d30854120cb3e78a9129aaacf24c84c6ecee7819845b3dc.json new file mode 100644 index 0000000000..72b02b68d1 --- /dev/null +++ b/backend/.sqlx/query-f03794eda2e3ad0b2d30854120cb3e78a9129aaacf24c84c6ecee7819845b3dc.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue\n SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'iterator', 'index'], ((flow_status->'modules'->$1::int->'iterator'->>'index')::int + 1)::text::jsonb),\n last_ping = NULL\n WHERE id = $2\n RETURNING (flow_status->'modules'->$1::int->'iterator'->>'index')::int", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "int4", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Int4", + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "f03794eda2e3ad0b2d30854120cb3e78a9129aaacf24c84c6ecee7819845b3dc" +} diff --git a/backend/.sqlx/query-f1280cedcac66a0257b45c2d1ec9f3c5e8efd23a323194f2210ae4e98de52358.json b/backend/.sqlx/query-f1280cedcac66a0257b45c2d1ec9f3c5e8efd23a323194f2210ae4e98de52358.json new file mode 100644 index 0000000000..c943ecad92 --- /dev/null +++ b/backend/.sqlx/query-f1280cedcac66a0257b45c2d1ec9f3c5e8efd23a323194f2210ae4e98de52358.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT coalesce(COUNT(*) FILTER(WHERE suspend = 0 AND running = false), 0) as \"database_length!\", coalesce(COUNT(*) FILTER(WHERE suspend > 0), 0) as \"suspended!\" FROM v2_queue WHERE (workspace_id = $1 OR $2) AND scheduled_for <= now()", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "database_length!", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "suspended!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text", + "Bool" + ] + }, + "nullable": [ + null, + null + ] + }, + "hash": "f1280cedcac66a0257b45c2d1ec9f3c5e8efd23a323194f2210ae4e98de52358" +} diff --git a/backend/.sqlx/query-f23941db8b1bac5964788985c3651be202adc8e6e591fca66df87d3dd7b74a2d.json b/backend/.sqlx/query-f23941db8b1bac5964788985c3651be202adc8e6e591fca66df87d3dd7b74a2d.json new file mode 100644 index 0000000000..e54eb5bf65 --- /dev/null +++ b/backend/.sqlx/query-f23941db8b1bac5964788985c3651be202adc8e6e591fca66df87d3dd7b74a2d.json @@ -0,0 +1,68 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n result AS \"result: sqlx::types::Json>\",\n language AS \"language: ScriptLang\",\n flow_status AS \"flow_status: sqlx::types::Json>\",\n success AS \"success!\"\n FROM v2_completed_job\n WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "language: ScriptLang", + "type_info": { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + } + }, + { + "ordinal": 2, + "name": "flow_status: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "success!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true + ] + }, + "hash": "f23941db8b1bac5964788985c3651be202adc8e6e591fca66df87d3dd7b74a2d" +} diff --git a/backend/.sqlx/query-f746c5d2ffa24dd75124b5f8d04f587c9581ef407417ec979b8a3ab07816cc69.json b/backend/.sqlx/query-f746c5d2ffa24dd75124b5f8d04f587c9581ef407417ec979b8a3ab07816cc69.json new file mode 100644 index 0000000000..c65cfb397a --- /dev/null +++ b/backend/.sqlx/query-f746c5d2ffa24dd75124b5f8d04f587c9581ef407417ec979b8a3ab07816cc69.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET trigger = REGEXP_REPLACE(trigger,'u/' || $2 || '/(.*)','u/' || $1 || '/\\1') WHERE trigger LIKE ('u/' || $2 || '/%') AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "f746c5d2ffa24dd75124b5f8d04f587c9581ef407417ec979b8a3ab07816cc69" +} diff --git a/backend/.sqlx/query-f8e0103dae8d80682a6b694762b6e4490d6004ba58ae26c52a4f21f867e1df70.json b/backend/.sqlx/query-f8e0103dae8d80682a6b694762b6e4490d6004ba58ae26c52a4f21f867e1df70.json new file mode 100644 index 0000000000..8505cb06cc --- /dev/null +++ b/backend/.sqlx/query-f8e0103dae8d80682a6b694762b6e4490d6004ba58ae26c52a4f21f867e1df70.json @@ -0,0 +1,111 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO v2_job (\n id, workspace_id,\n created_at, created_by, permissioned_as, permissioned_as_email,\n kind, runnable_id, runnable_path, parent_job, script_lang,\n flow_step_id, flow_root_job,\n trigger, trigger_kind,\n tag, same_worker, visible_to_owner, concurrent_limit, concurrency_time_window_s,\n cache_ttl, timeout, priority,\n args, pre_run_error,\n raw_code, raw_lock, raw_flow\n ) SELECT\n unnest($1::uuid[]), $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15,\n $16, $17, $18, $19, $20, $21, $22, $23, unnest($24::jsonb[]), $25, $26, $27, $28\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "UuidArray", + "Varchar", + "Timestamptz", + "Varchar", + "Varchar", + "Varchar", + { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + }, + "Int8", + "Varchar", + "Uuid", + { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + }, + "Varchar", + "Uuid", + "Varchar", + { + "Custom": { + "name": "job_trigger_kind", + "kind": { + "Enum": [ + "webhook", + "http", + "websocket", + "kafka", + "email", + "nats", + "schedule", + "app", + "ui" + ] + } + } + }, + "Varchar", + "Bool", + "Bool", + "Int4", + "Int4", + "Int4", + "Int4", + "Int2", + "JsonbArray", + "Text", + "Text", + "Text", + "Jsonb" + ] + }, + "nullable": [] + }, + "hash": "f8e0103dae8d80682a6b694762b6e4490d6004ba58ae26c52a4f21f867e1df70" +} diff --git a/backend/.sqlx/query-fb9e98f5a4da2918146cff7c04d0b1ed5e219c2392867d836bc29263cc57ff90.json b/backend/.sqlx/query-fb9e98f5a4da2918146cff7c04d0b1ed5e219c2392867d836bc29263cc57ff90.json new file mode 100644 index 0000000000..14198d4f69 --- /dev/null +++ b/backend/.sqlx/query-fb9e98f5a4da2918146cff7c04d0b1ed5e219c2392867d836bc29263cc57ff90.json @@ -0,0 +1,28 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT coalesce(COUNT(*), 0) as \"database_length!\", null::bigint as suspended FROM v2_completed_job WHERE workspace_id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "database_length!", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "suspended", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + null, + null + ] + }, + "hash": "fb9e98f5a4da2918146cff7c04d0b1ed5e219c2392867d836bc29263cc57ff90" +} diff --git a/backend/.sqlx/query-fc8bc1bdaf75bd5e1054698963be2ce6dea9f667ff323f4db84e3553f0e0f49c.json b/backend/.sqlx/query-fc8bc1bdaf75bd5e1054698963be2ce6dea9f667ff323f4db84e3553f0e0f49c.json new file mode 100644 index 0000000000..2129ba336f --- /dev/null +++ b/backend/.sqlx/query-fc8bc1bdaf75bd5e1054698963be2ce6dea9f667ff323f4db84e3553f0e0f49c.json @@ -0,0 +1,35 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_queue SET mem_peak = $1, last_ping = now()\n WHERE id = $2\n RETURNING canceled AS \"canceled!\", canceled_by, canceled_reason", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "canceled!", + "type_info": "Bool" + }, + { + "ordinal": 1, + "name": "canceled_by", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "canceled_reason", + "type_info": "Text" + } + ], + "parameters": { + "Left": [ + "Int4", + "Uuid" + ] + }, + "nullable": [ + true, + true, + true + ] + }, + "hash": "fc8bc1bdaf75bd5e1054698963be2ce6dea9f667ff323f4db84e3553f0e0f49c" +} diff --git a/backend/.sqlx/query-fee633fcf73f6253d07938cbf8e1c5947d2e22a10fc95401faa2d3704647830d.json b/backend/.sqlx/query-fee633fcf73f6253d07938cbf8e1c5947d2e22a10fc95401faa2d3704647830d.json new file mode 100644 index 0000000000..2f089691d9 --- /dev/null +++ b/backend/.sqlx/query-fee633fcf73f6253d07938cbf8e1c5947d2e22a10fc95401faa2d3704647830d.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\" FROM v2_queue WHERE workspace_id = $1 and root_job = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Text", + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "fee633fcf73f6253d07938cbf8e1c5947d2e22a10fc95401faa2d3704647830d" +} diff --git a/backend/.sqlx/query-fefcb942f0fbf57e7ba6e879f7843010a95fb50a983a45dc72638a3ada1b83ff.json b/backend/.sqlx/query-fefcb942f0fbf57e7ba6e879f7843010a95fb50a983a45dc72638a3ada1b83ff.json new file mode 100644 index 0000000000..5f5244f781 --- /dev/null +++ b/backend/.sqlx/query-fefcb942f0fbf57e7ba6e879f7843010a95fb50a983a45dc72638a3ada1b83ff.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(id) FROM v2_queue WHERE running = true AND workspace_id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "fefcb942f0fbf57e7ba6e879f7843010a95fb50a983a45dc72638a3ada1b83ff" +} diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 600abc1f5e..f1401955f2 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -11281,6 +11281,7 @@ dependencies = [ "tokio-postgres", "tokio-util", "tracing", + "ulid", "urlencoding", "uuid 1.12.0", "windmill-audit", diff --git a/backend/ee-repo-ref.txt b/backend/ee-repo-ref.txt index 2f8cf983a0..bf5697672c 100644 --- a/backend/ee-repo-ref.txt +++ b/backend/ee-repo-ref.txt @@ -1 +1 @@ -ddcfdfc18a9833a5fc4e62ad62a265ef1e06a0aa \ No newline at end of file +69134f284383169d54f4abd29481b5eca2dd2c2a \ No newline at end of file diff --git a/backend/migrations/20250117145630_v2_queue_compatibility_view.down.sql b/backend/migrations/20250117145630_v2_queue_compatibility_view.down.sql new file mode 100644 index 0000000000..27e4d60fa3 --- /dev/null +++ b/backend/migrations/20250117145630_v2_queue_compatibility_view.down.sql @@ -0,0 +1,6 @@ +-- Add down migration script here +DROP FUNCTION v2_queue_instead_of_update_overlay() CASCADE; +DROP FUNCTION v2_queue_instead_of_update() CASCADE; +DROP FUNCTION v2_queue_instead_of_delete() CASCADE; +DROP FUNCTION v2_queue_update(OLD v2_queue, NEW v2_queue) CASCADE; +DROP VIEW v2_queue; diff --git a/backend/migrations/20250117145630_v2_queue_compatibility_view.up.sql b/backend/migrations/20250117145630_v2_queue_compatibility_view.up.sql new file mode 100644 index 0000000000..d240e2e0aa --- /dev/null +++ b/backend/migrations/20250117145630_v2_queue_compatibility_view.up.sql @@ -0,0 +1,169 @@ +-- Add up migration script here +CREATE OR REPLACE VIEW v2_queue AS +SELECT + j.id, + j.workspace_id, + j.parent_job, + j.created_by, + j.created_at, + q.started_at, + q.scheduled_for, + q.running, + j.runnable_id AS script_hash, + j.runnable_path AS script_path, + j.args, + j.raw_code, + q.canceled_by IS NOT NULL AS canceled, + q.canceled_by, + q.canceled_reason, + r.ping AS last_ping, + j.kind AS job_kind, + j.trigger AS schedule_path, + j.permissioned_as, + f.flow_status, + j.raw_flow, + j.flow_step_id IS NOT NULL AS is_flow_step, + j.script_lang AS language, + q.suspend, + q.suspend_until, + j.same_worker, + j.raw_lock, + j.pre_run_error, + j.permissioned_as_email AS email, + j.visible_to_owner, + r.memory_peak AS mem_peak, + j.flow_root_job AS root_job, + f.leaf_jobs, + j.tag, + j.concurrent_limit, + j.concurrency_time_window_s, + j.timeout, + j.flow_step_id, + j.cache_ttl, + j.priority, + NULL::TEXT AS logs +FROM v2_job_queue q + JOIN v2_job j USING (id) + LEFT JOIN v2_job_runtime r USING (id) + LEFT JOIN v2_job_flow_runtime f USING (id) +; + +-- Dispatch update of `v1` schema to `v2_*` tables. +CREATE OR REPLACE FUNCTION v2_queue_update(OLD v2_queue, NEW v2_queue) RETURNS VOID AS $$ BEGIN + -- Unsupported columns: + IF NEW.workspace_id IS DISTINCT FROM OLD.workspace_id + OR NEW.parent_job IS DISTINCT FROM OLD.parent_job + OR NEW.created_by IS DISTINCT FROM OLD.created_by + OR NEW.created_at IS DISTINCT FROM OLD.created_at + OR NEW.script_hash IS DISTINCT FROM OLD.script_hash + OR NEW.script_path IS DISTINCT FROM OLD.script_path + OR NEW.raw_code IS DISTINCT FROM OLD.raw_code + OR NEW.job_kind IS DISTINCT FROM OLD.job_kind + OR NEW.schedule_path IS DISTINCT FROM OLD.schedule_path + OR NEW.permissioned_as IS DISTINCT FROM OLD.permissioned_as + OR NEW.raw_flow::TEXT IS DISTINCT FROM OLD.raw_flow::TEXT + OR NEW.language IS DISTINCT FROM OLD.language + OR NEW.same_worker IS DISTINCT FROM OLD.same_worker + OR NEW.raw_lock IS DISTINCT FROM OLD.raw_lock + OR NEW.pre_run_error IS DISTINCT FROM OLD.pre_run_error + OR NEW.email IS DISTINCT FROM OLD.email + OR NEW.visible_to_owner IS DISTINCT FROM OLD.visible_to_owner + OR NEW.concurrent_limit IS DISTINCT FROM OLD.concurrent_limit + OR NEW.concurrency_time_window_s IS DISTINCT FROM OLD.concurrency_time_window_s + OR NEW.timeout IS DISTINCT FROM OLD.timeout + OR NEW.flow_step_id IS DISTINCT FROM OLD.flow_step_id + OR NEW.cache_ttl IS DISTINCT FROM OLD.cache_ttl + OR NEW.priority IS DISTINCT FROM OLD.priority + THEN + RAISE EXCEPTION 'Updating an immutable column in `v2_queue`'; + END IF; + -- Update the `v2_job` table + IF NEW.args::TEXT IS DISTINCT FROM OLD.args::TEXT THEN + UPDATE v2_job + SET args = NEW.args + WHERE id = OLD.id; + END IF; + -- Update the `v2_job_queue` table + IF NEW.canceled AND NEW.canceled_by IS NULL THEN + NEW.canceled_by := 'unknown'; + NEW.canceled_reason := 'canceled by user'; + END IF; + IF NEW.started_at IS DISTINCT FROM OLD.started_at + OR NEW.scheduled_for IS DISTINCT FROM OLD.scheduled_for + OR NEW.running IS DISTINCT FROM OLD.running + OR NEW.canceled_by IS DISTINCT FROM OLD.canceled_by + OR NEW.canceled_reason IS DISTINCT FROM OLD.canceled_reason + OR NEW.suspend IS DISTINCT FROM OLD.suspend + OR NEW.suspend_until IS DISTINCT FROM OLD.suspend_until + THEN + UPDATE v2_job_queue + SET started_at = NEW.started_at, + scheduled_for = NEW.scheduled_for, + running = NEW.running, + canceled_by = NEW.canceled_by, + canceled_reason = NEW.canceled_reason, + suspend = NEW.suspend, + suspend_until = NEW.suspend_until + WHERE id = OLD.id; + END IF; + -- Update the `v2_job_runtime` table + IF NEW.last_ping IS DISTINCT FROM OLD.last_ping + OR NEW.mem_peak IS DISTINCT FROM OLD.mem_peak + THEN + UPDATE v2_job_runtime + SET ping = NEW.last_ping, + memory_peak = NEW.mem_peak + WHERE id = OLD.id; + END IF; + -- Update the `v2_job_flow_runtime` table + IF NEW.flow_status::TEXT IS DISTINCT FROM OLD.flow_status::TEXT + OR NEW.leaf_jobs::TEXT IS DISTINCT FROM OLD.leaf_jobs::TEXT + THEN + UPDATE v2_job_flow_runtime + SET flow_status = NEW.flow_status, + leaf_jobs = NEW.leaf_jobs + WHERE id = OLD.id; + END IF; +END $$ LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION v2_queue_instead_of_update() RETURNS TRIGGER AS $$ BEGIN + -- v1 -> v2 sync + PERFORM v2_queue_update(OLD, NEW); + RETURN NEW; +END $$ LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION v2_queue_instead_of_update_overlay() RETURNS TRIGGER AS $$ BEGIN + -- v1 -> v2 sync + PERFORM v2_queue_update(OLD, NEW); + -- v2 -> v1 sync + IF NEW.args IS DISTINCT FROM OLD.args + OR NEW.last_ping IS DISTINCT FROM OLD.last_ping + OR NEW.mem_peak IS DISTINCT FROM OLD.mem_peak + OR NEW.flow_status::TEXT IS DISTINCT FROM OLD.flow_status::TEXT + OR NEW.leaf_jobs::TEXT IS DISTINCT FROM OLD.leaf_jobs::TEXT + THEN + UPDATE v2_job_queue + SET __args = NEW.args, + __last_ping = NEW.last_ping, + __mem_peak = NEW.mem_peak, + __flow_status = NEW.flow_status, + __leaf_jobs = NEW.leaf_jobs + WHERE id = OLD.id; + END IF; + RETURN NEW; +END $$ LANGUAGE plpgsql; + +CREATE TRIGGER v2_queue_instead_of_update_trigger +INSTEAD OF UPDATE ON v2_queue +FOR EACH ROW +EXECUTE PROCEDURE v2_queue_instead_of_update_overlay(); + +CREATE OR REPLACE FUNCTION v2_queue_instead_of_delete() RETURNS TRIGGER AS $$ BEGIN + DELETE FROM v2_job_queue WHERE id = OLD.id; + RETURN OLD; +END $$ LANGUAGE plpgsql; + +CREATE TRIGGER v2_queue_instead_of_delete_trigger + INSTEAD OF DELETE ON v2_queue + FOR EACH ROW +EXECUTE PROCEDURE v2_queue_instead_of_delete(); diff --git a/backend/migrations/20250117145631_v2_completed_job_compatibility_view.down.sql b/backend/migrations/20250117145631_v2_completed_job_compatibility_view.down.sql new file mode 100644 index 0000000000..3bc436e1fd --- /dev/null +++ b/backend/migrations/20250117145631_v2_completed_job_compatibility_view.down.sql @@ -0,0 +1,6 @@ +-- Add up migration script here +DROP FUNCTION v2_completed_job_instead_of_update_overlay() CASCADE; +DROP FUNCTION v2_completed_job_instead_of_update() CASCADE; +DROP FUNCTION v2_completed_job_instead_of_delete() CASCADE; +DROP FUNCTION v2_completed_job_update(OLD v2_completed_job, NEW v2_completed_job) CASCADE; +DROP VIEW v2_completed_job; diff --git a/backend/migrations/20250117145631_v2_completed_job_compatibility_view.up.sql b/backend/migrations/20250117145631_v2_completed_job_compatibility_view.up.sql new file mode 100644 index 0000000000..8a5a60acdd --- /dev/null +++ b/backend/migrations/20250117145631_v2_completed_job_compatibility_view.up.sql @@ -0,0 +1,107 @@ +-- Add up migration script here +CREATE OR REPLACE VIEW v2_completed_job AS +SELECT + j.id, + j.workspace_id, + j.parent_job, + j.created_by, + j.created_at, + c.duration_ms, + c.status = 'success' AS success, + j.runnable_id AS script_hash, + j.runnable_path AS script_path, + j.args, + c.result, + FALSE AS deleted, + j.raw_code, + c.status = 'canceled' AS canceled, + c.canceled_by, + c.canceled_reason, + j.kind AS job_kind, + j.trigger AS schedule_path, + j.permissioned_as, + c.flow_status, + j.raw_flow, + j.flow_step_id IS NOT NULL AS is_flow_step, + j.script_lang AS language, + c.started_at, + c.status = 'skipped' AS is_skipped, + j.raw_lock, + j.permissioned_as_email AS email, + j.visible_to_owner, + c.memory_peak AS mem_peak, + j.tag, + j.priority, + NULL::TEXT AS logs +FROM v2_job_completed c + JOIN v2_job j USING (id) +; + +CREATE OR REPLACE FUNCTION v2_completed_job_update(OLD v2_completed_job, NEW v2_completed_job) RETURNS VOID AS $$ BEGIN + -- Unsupported columns: + IF NEW.workspace_id IS DISTINCT FROM OLD.workspace_id + OR NEW.parent_job IS DISTINCT FROM OLD.parent_job + OR NEW.created_by IS DISTINCT FROM OLD.created_by + OR NEW.created_at IS DISTINCT FROM OLD.created_at + OR NEW.script_hash IS DISTINCT FROM OLD.script_hash + OR NEW.script_path IS DISTINCT FROM OLD.script_path + OR NEW.raw_code IS DISTINCT FROM OLD.raw_code + OR NEW.job_kind IS DISTINCT FROM OLD.job_kind + OR NEW.schedule_path IS DISTINCT FROM OLD.schedule_path + OR NEW.permissioned_as IS DISTINCT FROM OLD.permissioned_as + OR NEW.raw_flow::TEXT IS DISTINCT FROM OLD.raw_flow::TEXT + OR NEW.language IS DISTINCT FROM OLD.language + OR NEW.raw_lock IS DISTINCT FROM OLD.raw_lock + OR NEW.email IS DISTINCT FROM OLD.email + OR NEW.visible_to_owner IS DISTINCT FROM OLD.visible_to_owner + OR NEW.priority IS DISTINCT FROM OLD.priority + THEN + RAISE EXCEPTION 'Updating an immutable column in `v2_completed_job`'; + END IF; + -- Update the `v2_job` table + IF NEW.args::TEXT IS DISTINCT FROM OLD.args::TEXT THEN + UPDATE v2_job + SET args = NEW.args + WHERE id = OLD.id; + END IF; + -- Update the `v2_job_completed` table + IF NEW.result::TEXT IS DISTINCT FROM OLD.result::TEXT + THEN + UPDATE v2_job_completed + SET result = NEW.result + WHERE id = OLD.id; + END IF; +END $$ LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION v2_completed_job_instead_of_update() RETURNS TRIGGER AS $$ BEGIN + -- v1 -> v2 sync + PERFORM v2_completed_job_update(OLD, NEW); + RETURN NEW; +END $$ LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION v2_completed_job_instead_of_update_overlay() RETURNS TRIGGER AS $$ BEGIN + -- v1 -> v2 sync + PERFORM v2_completed_job_update(OLD, NEW); + -- v2 -> v1 sync + IF NEW.args::TEXT IS DISTINCT FROM OLD.args::TEXT THEN + UPDATE v2_job_completed + SET __args = NEW.args + WHERE id = OLD.id; + END IF; + RETURN NEW; +END $$ LANGUAGE plpgsql; + +CREATE TRIGGER v2_completed_job_instead_of_update_trigger + INSTEAD OF UPDATE ON v2_completed_job + FOR EACH ROW +EXECUTE PROCEDURE v2_completed_job_instead_of_update_overlay(); + +CREATE OR REPLACE FUNCTION v2_completed_job_instead_of_delete() RETURNS TRIGGER AS $$ BEGIN + DELETE FROM v2_job_completed WHERE id = OLD.id; + RETURN OLD; +END $$ LANGUAGE plpgsql; + +CREATE TRIGGER v2_completed_job_instead_of_delete_trigger + INSTEAD OF DELETE ON v2_completed_job + FOR EACH ROW +EXECUTE PROCEDURE v2_completed_job_instead_of_delete(); diff --git a/backend/src/monitor.rs b/backend/src/monitor.rs index 1997bbcc3f..4e763b3d84 100644 --- a/backend/src/monitor.rs +++ b/backend/src/monitor.rs @@ -735,7 +735,7 @@ pub async fn delete_expired_items(db: &DB) -> () { match db.begin().await { Ok(mut tx) => { let deleted_jobs = sqlx::query_scalar!( - "DELETE FROM completed_job WHERE created_at <= now() - ($1::bigint::text || ' s')::interval AND started_at + ((duration_ms/1000 + $1::bigint) || ' s')::interval <= now() RETURNING id AS \"id!\"", + "DELETE FROM v2_completed_job WHERE created_at <= now() - ($1::bigint::text || ' s')::interval AND started_at + ((duration_ms/1000 + $1::bigint) || ' s')::interval <= now() RETURNING id AS \"id!\"", job_retention_secs ) .fetch_all(&mut *tx) @@ -787,7 +787,7 @@ pub async fn delete_expired_items(db: &DB) -> () { } if let Err(e) = - sqlx::query!("DELETE FROM job WHERE id = ANY($1)", &deleted_jobs) + sqlx::query!("DELETE FROM v2_job WHERE id = ANY($1)", &deleted_jobs) .execute(&mut *tx) .await { @@ -1333,7 +1333,7 @@ pub async fn expose_queue_metrics(db: &Pool) { sqlx::query!( "INSERT INTO metrics (id, value) VALUES ($1, to_jsonb((SELECT EXTRACT(EPOCH FROM now() - scheduled_for) - FROM queue WHERE tag = $2 AND running = false AND scheduled_for <= now() - ('3 seconds')::interval + FROM v2_queue WHERE tag = $2 AND running = false AND scheduled_for <= now() - ('3 seconds')::interval ORDER BY priority DESC NULLS LAST, scheduled_for LIMIT 1)))", format!("queue_delay_{}", tag), tag @@ -1496,7 +1496,7 @@ pub async fn reload_base_url_setting(db: &DB) -> error::Result<()> { async fn handle_zombie_jobs(db: &Pool, base_internal_url: &str, worker_name: &str) { if *RESTART_ZOMBIE_JOBS { let restarted = sqlx::query!( - "UPDATE queue SET running = false, started_at = null + "UPDATE v2_queue SET running = false, started_at = null WHERE last_ping < now() - ($1 || ' seconds')::interval AND running = true AND job_kind NOT IN ('flow', 'flowpreview', 'flownode', 'singlescriptflow') AND same_worker = false RETURNING id AS \"id!\", workspace_id AS \"workspace_id!\", last_ping", *ZOMBIE_JOB_TIMEOUT, @@ -1534,7 +1534,7 @@ async fn handle_zombie_jobs(db: &Pool, base_internal_url: &str, worker } let mut timeout_query = - "SELECT * FROM queue WHERE last_ping < now() - ($1 || ' seconds')::interval + "SELECT * FROM v2_queue WHERE last_ping < now() - ($1 || ' seconds')::interval AND running = true AND job_kind NOT IN ('flow', 'flowpreview', 'flownode', 'singlescriptflow')" .to_string(); if *RESTART_ZOMBIE_JOBS { @@ -1608,7 +1608,7 @@ async fn handle_zombie_jobs(db: &Pool, base_internal_url: &str, worker worker_name, send_result_never_used, #[cfg(feature = "benchmark")] - &mut windmill_common::bench::BenchmarkIter::new(), + &mut windmill_worker::bench::BenchmarkIter::new(), ) .await; } @@ -1620,7 +1620,7 @@ async fn handle_zombie_flows(db: &DB) -> error::Result<()> { SELECT id AS "id!", workspace_id AS "workspace_id!", parent_job, is_flow_step, flow_status AS "flow_status: Box", last_ping, same_worker - FROM queue + FROM v2_queue WHERE running = true AND suspend = 0 AND suspend_until IS null AND scheduled_for <= now() AND (job_kind = 'flow' OR job_kind = 'flowpreview' OR job_kind = 'flownode') AND last_ping IS NOT NULL AND last_ping < NOW() - ($1 || ' seconds')::interval @@ -1651,7 +1651,7 @@ async fn handle_zombie_flows(db: &DB) -> error::Result<()> { report_critical_error(error_message, db.clone(), Some(&flow.workspace_id), None).await; // if the flow hasn't started and is a zombie, we can simply restart it sqlx::query!( - "UPDATE queue SET running = false, started_at = null WHERE id = $1 AND canceled = false", + "UPDATE v2_queue SET running = false, started_at = null WHERE id = $1 AND canceled = false", flow.id ) .execute(db) @@ -1678,7 +1678,7 @@ async fn handle_zombie_flows(db: &DB) -> error::Result<()> { DELETE FROM parallel_monitor_lock WHERE last_ping IS NOT NULL AND last_ping < NOW() - ($1 || ' seconds')::interval - RETURNING parent_flow_id, job_id, last_ping, (SELECT workspace_id FROM queue q + RETURNING parent_flow_id, job_id, last_ping, (SELECT workspace_id FROM v2_queue q WHERE q.id = parent_flow_id AND q.running = true AND q.canceled = false) AS workspace_id "#, FLOW_ZOMBIE_TRANSITION_TIMEOUT.as_str() diff --git a/backend/tests/fixtures/base.sql b/backend/tests/fixtures/base.sql index e6e4f9875a..b0dfd05c08 100644 --- a/backend/tests/fixtures/base.sql +++ b/backend/tests/fixtures/base.sql @@ -23,7 +23,7 @@ GRANT ALL PRIVILEGES ON TABLE workspace_key TO windmill_user; CREATE FUNCTION "notify_insert_on_completed_job" () RETURNS TRIGGER AS $$ BEGIN - PERFORM pg_notify('insert on completed_job', NEW.id::text); + PERFORM pg_notify('completed', NEW.id::text); RETURN NEW; END; $$ LANGUAGE PLPGSQL; @@ -37,7 +37,7 @@ EXECUTE FUNCTION "notify_insert_on_completed_job" (); CREATE FUNCTION "notify_queue" () RETURNS TRIGGER AS $$ BEGIN - PERFORM pg_notify('queue', NEW.id::text); + PERFORM pg_notify('queued', NEW.id::text); RETURN NEW; END; $$ LANGUAGE PLPGSQL; diff --git a/backend/tests/fixtures/result_format.sql b/backend/tests/fixtures/result_format.sql index 1f990e2d86..0d70e56370 100644 --- a/backend/tests/fixtures/result_format.sql +++ b/backend/tests/fixtures/result_format.sql @@ -1,3 +1,9 @@ +INSERT INTO public.v2_job ( + id, workspace_id, created_by, kind, script_lang +) VALUES ( + '1eecb96a-c8b0-4a3d-b1b6-087878c55e41', 'test-workspace', 'test-user', 'script', 'postgresql' +); + INSERT INTO public.completed_job ( id, workspace_id, created_by, created_at, duration_ms, success, flow_status, result, job_kind, language ) VALUES ( diff --git a/backend/tests/worker.rs b/backend/tests/worker.rs index cd116eeb15..1ea74c3a2f 100644 --- a/backend/tests/worker.rs +++ b/backend/tests/worker.rs @@ -189,7 +189,6 @@ async fn set_jwt_secret() -> () { mod suspend_resume { use serde_json::json; - use sqlx::query_scalar; use super::*; @@ -200,11 +199,13 @@ mod suspend_resume { ) { loop { queue.by_ref().find(&flow).await.unwrap(); - if query_scalar("SELECT suspend > 0 FROM queue WHERE id = $1") - .bind(flow) - .fetch_one(db) - .await - .unwrap() + if sqlx::query_scalar!( + "SELECT suspend > 0 AS \"r!\" FROM v2_queue WHERE id = $1", + flow + ) + .fetch_one(db) + .await + .unwrap() { break; } @@ -358,7 +359,7 @@ mod suspend_resume { // ensure resumes are cleaned up through CASCADE when the flow is finished assert_eq!( 0, - query_scalar::<_, i64>("SELECT count(*) FROM resume_job") + sqlx::query_scalar!("SELECT count(*) AS \"count!\" FROM resume_job") .fetch_one(&db) .await .unwrap() @@ -925,7 +926,7 @@ impl RunJob { /* root job */ None, /* job_id */ None, /* is_flow_step */ false, - /* running */ false, + /* same_worker */ false, None, true, None, @@ -1047,11 +1048,11 @@ fn spawn_test_worker( } async fn listen_for_completed_jobs(db: &Pool) -> impl Stream + Unpin { - listen_for_uuid_on(db, "insert on completed_job").await + listen_for_uuid_on(db, "completed").await } async fn listen_for_queue(db: &Pool) -> impl Stream + Unpin { - listen_for_uuid_on(db, "queue").await + listen_for_uuid_on(db, "queued").await } async fn listen_for_uuid_on( @@ -1076,7 +1077,7 @@ async fn listen_for_uuid_on( async fn completed_job(uuid: Uuid, db: &Pool) -> CompletedJob { sqlx::query_as::<_, CompletedJob>( - "SELECT *, result->'wm_labels' as labels FROM completed_job WHERE id = $1", + "SELECT *, result->'wm_labels' as labels FROM v2_completed_job WHERE id = $1", ) .bind(uuid) .fetch_one(db) @@ -3188,11 +3189,13 @@ async fn test_script_schedule_handlers(db: Pool) { let uuid = uuid.unwrap().unwrap(); - let completed_job = - sqlx::query!("SELECT script_path FROM completed_job WHERE id = $1", uuid) - .fetch_one(&db2) - .await - .unwrap(); + let completed_job = sqlx::query!( + "SELECT script_path FROM v2_completed_job WHERE id = $1", + uuid + ) + .fetch_one(&db2) + .await + .unwrap(); if completed_job.script_path.is_none() || completed_job.script_path != Some("f/system/schedule_error_handler".to_string()) @@ -3257,7 +3260,7 @@ async fn test_script_schedule_handlers(db: Pool) { let uuid = uuid.unwrap().unwrap(); let completed_job = - sqlx::query!("SELECT script_path FROM completed_job WHERE id = $1", uuid) + sqlx::query!("SELECT script_path FROM v2_completed_job WHERE id = $1", uuid) .fetch_one(&db2) .await .unwrap(); @@ -3340,11 +3343,13 @@ async fn test_flow_schedule_handlers(db: Pool) { let uuid = uuid.unwrap().unwrap(); - let completed_job = - sqlx::query!("SELECT script_path FROM completed_job WHERE id = $1", uuid) - .fetch_one(&db2) - .await - .unwrap(); + let completed_job = sqlx::query!( + "SELECT script_path FROM v2_completed_job WHERE id = $1", + uuid + ) + .fetch_one(&db2) + .await + .unwrap(); if completed_job.script_path.is_none() || completed_job.script_path != Some("f/system/schedule_error_handler".to_string()) @@ -3410,7 +3415,7 @@ async fn test_flow_schedule_handlers(db: Pool) { let uuid = uuid.unwrap().unwrap(); let completed_job = - sqlx::query!("SELECT script_path FROM completed_job WHERE id = $1", uuid) + sqlx::query!("SELECT script_path FROM v2_completed_job WHERE id = $1", uuid) .fetch_one(&db2) .await .unwrap(); diff --git a/backend/windmill-api/src/apps.rs b/backend/windmill-api/src/apps.rs index a8cf4a5bde..0740d18f7b 100644 --- a/backend/windmill-api/src/apps.rs +++ b/backend/windmill-api/src/apps.rs @@ -1794,7 +1794,7 @@ async fn check_if_allowed_to_access_s3_file_from_app( let allowed = opt_authed.is_some() || sqlx::query_scalar!( r#"SELECT EXISTS ( - SELECT 1 FROM completed_job + SELECT 1 FROM v2_completed_job WHERE workspace_id = $2 AND (job_kind = 'appscript' OR job_kind = 'preview') AND created_by = 'anonymous' diff --git a/backend/windmill-api/src/concurrency_groups.rs b/backend/windmill-api/src/concurrency_groups.rs index 945df75573..8370dc29be 100644 --- a/backend/windmill-api/src/concurrency_groups.rs +++ b/backend/windmill-api/src/concurrency_groups.rs @@ -157,22 +157,22 @@ async fn get_concurrent_intervals( let lq = ListCompletedQuery { order_desc: Some(true), ..lq }; let lqc = lq.clone(); let lqq: ListQueueQuery = lqc.into(); - let mut sqlb_q = SqlBuilder::select_from("queue") + let mut sqlb_q = SqlBuilder::select_from("v2_queue") .fields(UnifiedJob::queued_job_fields()) .order_by("created_at", lq.order_desc.unwrap_or(true)) .limit(row_limit) .clone(); - let mut sqlb_c = SqlBuilder::select_from("completed_job") + let mut sqlb_c = SqlBuilder::select_from("v2_completed_job") .fields(UnifiedJob::completed_job_fields()) .order_by("started_at", lq.order_desc.unwrap_or(true)) .limit(row_limit) .clone(); - let mut sqlb_q_user = SqlBuilder::select_from("queue") + let mut sqlb_q_user = SqlBuilder::select_from("v2_queue") .fields(&["id"]) .order_by("created_at", lq.order_desc.unwrap_or(true)) .limit(row_limit) .clone(); - let mut sqlb_c_user = SqlBuilder::select_from("completed_job") + let mut sqlb_c_user = SqlBuilder::select_from("v2_completed_job") .fields(&["id"]) .order_by("started_at", lq.order_desc.unwrap_or(true)) .limit(row_limit) diff --git a/backend/windmill-api/src/flows.rs b/backend/windmill-api/src/flows.rs index 1b283d43f3..b4ab8a772d 100644 --- a/backend/windmill-api/src/flows.rs +++ b/backend/windmill-api/src/flows.rs @@ -913,7 +913,7 @@ async fn update_flow( })?; if let Some(old_dep_job) = old_dep_job { sqlx::query!( - "UPDATE queue SET canceled = true WHERE id = $1", + "UPDATE v2_queue SET canceled = true WHERE id = $1", old_dep_job ) .execute(&mut *new_tx) diff --git a/backend/windmill-api/src/inputs.rs b/backend/windmill-api/src/inputs.rs index 1271be1620..fc332140b4 100644 --- a/backend/windmill-api/src/inputs.rs +++ b/backend/windmill-api/src/inputs.rs @@ -133,7 +133,7 @@ async fn get_input_history( let mut tx = user_db.begin(&authed).await?; let sql = &format!( - "select id, created_at, created_by, 'null'::jsonb as args, success from completed_job \ + "select id, created_at, created_by, 'null'::jsonb as args, success from v2_completed_job \ where {} = $1 and job_kind = any($2) and workspace_id = $3 \ order by created_at desc limit $4 offset $5", r.runnable_type.column_name() @@ -204,16 +204,16 @@ async fn get_args_from_history_or_saved_input( let result_o = if let Some(input) = g.input { if input { sqlx::query_scalar!( - "SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM input WHERE id = $1 AND workspace_id = $2", - job_or_input_id, - w_id, - g.allow_large.unwrap_or(true) - ) - .fetch_optional(&mut *tx) - .await? + "SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM input WHERE id = $1 AND workspace_id = $2", + job_or_input_id, + w_id, + g.allow_large.unwrap_or(true) + ) + .fetch_optional(&mut *tx) + .await? } else { sqlx::query_scalar!( - "SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM completed_job WHERE id = $1 AND workspace_id = $2", + "SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM v2_job WHERE id = $1 AND workspace_id = $2", job_or_input_id, w_id, g.allow_large.unwrap_or(true) @@ -223,13 +223,15 @@ async fn get_args_from_history_or_saved_input( } } else { sqlx::query_scalar!( - "SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM completed_job WHERE id = $1 AND workspace_id = $2 UNION ALL SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM input WHERE id = $1 AND workspace_id = $2", - job_or_input_id, - w_id, - g.allow_large.unwrap_or(true) - ) - .fetch_optional(&mut *tx) - .await? + "SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM v2_job WHERE id = $1 AND workspace_id = $2 + UNION ALL + SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM input WHERE id = $1 AND workspace_id = $2", + job_or_input_id, + w_id, + g.allow_large.unwrap_or(true) + ) + .fetch_optional(&mut *tx) + .await? }; tx.commit().await?; diff --git a/backend/windmill-api/src/job_metrics.rs b/backend/windmill-api/src/job_metrics.rs index 2af59383a8..a763908ce9 100644 --- a/backend/windmill-api/src/job_metrics.rs +++ b/backend/windmill-api/src/job_metrics.rs @@ -171,7 +171,7 @@ async fn set_job_progress( if let Some(flow_job_id) = flow_job_id { // TODO: Return error if trying to set completed job? sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET(flow_status, ARRAY['modules', flow_status->>'step', 'progress'], $1) WHERE id = $2", serde_json::json!(percent.clamp(0, 99)), diff --git a/backend/windmill-api/src/jobs.rs b/backend/windmill-api/src/jobs.rs index 2eb119fd08..64136e24e4 100644 --- a/backend/windmill-api/src/jobs.rs +++ b/backend/windmill-api/src/jobs.rs @@ -14,6 +14,7 @@ use quick_cache::sync::Cache; use serde_json::value::RawValue; use sqlx::Pool; use std::collections::HashMap; +use std::iter; use std::ops::{Deref, DerefMut}; #[cfg(feature = "prometheus")] use std::sync::atomic::Ordering; @@ -86,7 +87,7 @@ use windmill_common::{METRICS_DEBUG_ENABLED, METRICS_ENABLED}; use windmill_common::{get_latest_deployed_hash_for_path, BASE_URL}; use windmill_queue::{ cancel_job, get_result_and_success_by_id_from_flow, job_is_complete, push, PushArgs, - PushArgsOwned, PushIsolationLevel, + PushArgsOwned, PushIsolationLevel, RawJob, }; #[cfg(feature = "prometheus")] @@ -338,7 +339,7 @@ async fn compute_root_job_for_flow(db: &DB, w_id: &str, mut job_id: Uuid) -> err // TODO: use `root_job` ? loop { job_id = match sqlx::query_scalar!( - "SELECT parent_job FROM queue WHERE id = $1 AND workspace_id = $2", + "SELECT parent_job FROM v2_queue WHERE id = $1 AND workspace_id = $2", job_id, w_id ) @@ -605,7 +606,7 @@ async fn get_flow_job_debug_info( let mut job_ids = vec![]; let jobs_with_root = sqlx::query_scalar!( - "SELECT id AS \"id!\" FROM queue WHERE workspace_id = $1 and root_job = $2", + "SELECT id AS \"id!\" FROM v2_queue WHERE workspace_id = $1 and root_job = $2", &w_id, &id, ) @@ -675,23 +676,23 @@ async fn get_job( } macro_rules! get_job_query { - ("completed_job_view", $($opts:tt)*) => { + ("v2_completed_job", $($opts:tt)*) => { get_job_query!( - @impl "completed_job_view", ($($opts)*), + @impl "v2_completed_job", ($($opts)*), "duration_ms, success, result, deleted, is_skipped, result->'wm_labels' as labels, \ CASE WHEN result is null or pg_column_size(result) < 90000 THEN result ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as result", ) }; - ("queue_view", $($opts:tt)*) => { + ("v2_queue", $($opts:tt)*) => { get_job_query!( - @impl "queue_view", ($($opts)*), + @impl "v2_queue", ($($opts)*), "scheduled_for, running, last_ping, suspend, suspend_until, same_worker, pre_run_error, visible_to_owner, \ root_job, leaf_jobs, concurrent_limit, concurrency_time_window_s, timeout, flow_step_id, cache_ttl", ) }; (@impl $table:literal, (with_logs: $with_logs:expr, $($rest:tt)*), $additional_fields:literal, $($args:tt)*) => { if $with_logs { - get_job_query!(@impl $table, ($($rest)*), $additional_fields, logs = const_format::formatcp!("right({}.logs, 20000)", $table), $($args)*) + get_job_query!(@impl $table, ($($rest)*), $additional_fields, logs = "right(job_logs.logs, 20000)", $($args)*) } else { get_job_query!(@impl $table, ($($rest)*), $additional_fields, logs = "null", $($args)*) } @@ -718,7 +719,7 @@ macro_rules! get_job_query { {logs} as logs, {code} as raw_code, canceled, canceled_by, canceled_reason, job_kind, \ schedule_path, permissioned_as, flow_status, {flow} as raw_flow, is_flow_step, language, \ {lock} as raw_lock, email, visible_to_owner, mem_peak, tag, priority, {additional_fields} \ - FROM {table} \ + FROM {table} LEFT JOIN job_logs ON id = job_id \ WHERE id = $1 AND {table}.workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3)) LIMIT 1", table = $table, additional_fields = $additional_fields, @@ -832,7 +833,7 @@ impl<'a> GetQuery<'a> { job_id: Uuid, workspace_id: &str, ) -> error::Result>> { - let query = get_job_query!("queue_view", + let query = get_job_query!("v2_queue", with_logs: self.with_logs, with_code: self.with_code, with_flow: self.with_flow, @@ -864,7 +865,7 @@ impl<'a> GetQuery<'a> { job_id: Uuid, workspace_id: &str, ) -> error::Result>> { - let query = get_job_query!("completed_job_view", + let query = get_job_query!("v2_completed_job", with_logs: self.with_logs, with_code: self.with_code, with_flow: self.with_flow, @@ -1012,10 +1013,10 @@ async fn get_job_logs( .flatten(); let record = sqlx::query!( - "SELECT created_by AS \"created_by!\", CONCAT(coalesce(completed_job.logs, ''), coalesce(job_logs.logs, '')) as logs, job_logs.log_offset, job_logs.log_file_index - FROM completed_job - LEFT JOIN job_logs ON job_logs.job_id = completed_job.id - WHERE completed_job.id = $1 AND completed_job.workspace_id = $2 AND ($3::text[] IS NULL OR completed_job.tag = ANY($3))", + "SELECT created_by AS \"created_by!\", CONCAT(coalesce(v2_completed_job.logs, ''), coalesce(job_logs.logs, '')) as logs, job_logs.log_offset, job_logs.log_file_index + FROM v2_completed_job + LEFT JOIN job_logs ON job_logs.job_id = v2_completed_job.id + WHERE v2_completed_job.id = $1 AND v2_completed_job.workspace_id = $2 AND ($3::text[] IS NULL OR v2_completed_job.tag = ANY($3))", id, w_id, tags.as_ref().map(|v| v.as_slice()) @@ -1049,10 +1050,10 @@ async fn get_job_logs( Ok(content_plain(Body::from(logs))) } else { let text = sqlx::query!( - "SELECT created_by AS \"created_by!\", CONCAT(coalesce(queue.logs, ''), coalesce(job_logs.logs, '')) as logs, coalesce(job_logs.log_offset, 0) as log_offset, job_logs.log_file_index - FROM queue - LEFT JOIN job_logs ON job_logs.job_id = queue.id - WHERE queue.id = $1 AND queue.workspace_id = $2 AND ($3::text[] IS NULL OR queue.tag = ANY($3))", + "SELECT created_by AS \"created_by!\", CONCAT(coalesce(v2_queue.logs, ''), coalesce(job_logs.logs, '')) as logs, coalesce(job_logs.log_offset, 0) as log_offset, job_logs.log_file_index + FROM v2_queue + LEFT JOIN job_logs ON job_logs.job_id = v2_queue.id + WHERE v2_queue.id = $1 AND v2_queue.workspace_id = $2 AND ($3::text[] IS NULL OR v2_queue.tag = ANY($3))", id, w_id, tags.as_ref().map(|v| v.as_slice()) @@ -1101,7 +1102,7 @@ async fn get_args( .flatten(); let record = sqlx::query!( "SELECT created_by AS \"created_by!\", args as \"args: sqlx::types::Json>\" - FROM completed_job + FROM v2_completed_job WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", id, &w_id, @@ -1123,7 +1124,7 @@ async fn get_args( } else { let record = sqlx::query!( "SELECT created_by AS \"created_by!\", args as \"args: sqlx::types::Json>\" - FROM queue + FROM v2_queue WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", id, &w_id, @@ -1396,7 +1397,7 @@ pub fn list_queue_jobs_query( tags: Option>, ) -> SqlBuilder { let (limit, offset) = paginate_without_limits(pagination); - let mut sqlb = SqlBuilder::select_from("queue") + let mut sqlb = SqlBuilder::select_from("v2_queue") .fields(fields) .order_by("created_at", lq.order_desc.unwrap_or(true)) .limit(limit) @@ -1484,82 +1485,46 @@ async fn cancel_jobs( w_id: &str, ) -> error::JsonResult> { let mut uuids = vec![]; - let mut tx = db.begin().await?; - let trivial_jobs = sqlx::query!("INSERT INTO completed_job AS cj - ( workspace_id - , id - , parent_job - , created_by - , created_at - , started_at - , duration_ms - , success - , script_hash - , script_path - , args - , result - , raw_code - , raw_lock - , canceled - , canceled_by - , canceled_reason - , job_kind - , schedule_path - , permissioned_as - , flow_status - , raw_flow - , is_flow_step - , is_skipped - , language - , email - , visible_to_owner - , mem_peak - , tag - , priority - ) - SELECT workspace_id - , id - , parent_job - , created_by - , created_at - , now() - , 0 - , false - , script_hash - , script_path - , args - , $4 - , raw_code - , raw_lock - , true - , $1 - , canceled_reason - , job_kind - , schedule_path - , permissioned_as - , flow_status - , raw_flow - , is_flow_step - , false - , language - , email - , visible_to_owner - , mem_peak - , tag - , priority FROM queue - WHERE id = any($2) AND running = false AND parent_job IS NULL AND workspace_id = $3 AND schedule_path IS NULL FOR UPDATE SKIP LOCKED - ON CONFLICT (id) DO NOTHING RETURNING id AS \"id!\"", username, &jobs, w_id, serde_json::json!({"error": { "message": format!("Job canceled: cancel all by {username}"), "name": "Canceled", "reason": "cancel all", "canceler": username}})) - .fetch_all(&mut *tx) - .await?.into_iter().map(|x| x.id).collect::>(); - sqlx::query!( - "DELETE FROM queue WHERE id = any($1) AND workspace_id = $2", - &trivial_jobs, - w_id + let trivial_jobs = sqlx::query_scalar!( + "WITH queued AS ( + DELETE FROM v2_job_queue q + USING v2_job j + WHERE + q.id = ANY ($2) AND q.id = j.id + AND q.running = false AND j.parent_job IS NULL AND q.workspace_id = $3 + AND j.trigger IS NULL + RETURNING + q.id, q.workspace_id, q.started_at, q.worker + ), queued_and_runtime AS ( + SELECT queued.*, memory_peak, flow_status + FROM queued + JOIN v2_job_runtime USING (id) + LEFT JOIN v2_job_flow_runtime USING (id) + ) INSERT INTO v2_job_completed ( + id, workspace_id, + duration_ms, result, canceled_by, canceled_reason, status, + flow_status, started_at, memory_peak, worker + ) SELECT + id, workspace_id, + 0, $4, $1, 'cancel all', 'canceled'::job_status, + flow_status, started_at, memory_peak, worker + FROM queued_and_runtime + ON CONFLICT (id) DO NOTHING RETURNING id", + username, + &jobs, + w_id, + serde_json::json!({ + "error": { + "message": format!("Job canceled: cancel all by {username}"), + "name": "Canceled", + "reason": "cancel all", + "canceler": username + } + }) ) - .execute(&mut *tx) + .fetch_all(db) .await?; - tx.commit().await?; // sqlx::query!( // "UPDATE queue SET canceled = true, canceled_by = $1, canceled_reason = 'cancelled all by user' WHERE id IN (SELECT id FROM queue where id = any($2) AND workspace_id = $3 AND schedule_path IS NULL FOR UPDATE SKIP LOCKED) RETURNING id", @@ -1621,7 +1586,7 @@ async fn cancel_selection( let mut tx = user_db.begin(&authed).await?; let tags = get_scope_tags(&authed).map(|v| v.iter().map(|s| s.to_string()).collect_vec()); let jobs_to_cancel = sqlx::query_scalar!( - "SELECT id AS \"id!\" FROM queue WHERE id = ANY($1) AND schedule_path IS NULL AND ($2::text[] IS NULL OR tag = ANY($2))", + "SELECT id AS \"id!\" FROM v2_queue WHERE id = ANY($1) AND schedule_path IS NULL AND ($2::text[] IS NULL OR tag = ANY($2))", &jobs, tags.as_ref().map(|v| v.as_slice()) ) @@ -1641,7 +1606,7 @@ async fn list_filtered_uuids( ) -> error::JsonResult> { require_admin(authed.is_admin, &authed.username)?; - let mut sqlb = SqlBuilder::select_from("queue").fields(&["id"]).clone(); + let mut sqlb = SqlBuilder::select_from("v2_queue").fields(&["id"]).clone(); sqlb = join_concurrency_key(lq.concurrency_key.as_ref(), sqlb); @@ -1678,7 +1643,7 @@ async fn count_queue_jobs( Ok(Json( sqlx::query_as!( QueueStats, - "SELECT coalesce(COUNT(*) FILTER(WHERE suspend = 0 AND running = false), 0) as \"database_length!\", coalesce(COUNT(*) FILTER(WHERE suspend > 0), 0) as \"suspended!\" FROM queue WHERE (workspace_id = $1 OR $2) AND scheduled_for <= now()", + "SELECT coalesce(COUNT(*) FILTER(WHERE suspend = 0 AND running = false), 0) as \"database_length!\", coalesce(COUNT(*) FILTER(WHERE suspend > 0), 0) as \"suspended!\" FROM v2_queue WHERE (workspace_id = $1 OR $2) AND scheduled_for <= now()", w_id, w_id == "admins" && cq.all_workspaces.unwrap_or(false), ) @@ -1700,7 +1665,7 @@ async fn count_completed_jobs_detail( Path(w_id): Path, Query(query): Query, ) -> error::JsonResult { - let mut sqlb = SqlBuilder::select_from("completed_job"); + let mut sqlb = SqlBuilder::select_from("v2_completed_job"); sqlb.field("COUNT(*) as count"); if !query.all_workspaces.unwrap_or(false) { @@ -1742,7 +1707,7 @@ async fn count_completed_jobs( Ok(Json( sqlx::query_as!( QueueStats, - "SELECT coalesce(COUNT(*), 0) as \"database_length!\", null::bigint as suspended FROM completed_job WHERE workspace_id = $1", + "SELECT coalesce(COUNT(*), 0) as \"database_length!\", null::bigint as suspended FROM v2_completed_job WHERE workspace_id = $1", w_id ) .fetch_one(&db) @@ -1956,7 +1921,7 @@ async fn resume_suspended_job_internal( if !approved { sqlx::query!( - "UPDATE queue SET suspend = 0 WHERE id = $1", + "UPDATE v2_queue SET suspend = 0 WHERE id = $1", parent_flow_info.id ) .execute(&mut *tx) @@ -2028,7 +1993,7 @@ async fn resume_immediately_if_relevant<'c>( if matches!(status.current_step(), Some(FlowStatusModule::WaitingForEvents { job, .. }) if job == &job_id) { sqlx::query!( - "UPDATE queue SET suspend = $1 WHERE id = $2", + "UPDATE v2_queue SET suspend = $1 WHERE id = $2", suspend, flow.id, ) @@ -2079,9 +2044,11 @@ async fn get_suspended_parent_flow_info(job_id: Uuid, db: &DB) -> error::Result< let flow = sqlx::query_as!( FlowInfo, r#" - SELECT id AS "id!", flow_status, suspend AS "suspend!", script_path - FROM queue - WHERE id = ( SELECT parent_job FROM queue WHERE id = $1 UNION ALL SELECT parent_job FROM completed_job WHERE id = $1) + SELECT q.id, f.flow_status, q.suspend, j.runnable_path AS script_path + FROM v2_job_queue q + JOIN v2_job j USING (id) + JOIN v2_job_flow_runtime f USING (id) + WHERE id = ( SELECT parent_job FROM v2_job WHERE id = $1 ) FOR UPDATE "#, job_id, @@ -2100,7 +2067,7 @@ async fn get_suspended_flow_info<'c>( FlowInfo, r#" SELECT id AS "id!", flow_status, suspend AS "suspend!", script_path - FROM queue + FROM v2_queue WHERE id = $1 "#, job_id, @@ -2159,11 +2126,7 @@ pub async fn get_suspended_job_flow( let flow_id = sqlx::query_scalar!( r#" SELECT parent_job - FROM queue - WHERE id = $1 AND workspace_id = $2 - UNION ALL - SELECT parent_job - FROM completed_job + FROM v2_job WHERE id = $1 AND workspace_id = $2 "#, job, @@ -2300,7 +2263,7 @@ pub async fn get_flow_user_state( let r = sqlx::query_scalar!( r#" SELECT flow_status->'user_states'->$1 - FROM queue + FROM v2_queue WHERE id = $2 AND workspace_id = $3 "#, key, @@ -2322,7 +2285,7 @@ pub async fn set_flow_user_state( let mut tx = user_db.begin(&authed).await?; let r = sqlx::query_scalar!( r#" - UPDATE queue SET flow_status = JSONB_SET(flow_status, ARRAY['user_states'], JSONB_SET(COALESCE(flow_status->'user_states', '{}'::jsonb), ARRAY[$1], $2)) + UPDATE v2_queue SET flow_status = JSONB_SET(flow_status, ARRAY['user_states'], JSONB_SET(COALESCE(flow_status->'user_states', '{}'::jsonb), ARRAY[$1], $2)) WHERE id = $3 AND workspace_id = $4 AND job_kind IN ('flow', 'flowpreview', 'flownode') RETURNING 1 "#, key, @@ -2761,7 +2724,7 @@ impl<'a> From for Job { parent_job: uj.parent_job, created_by: uj.created_by, created_at: uj.created_at, - started_at: uj.started_at.unwrap_or(uj.created_at), + started_at: uj.started_at, duration_ms: uj.duration_ms.unwrap(), success: uj.success.unwrap(), script_hash: uj.script_hash, @@ -3137,7 +3100,7 @@ pub async fn restart_flow( "SELECT script_path, args AS \"args: sqlx::types::Json>>\", tag AS \"tag!\", priority - FROM completed_job + FROM v2_completed_job WHERE id = $1 and workspace_id = $2", job_id, &w_id, @@ -3437,7 +3400,7 @@ pub async fn run_workflow_as_code( if !wkflow_query.skip_update.unwrap_or(false) { sqlx::query!( - "UPDATE queue SET flow_status = jsonb_set(COALESCE(flow_status, '{}'::jsonb), array[$1], jsonb_set(jsonb_set('{}'::jsonb, '{scheduled_for}', to_jsonb(now()::text)), '{name}', to_jsonb($4::text))) WHERE id = $2 AND workspace_id = $3", + "UPDATE v2_queue SET flow_status = jsonb_set(COALESCE(flow_status, '{}'::jsonb), array[$1], jsonb_set(jsonb_set('{}'::jsonb, '{scheduled_for}', to_jsonb(now()::text)), '{name}', to_jsonb($4::text))) WHERE id = $2 AND workspace_id = $3", uuid.to_string(), job_id, w_id, @@ -3574,7 +3537,7 @@ pub async fn run_wait_result( language AS \"language: ScriptLang\", flow_status AS \"flow_status: sqlx::types::Json>\", success AS \"success!\" - FROM completed_job + FROM v2_completed_job WHERE id = $1 AND workspace_id = $2", uuid, &w_id @@ -3687,7 +3650,7 @@ pub async fn run_wait_result( async fn delete_job_metadata_after_use(db: &DB, job_uuid: Uuid) -> Result<(), Error> { sqlx::query!( - "UPDATE completed_job + "UPDATE v2_completed_job SET logs = '##DELETED##', args = '{}'::jsonb, result = '{}'::jsonb WHERE id = $1", job_uuid, @@ -3708,7 +3671,7 @@ async fn delete_job_metadata_after_use(db: &DB, job_uuid: Uuid) -> Result<(), Er pub async fn check_queue_too_long(db: &DB, queue_limit: Option) -> error::Result<()> { if let Some(limit) = queue_limit { let count = sqlx::query_scalar!( - "SELECT COUNT(*) FROM queue WHERE canceled = false AND (scheduled_for <= now() + "SELECT COUNT(*) FROM v2_queue WHERE canceled = false AND (scheduled_for <= now() OR (suspend_until IS NOT NULL AND ( suspend <= 0 OR suspend_until <= now())))", @@ -4662,7 +4625,7 @@ async fn add_batch_jobs( dedicated_worker, custom_concurrency_key, concurrent_limit, - concurrent_time_window_s, + concurrency_time_window_s, timeout, raw_code, raw_lock, @@ -4815,52 +4778,32 @@ async fn add_batch_jobs( }; let mut tx = user_db.begin(&authed).await?; - - let uuids = sqlx::query_scalar!( - r#"WITH uuid_table as ( - select gen_random_uuid() as uuid from generate_series(1, $6) - ) - INSERT INTO job - (id, workspace_id, raw_code, raw_lock, raw_flow, tag) - (SELECT uuid, $1, $2, $3, $4, $5 FROM uuid_table) - RETURNING id AS "id!""#, - w_id, - raw_code, - raw_lock, - raw_flow.map(sqlx::types::Json) as Option>, - tag, - n - ) - .fetch_all(&mut *tx) + let uuids = Vec::from_iter(iter::repeat_with(|| ulid::Ulid::new().into()).take(n as usize)); + let args = uuids + .iter() + .map(|uuid| sqlx::types::Json(to_raw_value(&serde_json::json!({ "uuid": uuid })))) + .collect::>(); + tx = RawJob { + created_by: &authed.username, + permissioned_as: &username_to_permissioned_as(&authed.username), + permissioned_as_email: &authed.email, + kind: job_kind, + runnable_id: hash.map(|h| h.0), + runnable_path: path.as_deref(), + script_lang: Some(language), + tag: &tag, + concurrent_limit, + concurrency_time_window_s, + timeout, + raw_code: raw_code.as_deref(), + raw_lock: raw_lock.as_deref(), + raw_flow: raw_flow.as_ref(), + flow_status: flow_status.as_ref(), + ..RawJob::default() + } + .push_many(tx, &uuids, &w_id, &args) .await?; - let uuids = sqlx::query_scalar!( - r#"WITH uuid_table as ( - select unnest($11::uuid[]) as uuid - ) - INSERT INTO queue - (id, script_hash, script_path, job_kind, language, args, tag, created_by, permissioned_as, email, scheduled_for, workspace_id, concurrent_limit, concurrency_time_window_s, timeout, flow_status) - (SELECT uuid, $1, $2, $3, $4, ('{ "uuid": "' || uuid || '" }')::jsonb, $5, $6, $7, $8, $9, $10, $12, $13, $14, $15 FROM uuid_table) - RETURNING id AS "id!""#, - hash.map(|h| h.0), - path, - job_kind.clone() as JobKind, - language as ScriptLang, - tag, - authed.username, - username_to_permissioned_as(&authed.username), - authed.email, - Utc::now(), - w_id, - &uuids, - concurrent_limit, - concurrent_time_window_s, - timeout, - flow_status.map(sqlx::types::Json) as Option> - ) - .fetch_all(&mut *tx) - .await?; - if let Some(custom_concurrency_key) = custom_concurrency_key { sqlx::query!( "INSERT INTO concurrency_key (job_id, key) SELECT id, $1 FROM unnest($2::uuid[]) as id", @@ -5139,14 +5082,14 @@ async fn get_job_update( let record = sqlx::query!( "SELECT running AS \"running!\", - substr(concat(coalesce(queue.logs, ''), job_logs.logs), greatest($1 - job_logs.log_offset, 0)) AS logs, + substr(concat(coalesce(v2_queue.logs, ''), job_logs.logs), greatest($1 - job_logs.log_offset, 0)) AS logs, mem_peak, CASE WHEN is_flow_step is true then NULL else flow_status END AS \"flow_status: sqlx::types::Json>\", job_logs.log_offset + char_length(job_logs.logs) + 1 AS log_offset, created_by AS \"created_by!\" - FROM queue - LEFT JOIN job_logs ON job_logs.job_id = queue.id - WHERE queue.workspace_id = $2 AND queue.id = $3", + FROM v2_queue + LEFT JOIN job_logs ON job_logs.job_id = v2_queue.id + WHERE v2_queue.workspace_id = $2 AND v2_queue.id = $3", log_offset, &w_id, job_id @@ -5192,14 +5135,14 @@ async fn get_job_update( } else { let record = sqlx::query!( "SELECT - substr(concat(coalesce(completed_job.logs, ''), job_logs.logs), greatest($1 - job_logs.log_offset, 0)) AS logs, + substr(concat(coalesce(v2_completed_job.logs, ''), job_logs.logs), greatest($1 - job_logs.log_offset, 0)) AS logs, mem_peak, CASE WHEN is_flow_step is true then NULL else flow_status END AS \"flow_status: sqlx::types::Json>\", job_logs.log_offset + char_length(job_logs.logs) + 1 AS log_offset, created_by AS \"created_by!\" - FROM completed_job - LEFT JOIN job_logs ON job_logs.job_id = completed_job.id - WHERE completed_job.workspace_id = $2 AND completed_job.id = $3", + FROM v2_completed_job + LEFT JOIN job_logs ON job_logs.job_id = v2_completed_job.id + WHERE v2_completed_job.workspace_id = $2 AND v2_completed_job.id = $3", log_offset, &w_id, job_id @@ -5346,7 +5289,7 @@ pub fn list_completed_jobs_query( join_outstanding_wait_times: bool, tags: Option>, ) -> SqlBuilder { - let mut sqlb = SqlBuilder::select_from("completed_job") + let mut sqlb = SqlBuilder::select_from("v2_completed_job") .fields(fields) .order_by("created_at", lq.order_desc.unwrap_or(true)) .offset(offset) @@ -5512,7 +5455,7 @@ async fn get_completed_job_result( flow_status AS \"flow_status: sqlx::types::Json>\", language AS \"language: ScriptLang\", created_by AS \"created_by!\" - FROM completed_job + FROM v2_completed_job WHERE id = $1 AND workspace_id = $2 AND ($4::text[] IS NULL OR tag = ANY($4))", id, &w_id, @@ -5529,7 +5472,7 @@ async fn get_completed_job_result( flow_status AS \"flow_status: sqlx::types::Json>\", language AS \"language: ScriptLang\", created_by AS \"created_by!\" - FROM completed_job + FROM v2_completed_job WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", id, &w_id, @@ -5547,7 +5490,7 @@ async fn get_completed_job_result( let mut parent_job = id; while parent_job != suspended_job { let p_job = sqlx::query_scalar!( - "SELECT parent_job FROM queue WHERE id = $1 AND workspace_id = $2", + "SELECT parent_job FROM v2_queue WHERE id = $1 AND workspace_id = $2", parent_job, &w_id ) @@ -5614,7 +5557,7 @@ async fn count_by_tag( TagCount, r#" SELECT tag as "tag!", COUNT(*) as "count!" - FROM completed_job + FROM v2_completed_job WHERE started_at > NOW() - make_interval(secs => $1) AND ($2::text IS NULL OR workspace_id = $2) GROUP BY tag ORDER BY "count!" DESC @@ -5657,7 +5600,7 @@ async fn get_completed_job_result_maybe( language AS \"language: ScriptLang\", flow_status AS \"flow_status: sqlx::types::Json>\", created_by AS \"created_by!\" - FROM completed_job + FROM v2_completed_job WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", id, &w_id, @@ -5689,7 +5632,7 @@ async fn get_completed_job_result_maybe( .into_response()) } else if get_started.is_some_and(|x| x) { let started = sqlx::query_scalar!( - "SELECT running AS \"running!\" FROM queue WHERE id = $1 AND workspace_id = $2", + "SELECT running AS \"running!\" FROM v2_queue WHERE id = $1 AND workspace_id = $2", id, w_id ) @@ -5726,7 +5669,7 @@ async fn delete_completed_job<'a>( require_admin(authed.is_admin, &authed.username)?; let tags = get_scope_tags(&authed); let job_o = sqlx::query_as::<_, CompletedJob>( - "UPDATE completed_job SET args = null, logs = '', result = null, deleted = true WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3)) \ + "UPDATE v2_completed_job SET args = null, logs = '', result = null, deleted = true WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3)) \ RETURNING *, null as labels", ) .bind(id) diff --git a/backend/windmill-api/src/resources.rs b/backend/windmill-api/src/resources.rs index 8848ed866f..7ce92d00fd 100644 --- a/backend/windmill-api/src/resources.rs +++ b/backend/windmill-api/src/resources.rs @@ -544,7 +544,7 @@ pub async fn transform_json_value<'c>( parent_job, permissioned_as AS \"permissioned_as!\", script_path, schedule_path, flow_step_id, root_job, scheduled_for AS \"scheduled_for!: chrono::DateTime\" - FROM queue WHERE id = $1 AND workspace_id = $2", + FROM v2_queue WHERE id = $1 AND workspace_id = $2", job_id, workspace ) @@ -557,7 +557,7 @@ pub async fn transform_json_value<'c>( let flow_path = if let Some(uuid) = job.parent_job { let mut tx: Transaction<'_, Postgres> = authed_transaction_or_default(authed, user_db.clone(), db).await?; - let p = sqlx::query_scalar!("SELECT script_path FROM queue WHERE id = $1", uuid) + let p = sqlx::query_scalar!("SELECT script_path FROM v2_queue WHERE id = $1", uuid) .fetch_optional(&mut *tx) .await? .flatten(); diff --git a/backend/windmill-api/src/schedule.rs b/backend/windmill-api/src/schedule.rs index 79e8c4dcb4..d58996ddc4 100644 --- a/backend/windmill-api/src/schedule.rs +++ b/backend/windmill-api/src/schedule.rs @@ -407,8 +407,8 @@ async fn list_schedule_with_jobs( let mut tx = user_db.begin(&authed).await?; let (per_page, offset) = paginate(pagination); let rows = sqlx::query_as!(ScheduleWJobs, - "SELECT schedule.*, t.jobs FROM schedule, LATERAL ( SELECT ARRAY (SELECT json_build_object('id', id, 'success', success, 'duration_ms', duration_ms) FROM completed_job WHERE - completed_job.schedule_path = schedule.path AND completed_job.workspace_id = $1 AND parent_job IS NULL AND is_skipped = False ORDER BY started_at DESC LIMIT 20) AS jobs ) t + "SELECT schedule.*, t.jobs FROM schedule, LATERAL ( SELECT ARRAY (SELECT json_build_object('id', id, 'success', success, 'duration_ms', duration_ms) FROM v2_completed_job WHERE + v2_completed_job.schedule_path = schedule.path AND v2_completed_job.workspace_id = $1 AND parent_job IS NULL AND is_skipped = False ORDER BY started_at DESC LIMIT 20) AS jobs ) t WHERE schedule.workspace_id = $1 ORDER BY schedule.edited_at desc LIMIT $2 OFFSET $3", w_id, per_page as i64, @@ -838,7 +838,7 @@ pub async fn clear_schedule<'c>( ) -> Result<()> { tracing::info!("Clearing schedule {}", path); sqlx::query!( - "DELETE FROM queue WHERE schedule_path = $1 AND running = false AND workspace_id = $2 AND is_flow_step = false", + "DELETE FROM v2_queue WHERE schedule_path = $1 AND running = false AND workspace_id = $2 AND is_flow_step = false", path, w_id ) diff --git a/backend/windmill-api/src/slack_approvals.rs b/backend/windmill-api/src/slack_approvals.rs index fb027916ef..fcaa5b121c 100644 --- a/backend/windmill-api/src/slack_approvals.rs +++ b/backend/windmill-api/src/slack_approvals.rs @@ -448,10 +448,16 @@ async fn transform_schemas( let is_required = required.unwrap().contains(key); let default_value = default_args_json.and_then(|json| json.get(key).cloned()); - let dynamic_enums_value = dynamic_enums_json.and_then(|json| json.get(key).cloned()); + let dynamic_enums_value = + dynamic_enums_json.and_then(|json| json.get(key).cloned()); - let input_block = - create_input_block(key, schema, is_required, default_value, dynamic_enums_value); + let input_block = create_input_block( + key, + schema, + is_required, + default_value, + dynamic_enums_value, + ); match input_block { serde_json::Value::Array(arr) => blocks.extend(arr), _ => blocks.push(input_block), @@ -536,7 +542,7 @@ fn create_input_block( // Handle date-time format if let FieldType::String = schema.r#type { - if schema.format.as_deref() == Some("date-time") { + if schema.format.as_deref() == Some("date-time") { tracing::debug!("Date-time type"); let now = chrono::Local::now(); let current_date = now.format("%Y-%m-%d").to_string(); @@ -971,17 +977,17 @@ async fn get_modal_blocks( let (job_kind, script_hash, raw_flow, parent_job_id, created_at, created_by, script_path, args) = sqlx::query!( "SELECT - queue.job_kind AS \"job_kind!: JobKind\", - queue.script_hash AS \"script_hash: ScriptHash\", - queue.raw_flow AS \"raw_flow: sqlx::types::Json>\", - completed_job.parent_job AS \"parent_job: Uuid\", - completed_job.created_at AS \"created_at!: chrono::NaiveDateTime\", - completed_job.created_by AS \"created_by!\", - queue.script_path, - queue.args AS \"args: sqlx::types::Json>\" - FROM queue - JOIN completed_job ON completed_job.parent_job = queue.id - WHERE completed_job.id = $1 AND completed_job.workspace_id = $2 + v2_queue.job_kind AS \"job_kind!: JobKind\", + v2_queue.script_hash AS \"script_hash: ScriptHash\", + v2_queue.raw_flow AS \"raw_flow: sqlx::types::Json>\", + v2_completed_job.parent_job AS \"parent_job: Uuid\", + v2_completed_job.created_at AS \"created_at!: chrono::NaiveDateTime\", + v2_completed_job.created_by AS \"created_by!\", + v2_queue.script_path, + v2_queue.args AS \"args: sqlx::types::Json>\" + FROM v2_queue + JOIN v2_completed_job ON v2_completed_job.parent_job = v2_queue.id + WHERE v2_completed_job.id = $1 AND v2_completed_job.workspace_id = $2 LIMIT 1", job_id, &w_id diff --git a/backend/windmill-api/src/users.rs b/backend/windmill-api/src/users.rs index fdb40d97c5..c065715587 100644 --- a/backend/windmill-api/src/users.rs +++ b/backend/windmill-api/src/users.rs @@ -471,7 +471,7 @@ async fn list_user_usage( FROM usr , LATERAL ( SELECT COALESCE(SUM(duration_ms + 1000)/1000 , 0)::BIGINT executions - FROM completed_job + FROM v2_completed_job WHERE workspace_id = $1 AND job_kind NOT IN ('flow', 'flowpreview', 'flownode') AND email = usr.email @@ -2309,25 +2309,9 @@ async fn update_username_in_workpsace<'c>( .execute(&mut **tx) .await?; - // ---- queue ---- + // ---- v2_job ---- sqlx::query!( - r#"UPDATE queue SET script_path = REGEXP_REPLACE(script_path,'u/' || $2 || '/(.*)','u/' || $1 || '/\1') WHERE script_path LIKE ('u/' || $2 || '/%') AND workspace_id = $3"#, - new_username, - old_username, - w_id - ).execute(&mut **tx) - .await?; - - sqlx::query!( - r#"UPDATE queue SET schedule_path = REGEXP_REPLACE(schedule_path,'u/' || $2 || '/(.*)','u/' || $1 || '/\1') WHERE schedule_path LIKE ('u/' || $2 || '/%') AND workspace_id = $3"#, - new_username, - old_username, - w_id - ).execute(&mut **tx) - .await?; - - sqlx::query!( - "UPDATE queue SET permissioned_as = ('u/' || $1) WHERE permissioned_as = ('u/' || $2) AND workspace_id = $3", + r#"UPDATE v2_job SET runnable_path = REGEXP_REPLACE(runnable_path,'u/' || $2 || '/(.*)','u/' || $1 || '/\1') WHERE runnable_path LIKE ('u/' || $2 || '/%') AND workspace_id = $3"#, new_username, old_username, w_id @@ -2336,44 +2320,7 @@ async fn update_username_in_workpsace<'c>( .await?; sqlx::query!( - "UPDATE queue SET canceled_by = $1 WHERE canceled_by = $2 AND workspace_id = $3", - new_username, - old_username, - w_id - ) - .execute(&mut **tx) - .await - .unwrap(); - - sqlx::query!( - "UPDATE queue SET created_by = $1 WHERE created_by = $2 AND workspace_id = $3", - new_username, - old_username, - w_id - ) - .execute(&mut **tx) - .await - .unwrap(); - - // ---- completed_job ---- - sqlx::query!( - r#"UPDATE completed_job SET script_path = REGEXP_REPLACE(script_path,'u/' || $2 || '/(.*)','u/' || $1 || '/\1') WHERE script_path LIKE ('u/' || $2 || '/%') AND workspace_id = $3"#, - new_username, - old_username, - w_id - ).execute(&mut **tx) - .await?; - - sqlx::query!( - r#"UPDATE completed_job SET schedule_path = REGEXP_REPLACE(schedule_path,'u/' || $2 || '/(.*)','u/' || $1 || '/\1') WHERE schedule_path LIKE ('u/' || $2 || '/%') AND workspace_id = $3"#, - new_username, - old_username, - w_id - ).execute(&mut **tx) - .await?; - - sqlx::query!( - "UPDATE completed_job SET permissioned_as = ('u/' || $1) WHERE permissioned_as = ('u/' || $2) AND workspace_id = $3", + r#"UPDATE v2_job SET trigger = REGEXP_REPLACE(trigger,'u/' || $2 || '/(.*)','u/' || $1 || '/\1') WHERE trigger LIKE ('u/' || $2 || '/%') AND workspace_id = $3"#, new_username, old_username, w_id @@ -2382,24 +2329,42 @@ async fn update_username_in_workpsace<'c>( .await?; sqlx::query!( - "UPDATE completed_job SET created_by = $1 WHERE created_by = $2 AND workspace_id = $3", + "UPDATE v2_job SET permissioned_as = ('u/' || $1) WHERE permissioned_as = ('u/' || $2) AND workspace_id = $3", new_username, old_username, w_id ) .execute(&mut **tx) - .await - .unwrap(); + .await?; sqlx::query!( - "UPDATE completed_job SET canceled_by = $1 WHERE canceled_by = $2 AND workspace_id = $3", + "UPDATE v2_job SET created_by = $1 WHERE created_by = $2 AND workspace_id = $3", new_username, old_username, w_id ) .execute(&mut **tx) - .await - .unwrap(); + .await?; + + // ---- v2_job_queue ---- + sqlx::query!( + "UPDATE v2_job_queue SET canceled_by = $1 WHERE canceled_by = $2 AND workspace_id = $3", + new_username, + old_username, + w_id + ) + .execute(&mut **tx) + .await?; + + // ---- v2_job_completed job ---- + sqlx::query!( + "UPDATE v2_job_completed SET canceled_by = $1 WHERE canceled_by = $2 AND workspace_id = $3", + new_username, + old_username, + w_id + ) + .execute(&mut **tx) + .await?; // ---- resources---- sqlx::query!( diff --git a/backend/windmill-api/src/websocket_triggers.rs b/backend/windmill-api/src/websocket_triggers.rs index ed0dc56035..f14c2b5f41 100644 --- a/backend/windmill-api/src/websocket_triggers.rs +++ b/backend/windmill-api/src/websocket_triggers.rs @@ -560,7 +560,7 @@ async fn wait_runnable_result( let result = sqlx::query!( "SELECT result AS \"result: SqlxJson>\", success AS \"success!\" - FROM completed_job WHERE id = $1 AND workspace_id = $2", + FROM v2_completed_job WHERE id = $1 AND workspace_id = $2", Uuid::parse_str(&job_id)?, workspace_id ) diff --git a/backend/windmill-api/src/workspaces_extra.rs b/backend/windmill-api/src/workspaces_extra.rs index a8f0c8721d..2378e85c02 100644 --- a/backend/windmill-api/src/workspaces_extra.rs +++ b/backend/windmill-api/src/workspaces_extra.rs @@ -144,7 +144,7 @@ pub(crate) async fn change_workspace_id( .await?; sqlx::query!( - "UPDATE completed_job SET workspace_id = $1 WHERE workspace_id = $2", + "UPDATE v2_job_completed SET workspace_id = $1 WHERE workspace_id = $2", &rw.new_id, &old_id ) @@ -269,7 +269,7 @@ pub(crate) async fn change_workspace_id( .await?; sqlx::query!( - "UPDATE queue SET workspace_id = $1 WHERE workspace_id = $2", + "UPDATE v2_job_queue SET workspace_id = $1 WHERE workspace_id = $2", &rw.new_id, &old_id ) @@ -277,7 +277,7 @@ pub(crate) async fn change_workspace_id( .await?; sqlx::query!( - "UPDATE job SET workspace_id = $1 WHERE workspace_id = $2", + "UPDATE v2_job SET workspace_id = $1 WHERE workspace_id = $2", &rw.new_id, &old_id ) @@ -430,7 +430,10 @@ pub(crate) async fn delete_workspace( sqlx::query!("DELETE FROM dependency_map WHERE workspace_id = $1", &w_id) .execute(&mut *tx) .await?; - sqlx::query!("DELETE FROM queue WHERE workspace_id = $1", &w_id) + sqlx::query!("DELETE FROM v2_job_queue WHERE workspace_id = $1", &w_id) + .execute(&mut *tx) + .await?; + sqlx::query!("DELETE FROM v2_job WHERE workspace_id = $1", &w_id) .execute(&mut *tx) .await?; sqlx::query!("DELETE FROM capture WHERE workspace_id = $1", &w_id) @@ -468,9 +471,12 @@ pub(crate) async fn delete_workspace( .execute(&mut *tx) .await?; - sqlx::query!("DELETE FROM completed_job WHERE workspace_id = $1", &w_id) - .execute(&mut *tx) - .await?; + sqlx::query!( + "DELETE FROM v2_job_completed WHERE workspace_id = $1", + &w_id + ) + .execute(&mut *tx) + .await?; sqlx::query!("DELETE FROM job_stats WHERE workspace_id = $1", &w_id) .execute(&mut *tx) diff --git a/backend/windmill-common/src/bench.rs b/backend/windmill-common/src/bench.rs deleted file mode 100644 index 0e89af571c..0000000000 --- a/backend/windmill-common/src/bench.rs +++ /dev/null @@ -1,213 +0,0 @@ -use crate::{ - worker::{write_file, TMP_DIR}, - DB, -}; -use serde::Serialize; -use tokio::time::Instant; - -#[derive(Serialize)] -pub struct BenchmarkInfo { - #[serde(skip)] - pub start: Instant, - #[serde(skip)] - pub iters: u64, - timings: Vec, - pub iter_durations: Vec, - pub total_duration: Option, -} - -impl BenchmarkInfo { - pub fn new() -> Self { - BenchmarkInfo { - iters: 0, - timings: vec![], - start: Instant::now(), - iter_durations: vec![], - total_duration: None, - } - } - - pub fn add_iter(&mut self, bench: BenchmarkIter, inc_iters: bool) { - if inc_iters { - self.iters += 1; - } - let elapsed_total = bench.start.elapsed().as_nanos() as u64; - self.timings.push(bench); - self.iter_durations.push(elapsed_total); - } - - pub fn write_to_file(&mut self, path: &str) -> anyhow::Result<()> { - let total_duration = self.start.elapsed().as_millis() as u64; - self.total_duration = Some(total_duration as u64); - - println!( - "Writing benchmark {path}, duration of benchmark: {total_duration}s and RPS: {}", - self.iters as f64 / total_duration as f64 - ); - write_file(TMP_DIR, path, &serde_json::to_string(&self).unwrap()).expect("write profiling"); - Ok(()) - } -} - -#[derive(Serialize)] -pub struct BenchmarkIter { - #[serde(skip)] - pub start: Instant, - #[serde(skip)] - last_instant: Instant, - last_step: String, - timings: Vec<(String, u32)>, -} - -impl BenchmarkIter { - pub fn new() -> Self { - BenchmarkIter { - last_instant: Instant::now(), - timings: vec![], - start: Instant::now(), - last_step: String::new(), - } - } - - pub fn add_timing(&mut self, name: &str) { - let elapsed = self.last_instant.elapsed().as_nanos() as u32; - self.timings - .push((format!("{}->{}", self.last_step, name), elapsed)); - self.last_instant = Instant::now(); - self.last_step = name.to_string(); - } -} - -pub async fn benchmark_init(benchmark_jobs: i32, db: &DB) { - use crate::{jobs::JobKind, scripts::ScriptLang}; - - let benchmark_kind = std::env::var("BENCHMARK_KIND").unwrap_or("noop".to_string()); - - if benchmark_jobs > 0 { - match benchmark_kind.as_str() { - "dedicated" => { - // you need to create the script first, check https://github.com/windmill-labs/windmill/blob/b76a92cfe454c686f005c65f534e29e039f3c706/benchmarks/lib.ts#L47 - let hash = sqlx::query_scalar!( - "SELECT hash FROM script WHERE path = $1 AND workspace_id = $2", - "f/benchmarks/dedicated", - "admins" - ) - .fetch_one(db) - .await - .unwrap_or_else(|_e| panic!("failed to insert dedicated jobs")); - sqlx::query!("INSERT INTO queue (id, script_hash, script_path, job_kind, language, tag, created_by, permissioned_as, email, scheduled_for, workspace_id) (SELECT gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9, $10 FROM generate_series(1, $11))", - hash, - "f/benchmarks/dedicated", - JobKind::Script as JobKind, - ScriptLang::Bun as ScriptLang, - "admins:f/benchmarks/dedicated", - "admin", - "u/admin", - "admin@windmill.dev", - chrono::Utc::now(), - "admins", - benchmark_jobs - ) - .execute(db) - .await.unwrap_or_else(|_e| panic!("failed to insert dedicated jobs")); - } - "parallelflow" => { - //create dedicated script - sqlx::query!("INSERT INTO script (summary, description, dedicated_worker, content, workspace_id, path, hash, language, tag, created_by, lock) VALUES ('', '', true, $1, $2, $3, $4, $5, $6, $7, '') ON CONFLICT (workspace_id, hash) DO NOTHING", - "export async function main() { - console.log('hello world'); - }", - "admins", - "u/admin/parallelflow", - 1234567890, - ScriptLang::Deno as ScriptLang, - "flow", - "admin", - ) - .execute(db) - .await.unwrap_or_else(|_e| panic!("failed to insert parallelflow jobs {_e:#}")); - sqlx::query!("INSERT INTO queue (id, script_hash, script_path, job_kind, language, tag, created_by, permissioned_as, email, scheduled_for, workspace_id, raw_flow, flow_status) (SELECT gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12 FROM generate_series(1, 1))", - None::, - None::, - JobKind::FlowPreview as JobKind, - ScriptLang::Deno as ScriptLang, - "flow", - "admin", - "u/admin", - "admin@windmill.dev", - chrono::Utc::now(), - "admins", - serde_json::from_str::(r#" -{ - "modules": [ - { - "id": "a", - "value": { - "type": "forloopflow", - "modules": [ - { - "id": "b", - "value": { - "path": "u/admin/parallelflow", - "type": "script", - "tag_override": "", - "input_transforms": {} - }, - "summary": "calctest" - } - ], - "iterator": { - "expr": "[...new Array(300)]", - "type": "javascript" - }, - "parallel": true, - "parallelism": 10, - "skip_failures": true - } - } - ], - "preprocessor_module": null -} - "#).unwrap(), - serde_json::from_str::(r#" -{ - "step": 0, - "modules": [ - { - "id": "a", - "type": "WaitingForPriorSteps" - } - ], - "cleanup_module": {}, - "failure_module": { - "id": "failure", - "type": "WaitingForPriorSteps" - }, - "preprocessor_module": null - } - - "#).unwrap() - ) - .execute(db) - .await.unwrap_or_else(|_e| panic!("failed to insert parallelflow jobs")); - } - _ => { - sqlx::query!("INSERT INTO queue (id, script_hash, script_path, job_kind, language, tag, created_by, permissioned_as, email, scheduled_for, workspace_id) (SELECT gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9, $10 FROM generate_series(1, $11))", - None::, - None::, - JobKind::Noop as JobKind, - ScriptLang::Deno as ScriptLang, - "deno", - "admin", - "u/admin", - "admin@windmill.dev", - chrono::Utc::now(), - "admins", - benchmark_jobs - ) - .execute(db) - .await.unwrap_or_else(|_e| panic!("failed to insert noop jobs")); - } - } - } -} diff --git a/backend/windmill-common/src/cache.rs b/backend/windmill-common/src/cache.rs index 13d71dd402..1efe481aa6 100644 --- a/backend/windmill-common/src/cache.rs +++ b/backend/windmill-common/src/cache.rs @@ -672,7 +672,7 @@ pub mod job { match (raw_lock, raw_code, raw_flow) { (None, None, None) => sqlx::query!( "SELECT raw_code, raw_lock, raw_flow AS \"raw_flow: Json>\" \ - FROM job WHERE id = $1 LIMIT 1", + FROM v2_job WHERE id = $1 LIMIT 1", job ) .fetch_optional(e) diff --git a/backend/windmill-common/src/jobs.rs b/backend/windmill-common/src/jobs.rs index 13a8dd7e8a..7ac6464cc9 100644 --- a/backend/windmill-common/src/jobs.rs +++ b/backend/windmill-common/src/jobs.rs @@ -46,6 +46,21 @@ pub enum JobKind { AppScript, } +#[derive(sqlx::Type, Serialize, Deserialize, Debug, PartialEq, Copy, Clone)] +#[sqlx(type_name = "JOB_TRIGGER_KIND", rename_all = "lowercase")] +#[serde(rename_all(serialize = "lowercase"))] +pub enum JobTriggerKind { + Webhook, + Http, + Websocket, + Kafka, + Email, + Nats, + Schedule, + App, + Ui, +} + impl JobKind { pub fn is_flow(&self) -> bool { matches!( @@ -197,7 +212,7 @@ pub struct CompletedJob { pub parent_job: Option, pub created_by: String, pub created_at: chrono::DateTime, - pub started_at: chrono::DateTime, + pub started_at: Option>, pub duration_ms: i64, pub success: bool, #[serde(skip_serializing_if = "Option::is_none")] diff --git a/backend/windmill-common/src/lib.rs b/backend/windmill-common/src/lib.rs index 9fcd14111f..b039faec63 100644 --- a/backend/windmill-common/src/lib.rs +++ b/backend/windmill-common/src/lib.rs @@ -18,8 +18,6 @@ use sqlx::{Pool, Postgres}; pub mod apps; pub mod auth; -#[cfg(feature = "benchmark")] -pub mod bench; pub mod cache; pub mod db; pub mod ee; diff --git a/backend/windmill-common/src/queue.rs b/backend/windmill-common/src/queue.rs index 3b427e9bb4..93c26e7d7d 100644 --- a/backend/windmill-common/src/queue.rs +++ b/backend/windmill-common/src/queue.rs @@ -4,7 +4,7 @@ use sqlx::{Pool, Postgres}; pub async fn get_queue_counts(db: &Pool) -> HashMap { sqlx::query!( - "SELECT tag AS \"tag!\", count(*) AS \"count!\" FROM queue WHERE + "SELECT tag AS \"tag!\", count(*) AS \"count!\" FROM v2_queue WHERE scheduled_for <= now() - ('3 seconds')::interval AND running = false GROUP BY tag", ) diff --git a/backend/windmill-common/src/worker.rs b/backend/windmill-common/src/worker.rs index 81c3537c8a..a6c3257bf5 100644 --- a/backend/windmill-common/src/worker.rs +++ b/backend/windmill-common/src/worker.rs @@ -109,14 +109,14 @@ pub async fn make_suspended_pull_query(wc: &WorkerConfig) { return; } let query = format!( - "UPDATE queue + "UPDATE v2_queue SET running = true , started_at = coalesce(started_at, now()) , last_ping = now() , suspend_until = null WHERE id = ( SELECT id - FROM queue + FROM v2_job_queue WHERE suspend_until IS NOT NULL AND (suspend <= 0 OR suspend_until <= now()) AND tag IN ({}) ORDER BY priority DESC NULLS LAST, created_at FOR UPDATE SKIP LOCKED @@ -141,14 +141,14 @@ pub async fn make_pull_query(wc: &WorkerConfig) { tracing::error!("Empty tags in priority tags, skipping"); continue; } - let query = format!("UPDATE queue + let query = format!("UPDATE v2_queue SET running = true , started_at = coalesce(started_at, now()) , last_ping = now() , suspend_until = null WHERE id = ( SELECT id - FROM queue + FROM v2_job_queue WHERE running = false AND tag IN ({}) AND scheduled_for <= now() ORDER BY priority DESC NULLS LAST, scheduled_for FOR UPDATE SKIP LOCKED diff --git a/backend/windmill-queue/src/jobs.rs b/backend/windmill-queue/src/jobs.rs index 05f7a8ceaf..65d2dec244 100644 --- a/backend/windmill-queue/src/jobs.rs +++ b/backend/windmill-queue/src/jobs.rs @@ -40,8 +40,8 @@ use windmill_common::{ add_virtual_items_if_necessary, FlowModule, FlowModuleValue, FlowValue, InputTransform, }, jobs::{ - get_payload_tag_from_prefixed_path, JobKind, JobPayload, QueuedJob, RawCode, - ENTRYPOINT_OVERRIDE, PREPROCESSOR_FAKE_ENTRYPOINT, + get_payload_tag_from_prefixed_path, JobKind, JobPayload, JobTriggerKind, QueuedJob, + RawCode, ENTRYPOINT_OVERRIDE, PREPROCESSOR_FAKE_ENTRYPOINT, }, schedule::Schedule, scripts::{get_full_hub_script_by_path, ScriptHash, ScriptLang}, @@ -49,8 +49,8 @@ use windmill_common::{ utils::{not_found_if_none, report_critical_error, StripPath, WarnAfterExt}, worker::{ to_raw_value, CLOUD_HOSTED, DEFAULT_TAGS_PER_WORKSPACE, DEFAULT_TAGS_WORKSPACES, - DISABLE_FLOW_SCRIPT, MIN_VERSION_IS_AT_LEAST_1_427, MIN_VERSION_IS_AT_LEAST_1_432, - MIN_VERSION_IS_AT_LEAST_1_440, NO_LOGS, WORKER_PULL_QUERIES, WORKER_SUSPENDED_PULL_QUERY, + DISABLE_FLOW_SCRIPT, MIN_VERSION_IS_AT_LEAST_1_432, MIN_VERSION_IS_AT_LEAST_1_440, NO_LOGS, + WORKER_PULL_QUERIES, WORKER_SUSPENDED_PULL_QUERY, }, DB, METRICS_ENABLED, }; @@ -173,7 +173,7 @@ pub async fn cancel_single_job<'c>( }); } else { let id: Option = sqlx::query_scalar!( - "UPDATE queue SET canceled = true, canceled_by = $1, canceled_reason = $2, scheduled_for = now(), suspend = 0 WHERE id = $3 AND workspace_id = $4 AND (canceled = false OR canceled_reason != $2) RETURNING id AS \"id!\"", + "UPDATE v2_queue SET canceled = true, canceled_by = $1, canceled_reason = $2, scheduled_for = now(), suspend = 0 WHERE id = $3 AND workspace_id = $4 AND (canceled = false OR canceled_reason != $2) RETURNING id AS \"id!\"", username, reason, job_running.id, @@ -249,7 +249,7 @@ pub async fn cancel_job<'c>( while !jobs.is_empty() { let p_job = jobs.pop(); let new_jobs = sqlx::query_scalar!( - "SELECT id AS \"id!\" FROM queue WHERE parent_job = $1 AND workspace_id = $2", + "SELECT id AS \"id!\" FROM v2_queue WHERE parent_job = $1 AND workspace_id = $2", p_job, w_id ) @@ -360,11 +360,11 @@ async fn cancel_persistent_script_jobs_internal<'c>( let mut tx = db.begin().await?; // we could have retrieved the job IDs in the first query where we retrieve the hashes, but just in case a job was inserted in the queue right in-between the two above query, we re-do the fetch here - let jobs_to_cancel = sqlx::query_scalar::<_, Uuid>( - "SELECT id FROM queue WHERE workspace_id = $1 AND script_path = $2 AND canceled = false", + let jobs_to_cancel = sqlx::query_scalar!( + "SELECT id as \"id!\" FROM v2_queue WHERE workspace_id = $1 AND script_path = $2 AND canceled = false", + w_id, + script_path ) - .bind(w_id) - .bind(script_path) .fetch_all(&mut *tx) .await?; @@ -533,11 +533,12 @@ pub async fn add_completed_job( )); } - let _job_id = queued_job.id; - let (opt_uuid, _duration, _skip_downstream_error_handlers) = (|| async { + let job_id = queued_job.id; + let (canceled_by, canceled_reason) = + canceled_by.map_or((None, None), |c| (c.username, c.reason)); + let (opt_uuid, canceled, _duration, _skip_downstream_error_handlers) = (|| async { let mut tx = db.begin().await?; - let job_id = queued_job.id; // tracing::error!("1 {:?}", start.elapsed()); tracing::debug!( @@ -546,139 +547,81 @@ pub async fn add_completed_job( serde_json::to_string(&result).unwrap_or_else(|_| "".to_string()) ); - let (raw_code, raw_lock, raw_flow) = if !*MIN_VERSION_IS_AT_LEAST_1_427.read().await { - sqlx::query!( - "SELECT raw_code, raw_lock, raw_flow AS \"raw_flow: Json>\" - FROM job WHERE id = $1 AND workspace_id = $2 LIMIT 1", - &job_id, - &queued_job.workspace_id - ) - .fetch_one(db) - .map_ok(|record| (record.raw_code, record.raw_lock, record.raw_flow)) - .or_else(|_| { - sqlx::query!( - "SELECT raw_code, raw_lock, raw_flow AS \"raw_flow: Json>\" - FROM queue WHERE id = $1 AND workspace_id = $2 LIMIT 1", - &job_id, - &queued_job.workspace_id - ) - .fetch_one(db) - .map_ok(|record| (record.raw_code, record.raw_lock, record.raw_flow)) - }) - .await - .unwrap_or_default() - } else { - (None, None, None) - }; - - let mem_peak = mem_peak.max(queued_job.mem_peak.unwrap_or(0)); // add_time!(bench, "add_completed_job query START"); - let _duration = sqlx::query_scalar!( - "INSERT INTO completed_job AS cj - ( workspace_id - , id - , parent_job - , created_by - , created_at - , started_at - , duration_ms - , success - , script_hash - , script_path - , args - , result - , raw_code - , raw_lock - , canceled - , canceled_by - , canceled_reason - , job_kind - , schedule_path - , permissioned_as - , flow_status - , raw_flow - , is_flow_step - , is_skipped - , language - , email - , visible_to_owner - , mem_peak - , tag - , priority - ) - VALUES ($1, $2, $3, $4, $5, COALESCE($6, now()), COALESCE($30::bigint, (EXTRACT('epoch' FROM (now())) - EXTRACT('epoch' FROM (COALESCE($6, now()))))*1000), $7, $8, $9,\ - $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29) - ON CONFLICT (id) DO UPDATE SET success = $7, result = $11 RETURNING duration_ms AS \"duration_ms!\"", - queued_job.workspace_id, - queued_job.id, - queued_job.parent_job, - queued_job.created_by, - queued_job.created_at, - queued_job.started_at, - success, - queued_job.script_hash.map(|x| x.0), - queued_job.script_path, - &queued_job.args as &Option>>>, - result as Json<&T>, - raw_code, - raw_lock, - canceled_by.is_some(), - canceled_by.clone().map(|cb| cb.username).flatten(), - canceled_by.clone().map(|cb| cb.reason).flatten(), - queued_job.job_kind.clone() as JobKind, - queued_job.schedule_path, - queued_job.permissioned_as, - &queued_job.flow_status as &Option>>, - &raw_flow as &Option>>, - queued_job.is_flow_step, - skipped, - queued_job.language.clone() as Option, - queued_job.email, - queued_job.visible_to_owner, - if mem_peak > 0 { Some(mem_peak) } else { None }, - queued_job.tag, - queued_job.priority, - duration, + let (canceled, _duration) = sqlx::query!( + "WITH runtime AS ( + SELECT GREATEST($8, r.memory_peak) AS memory_peak, flow_status + FROM v2_job_runtime r + LEFT JOIN v2_job_flow_runtime f USING (id) + WHERE r.id = $1 + ), queued AS ( + DELETE FROM v2_job_queue q + WHERE q.id = $1 + RETURNING + q.id, q.workspace_id, q.started_at, q.worker, + COALESCE($5, q.canceled_by) AS canceled_by, + COALESCE($6, q.canceled_reason) AS canceled_reason + ) INSERT INTO v2_job_completed ( + id, workspace_id, started_at, worker, memory_peak, flow_status, result, + canceled_by, canceled_reason, + duration_ms, + status + ) SELECT + id, workspace_id, started_at, worker, memory_peak, flow_status, $7, + canceled_by, canceled_reason, + COALESCE($2::bigint, CASE + WHEN started_at IS NULL THEN 0 + ELSE (EXTRACT('epoch' FROM NOW()) - EXTRACT('epoch' FROM started_at)) * 1000 + END) AS duration_ms, + CASE + WHEN $4::BOOLEAN THEN 'skipped'::job_status + WHEN canceled_by IS NOT NULL THEN 'canceled'::job_status + WHEN $3::BOOLEAN THEN 'success'::job_status + ELSE 'failure'::job_status + END AS status + FROM queued, runtime + ON CONFLICT (id) DO UPDATE SET status = EXCLUDED.status, result = EXCLUDED.result + RETURNING status = 'canceled' AS \"canceled!\", duration_ms", + /* $1 */ queued_job.id, + /* $2 */ duration, + /* $3 */ success, + /* $4 */ skipped, + /* $5 */ canceled_by, + /* $6 */ canceled_reason, + /* $7 */ result as Json<&T>, + /* $8 */ if mem_peak > 0 { Some(mem_peak) } else { None }, ) + .map(|record| (record.canceled, record.duration_ms)) .fetch_one(&mut *tx) .await .map_err(|e| Error::InternalErr(format!("Could not add completed job {job_id}: {e:#}")))?; - + // Hacky trick used by `workflow_as_code` if !queued_job.is_flow_step { - if _duration > 500 - && (queued_job.job_kind == JobKind::Script - || queued_job.job_kind == JobKind::Preview) - { - if let Err(e) = sqlx::query!( - "UPDATE completed_job SET flow_status = q.flow_status FROM queue q WHERE completed_job.id = $1 AND q.id = $1 AND q.workspace_id = $2 AND completed_job.workspace_id = $2 AND q.flow_status IS NOT NULL", - &queued_job.id, - &queued_job.workspace_id - ) - .execute(&mut *tx) - .await { - tracing::error!("Could not update job duration: {}", e); - } - } if let Some(parent_job) = queued_job.parent_job { - if let Err(e) = sqlx::query_scalar!( - "UPDATE queue SET flow_status = jsonb_set(jsonb_set(COALESCE(flow_status, '{}'::jsonb), array[$1], COALESCE(flow_status->$1, '{}'::jsonb)), array[$1, 'duration_ms'], to_jsonb($2::bigint)) WHERE id = $3 AND workspace_id = $4", - &queued_job.id.to_string(), - _duration, - parent_job, - &queued_job.workspace_id - ) - .execute(&mut *tx) - .await { - tracing::error!("Could not update parent job flow_status: {}", e); - } + let _ = sqlx::query_scalar!( + "UPDATE v2_job_flow_runtime SET flow_status = jsonb_set( + jsonb_set( + COALESCE(flow_status, '{}'::jsonb), + array[$1], + COALESCE(flow_status->$1, '{}'::jsonb) + ), + array[$1, 'duration_ms'], + to_jsonb($2::bigint) + ) WHERE id = $3", + &queued_job.id.to_string(), + _duration, + parent_job + ) + .execute(&mut *tx) + .await + .inspect_err(|e| tracing::error!("Could not update parent job flow_status: {}", e)); } } // tracing::error!("Added completed job {:#?}", queued_job); let mut _skip_downstream_error_handlers = false; - tx = delete_job(tx, &queued_job.workspace_id, job_id).await?; // tracing::error!("3 {:?}", start.elapsed()); if queued_job.is_flow_step { @@ -689,7 +632,7 @@ pub async fn add_completed_job( parent_job ); sqlx::query!( - "UPDATE queue SET last_ping = now() WHERE id = $1 AND workspace_id = $2 AND canceled = false", + "UPDATE v2_queue SET last_ping = now() WHERE id = $1 AND workspace_id = $2 AND canceled = false", parent_job, &queued_job.workspace_id ) @@ -738,7 +681,7 @@ pub async fn add_completed_job( AND flow_status->'modules'->0->>'job' = $1 ) ) - FROM completed_job WHERE id = $2 AND workspace_id = $3", + FROM v2_completed_job WHERE id = $2 AND workspace_id = $3", Uuid::nil().to_string(), &queued_job.id, &queued_job.workspace_id @@ -757,7 +700,7 @@ pub async fn add_completed_job( match err { Error::QuotaExceeded(_) => (), // scheduling next job failed and could not disable schedule => make zombie job to retry - _ => return Ok((Some(job_id), 0, true)), + _ => return Ok((Some(job_id), canceled, 0, true)), } }; } @@ -868,7 +811,7 @@ pub async fn add_completed_job( "inserted completed job: {} (success: {success})", queued_job.id ); - Ok((None, _duration, _skip_downstream_error_handlers)) as windmill_common::error::Result<(Option, i64, bool)> + Result::Ok((None, canceled, _duration, _skip_downstream_error_handlers)) }) .retry( ConstantBuilder::default() @@ -928,15 +871,14 @@ pub async fn add_completed_job( if let Ok(flow) = cache::job::fetch_flow(db, job.job_kind, job.script_hash).await { return flow.value().failure_module.is_some(); } - sqlx::query_scalar!("SELECT raw_flow->'failure_module' != 'null'::jsonb FROM job WHERE id = $1", job.id) - .fetch_one(db) - .or_else(|_| - sqlx::query_scalar!("SELECT raw_flow->'failure_module' != 'null'::jsonb FROM completed_job WHERE id = $1", job.id) - .fetch_one(db) - ) - .await - .unwrap_or(Some(false)) - .unwrap_or(false) + sqlx::query_scalar!( + "SELECT raw_flow->'failure_module' != 'null'::jsonb FROM v2_job WHERE id = $1", + job.id + ) + .fetch_one(db) + .await + .unwrap_or(Some(false)) + .unwrap_or(false) } if queued_job.email == ERROR_HANDLER_USER_EMAIL { @@ -1003,13 +945,8 @@ pub async fn add_completed_job( ); } - if let Err(err) = send_error_to_workspace_handler( - &queued_job, - canceled_by.is_some(), - db, - Json(&result), - ) - .await + if let Err(err) = + send_error_to_workspace_handler(&queued_job, canceled, db, Json(&result)).await { match err { Error::QuotaExceeded(_) => {} @@ -1028,7 +965,7 @@ pub async fn add_completed_job( } } - if !queued_job.is_flow_step && queued_job.job_kind == JobKind::Script && canceled_by.is_none() { + if !queued_job.is_flow_step && queued_job.job_kind == JobKind::Script && !canceled { if let Some(hash) = queued_job.script_hash { let p = sqlx::query_scalar!( "SELECT restart_unless_cancelled FROM script WHERE hash = $1 AND workspace_id = $2", @@ -1386,7 +1323,7 @@ async fn apply_schedule_handlers<'a, 'c, T: Serialize + Send + Sync>( success AS \"success!\", result AS \"result: Json>\", started_at AS \"started_at!\" - FROM completed_job + FROM v2_completed_job WHERE workspace_id = $1 AND schedule_path = $2 AND script_path = $3 AND id != $4 ORDER BY created_at DESC LIMIT $5", @@ -1457,7 +1394,7 @@ async fn apply_schedule_handlers<'a, 'c, T: Serialize + Send + Sync>( success AS \"success!\", result AS \"result: Json>\", started_at AS \"started_at!\"\ - FROM completed_job WHERE workspace_id = $1 AND schedule_path = $2 AND script_path = $3 AND id != $4 + FROM v2_completed_job WHERE workspace_id = $1 AND schedule_path = $2 AND script_path = $3 AND id != $4 ORDER BY created_at DESC LIMIT $5", &schedule.workspace_id, @@ -1891,7 +1828,7 @@ pub async fn pull( ); sqlx::query_scalar!( - "SELECT null FROM queue WHERE id = $1 FOR UPDATE", + "SELECT null FROM v2_job_queue WHERE id = $1 FOR UPDATE", pulled_job.id ) .fetch_one(&mut *tx) @@ -1932,7 +1869,7 @@ pub async fn pull( let min_started_at = sqlx::query!( "SELECT COALESCE((SELECT MIN(started_at) as min_started_at - FROM queue + FROM v2_queue WHERE script_path = $1 AND job_kind != 'dependencies' AND running = true AND workspace_id = $2 AND canceled = false AND concurrent_limit > 0), $3) as min_started_at, now() AS now", job_script_path, &pulled_job.workspace_id, @@ -1979,7 +1916,7 @@ pub async fn pull( let job_uuid: Uuid = pulled_job.id; let avg_script_duration: Option = sqlx::query_scalar!( "SELECT CAST(ROUND(AVG(duration_ms), 0) AS BIGINT) AS avg_duration_s FROM - (SELECT duration_ms FROM concurrency_key LEFT JOIN completed_job ON completed_job.id = concurrency_key.job_id WHERE key = $1 AND ended_at IS NOT NULL + (SELECT duration_ms FROM concurrency_key LEFT JOIN v2_completed_job ON v2_completed_job.id = concurrency_key.job_id WHERE key = $1 AND ended_at IS NOT NULL ORDER BY ended_at DESC LIMIT 10) AS t", job_concurrency_key @@ -2011,7 +1948,7 @@ pub async fn pull( loop { let nestimated = estimated_next_schedule_timestamp + inc; let jobs_in_window = sqlx::query_scalar!( - "SELECT COUNT(*) FROM queue LEFT JOIN concurrency_key ON concurrency_key.job_id = queue.id + "SELECT COUNT(*) FROM v2_queue LEFT JOIN concurrency_key ON concurrency_key.job_id = v2_queue.id WHERE key = $1 AND running = false AND canceled = false AND scheduled_for >= $2 AND scheduled_for < $3", job_concurrency_key, estimated_next_schedule_timestamp, @@ -2035,7 +1972,7 @@ pub async fn pull( // if using posgtres, then we're able to re-queue the entire batch of scheduled job for this script_path, so we do it sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET running = false , started_at = null , scheduled_for = $1 @@ -2228,8 +2165,8 @@ pub async fn get_result_by_id( "SELECT id As \"id!\", flow_status->'restarted_from'->'flow_job_id' AS \"restarted_from: Json\" - FROM queue - WHERE COALESCE((SELECT root_job FROM queue WHERE id = $1), $1) = id AND workspace_id = $2", + FROM v2_queue + WHERE COALESCE((SELECT root_job FROM v2_queue WHERE id = $1), $1) = id AND workspace_id = $2", flow_id, &w_id ) @@ -2308,7 +2245,7 @@ pub async fn get_result_and_success_by_id_from_flow( JobResult::SingleJob(job_id) => { sqlx::query_scalar!( "SELECT success AS \"success!\" - FROM completed_job WHERE id = $1 AND workspace_id = $2", + FROM v2_completed_job WHERE id = $1 AND workspace_id = $2", job_id, w_id ) @@ -2325,7 +2262,11 @@ pub async fn get_result_and_success_by_id_from_flow( SELECT module->>'type' = 'Success' FROM modules WHERE module->>'id' = $3"#, - if completed { "completed_job" } else { "queue" } + if completed { + "v2_completed_job" + } else { + "v2_queue" + } ); sqlx::query_scalar(&query) .bind(flow_id) @@ -2366,8 +2307,8 @@ pub async fn get_result_by_id_from_running_flow_inner( ) -> error::Result { let flow_job_result = sqlx::query!( "SELECT leaf_jobs->$1::text AS \"leaf_jobs: Json>\", parent_job - FROM queue - WHERE COALESCE((SELECT root_job FROM queue WHERE id = $2), $2) = id AND workspace_id = $3", + FROM v2_queue + WHERE COALESCE((SELECT root_job FROM v2_queue WHERE id = $2), $2) = id AND workspace_id = $3", node_id, flow_id, w_id, @@ -2388,11 +2329,12 @@ pub async fn get_result_by_id_from_running_flow_inner( if job_result.is_none() && flow_job_result.parent_job.is_some() { let parent_job = flow_job_result.parent_job.unwrap(); - let root_job = sqlx::query_scalar!("SELECT root_job FROM queue WHERE id = $1", parent_job) - .fetch_optional(db) - .await? - .flatten() - .unwrap_or(parent_job); + let root_job = + sqlx::query_scalar!("SELECT root_job FROM v2_queue WHERE id = $1", parent_job) + .fetch_optional(db) + .await? + .flatten() + .unwrap_or(parent_job); return get_result_by_id_from_running_flow_inner(db, w_id, &root_job, node_id).await; } @@ -2429,7 +2371,7 @@ async fn get_completed_flow_node_result_rec( } else { let subflows = sqlx::query!( "SELECT id AS \"id!\", flow_status AS \"flow_status!: Json\" - FROM completed_job + FROM v2_completed_job WHERE parent_job = $1 AND workspace_id = $2 AND flow_status IS NOT NULL", id, w_id @@ -2460,7 +2402,7 @@ async fn get_result_by_id_from_original_flow_inner( ) -> error::Result { let flow_job = sqlx::query!( "SELECT id AS \"id!\", flow_status AS \"flow_status!: Json\" - FROM completed_job WHERE id = $1 AND workspace_id = $2", + FROM v2_completed_job WHERE id = $1 AND workspace_id = $2", completed_flow_id, w_id ) @@ -2514,7 +2456,7 @@ async fn extract_result_from_job_result( }; Ok(sqlx::query_scalar!( "SELECT result #> $3 AS \"result: Json>\" - FROM completed_job WHERE id = $1 AND workspace_id = $2", + FROM v2_completed_job WHERE id = $1 AND workspace_id = $2", job_id, w_id, parts.collect::>() as Vec<&str> @@ -2528,7 +2470,7 @@ async fn extract_result_from_job_result( None => { let rows = sqlx::query!( "SELECT id AS \"id!\", result AS \"result: Json>\" - FROM completed_job WHERE id = ANY($1) AND workspace_id = $2", + FROM v2_completed_job WHERE id = ANY($1) AND workspace_id = $2", job_ids.as_slice(), w_id ) @@ -2550,7 +2492,7 @@ async fn extract_result_from_job_result( }, JobResult::SingleJob(x) => Ok(sqlx::query!( "SELECT result #> $3 AS \"result: Json>\" - FROM completed_job WHERE id = $1 AND workspace_id = $2", + FROM v2_completed_job WHERE id = $1 AND workspace_id = $2", x, w_id, json_path @@ -2577,7 +2519,7 @@ pub async fn delete_job<'c>( } let job_removed = sqlx::query_scalar!( - "DELETE FROM queue WHERE workspace_id = $1 AND id = $2 RETURNING 1", + "DELETE FROM v2_queue WHERE workspace_id = $1 AND id = $2 RETURNING 1", w_id, job_id ) @@ -2601,7 +2543,7 @@ pub async fn delete_job<'c>( pub async fn job_is_complete(db: &DB, id: Uuid, w_id: &str) -> error::Result { Ok(sqlx::query_scalar!( - "SELECT EXISTS(SELECT 1 FROM completed_job WHERE id = $1 AND workspace_id = $2)", + "SELECT EXISTS(SELECT 1 FROM v2_completed_job WHERE id = $1 AND workspace_id = $2)", id, w_id ) @@ -2617,7 +2559,7 @@ async fn get_queued_job_tx<'c>( ) -> error::Result> { sqlx::query_as::<_, QueuedJob>( "SELECT * - FROM queue WHERE id = $1 AND workspace_id = $2", + FROM v2_queue WHERE id = $1 AND workspace_id = $2", ) .bind(id) .bind(w_id) @@ -2629,7 +2571,7 @@ async fn get_queued_job_tx<'c>( pub async fn get_queued_job(id: &Uuid, w_id: &str, db: &DB) -> error::Result> { sqlx::query_as::<_, QueuedJob>( "SELECT * - FROM queue WHERE id = $1 AND workspace_id = $2", + FROM v2_queue WHERE id = $1 AND workspace_id = $2", ) .bind(id) .bind(w_id) @@ -2742,6 +2684,184 @@ lazy_static::lazy_static! { pub static ref RE_ARG_TAG: Regex = Regex::new(r#"\$args\[(\w+)\]"#).unwrap(); } +pub struct RawJob<'a> { + pub created_by: &'a str, + pub permissioned_as: &'a str, + pub permissioned_as_email: &'a str, + pub kind: JobKind, + pub runnable_id: Option, + pub runnable_path: Option<&'a str>, + pub parent_job: Option, + pub script_lang: Option, + pub flow_step_id: Option<&'a str>, + pub flow_root_job: Option, + pub trigger: Option<&'a str>, + pub trigger_kind: Option, + pub tag: &'a str, + pub same_worker: bool, + pub visible_to_owner: bool, + pub concurrent_limit: Option, + pub concurrency_time_window_s: Option, + pub cache_ttl: Option, + pub timeout: Option, + pub priority: Option, + pub pre_run_error: Option<&'a str>, + pub raw_code: Option<&'a str>, + pub raw_lock: Option<&'a str>, + pub raw_flow: Option<&'a FlowValue>, + pub flow_status: Option<&'a FlowStatus>, + pub scheduled_for: Option>, + pub running: bool, +} + +impl<'a> RawJob<'a> { + pub const fn default() -> Self { + Self { + created_by: "missing", + permissioned_as: "g/all", + permissioned_as_email: "missing@email.xyz", + kind: JobKind::Script, + runnable_id: None, + runnable_path: None, + parent_job: None, + script_lang: None, + flow_step_id: None, + flow_root_job: None, + trigger: None, + trigger_kind: None, + tag: "other", + same_worker: false, + visible_to_owner: false, + concurrent_limit: None, + concurrency_time_window_s: None, + cache_ttl: None, + timeout: None, + priority: None, + pre_run_error: None, + raw_code: None, + raw_lock: None, + raw_flow: None, + flow_status: None, + scheduled_for: None, + running: false, + } + } + + pub async fn push<'c>( + &self, + tx: sqlx::PgTransaction<'c>, + id: Uuid, + workspace_id: &str, + args: Json>, + ) -> error::Result> { + self.push_many(tx, &[id], workspace_id, &[args]).await + } + + pub async fn push_many<'c>( + &self, + mut tx: sqlx::PgTransaction<'c>, + id: &[Uuid], + workspace_id: &str, + args: &[Json>], + ) -> error::Result> { + if id.len() > args.len() { + return Err(Error::InternalErr( + "args must be at least as long as id".to_string(), + )); + } + let created_at = Utc::now(); + sqlx::query!( + "INSERT INTO v2_job ( + id, workspace_id, + created_at, created_by, permissioned_as, permissioned_as_email, + kind, runnable_id, runnable_path, parent_job, script_lang, + flow_step_id, flow_root_job, + trigger, trigger_kind, + tag, same_worker, visible_to_owner, concurrent_limit, concurrency_time_window_s, + cache_ttl, timeout, priority, + args, pre_run_error, + raw_code, raw_lock, raw_flow + ) SELECT + unnest($1::uuid[]), $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, + $16, $17, $18, $19, $20, $21, $22, $23, unnest($24::jsonb[]), $25, $26, $27, $28 + ", + id, + workspace_id, + created_at, + self.created_by, + self.permissioned_as, + self.permissioned_as_email, + self.kind as JobKind, + self.runnable_id, + self.runnable_path, + self.parent_job, + self.script_lang as Option, + self.flow_step_id, + self.flow_root_job, + self.trigger, + self.trigger_kind as Option, + self.tag, + self.same_worker, + self.visible_to_owner, + self.concurrent_limit, + self.concurrency_time_window_s, + self.cache_ttl, + self.timeout, + self.priority, + args as &[Json>], + self.pre_run_error, + self.raw_code, + self.raw_lock, + self.raw_flow.map(Json) as Option>, + ) + .execute(&mut *tx) + .warn_after_seconds(1) + .await?; + sqlx::query!( + "INSERT INTO v2_job_queue ( + id, workspace_id, started_at, scheduled_for, running, created_at, tag, priority + ) SELECT unnest($1::uuid[]), $2, $3, $4, $5, $6, $7, $8", + id, + workspace_id, + self.running.then(|| created_at), + self.scheduled_for.unwrap_or(created_at), + self.running, + created_at, + self.tag, + self.priority, + ) + .execute(&mut *tx) + .warn_after_seconds(1) + .await?; + sqlx::query!( + "INSERT INTO v2_job_runtime (id) SELECT unnest($1::uuid[])", + id + ) + .execute(&mut *tx) + .warn_after_seconds(1) + .await?; + if let Some(flow_status) = self.flow_status { + sqlx::query!( + "INSERT INTO v2_job_flow_runtime (id, flow_status) SELECT unnest($1::uuid[]), $2", + id, + Json(flow_status) as Json<&FlowStatus>, + ) + .execute(&mut *tx) + .warn_after_seconds(1) + .await?; + } + + #[cfg(feature = "prometheus")] + if METRICS_ENABLED.load(std::sync::atomic::Ordering::Relaxed) { + // TODO: technically the job isn't queued yet, as the transaction can be rolled back. + // Should be solved when moving these metrics to the queue abstraction. + QUEUE_PUSH_COUNT.inc_by(id.len() as u64); + } + + Ok(tx) + } +} + // #[instrument(level = "trace", skip_all)] pub async fn push<'c, 'd>( _db: &Pool, @@ -2757,7 +2877,7 @@ pub async fn push<'c, 'd>( parent_job: Option, root_job: Option, job_id: Option, - is_flow_step: bool, + _is_flow_step: bool, mut same_worker: bool, pre_run_error: Option<&windmill_common::error::Error>, visible_to_owner: bool, @@ -2856,11 +2976,13 @@ pub async fn push<'c, 'd>( ))); } - let in_queue = - sqlx::query_scalar!("SELECT COUNT(id) FROM queue WHERE email = $1", email) - .fetch_one(_db) - .await? - .unwrap_or(0); + let in_queue = sqlx::query_scalar!( + "SELECT COUNT(id) FROM v2_queue WHERE email = $1", + email + ) + .fetch_one(_db) + .await? + .unwrap_or(0); if in_queue > MAX_FREE_EXECS.into() { return Err(error::Error::QuotaExceeded(format!( @@ -2869,7 +2991,7 @@ pub async fn push<'c, 'd>( } let concurrent_runs = sqlx::query_scalar!( - "SELECT COUNT(id) FROM queue WHERE running = true AND email = $1", + "SELECT COUNT(id) FROM v2_queue WHERE running = true AND email = $1", email ) .fetch_one(_db) @@ -2911,7 +3033,7 @@ pub async fn push<'c, 'd>( } let in_queue_workspace = sqlx::query_scalar!( - "SELECT COUNT(id) FROM queue WHERE workspace_id = $1", + "SELECT COUNT(id) FROM v2_queue WHERE workspace_id = $1", workspace_id ) .fetch_one(_db) @@ -2925,7 +3047,7 @@ pub async fn push<'c, 'd>( } let concurrent_runs_workspace = sqlx::query_scalar!( - "SELECT COUNT(id) FROM queue WHERE running = true AND workspace_id = $1", + "SELECT COUNT(id) FROM v2_queue WHERE running = true AND workspace_id = $1", workspace_id ) .fetch_one(_db) @@ -3657,12 +3779,9 @@ pub async fn push<'c, 'd>( let mut tx = tx.into_tx().await?; let job_id: Uuid = if let Some(job_id) = job_id { - let conflicting_id = sqlx::query_scalar!( - "SELECT 1 FROM queue WHERE id = $1 UNION ALL select 1 FROM completed_job WHERE id = $1", - job_id - ) - .fetch_optional(&mut *tx) - .await?; + let conflicting_id = sqlx::query_scalar!("SELECT 1 FROM v2_job WHERE id = $1", job_id) + .fetch_optional(&mut *tx) + .await?; if conflicting_id.is_some() { return Err(Error::BadRequest(format!( @@ -3703,80 +3822,55 @@ pub async fn push<'c, 'd>( None }; - let raw_flow = raw_flow.map(Json); - - sqlx::query!( - "INSERT INTO job (id, workspace_id, raw_code, raw_lock, raw_flow, tag) - VALUES ($1, $2, $3, $4, $5, $6)", - job_id, - workspace_id, - raw_code, - raw_lock, - raw_flow.as_ref() as Option<&Json>, - tag, - ) - .execute(&mut *tx) - .warn_after_seconds(1) - .await?; - - let (raw_code, raw_lock, raw_flow) = if !*MIN_VERSION_IS_AT_LEAST_1_427.read().await { - (raw_code, raw_lock, raw_flow) - } else { - (None, None, None) - }; - - tracing::debug!("Pushing job {job_id} with tag {tag}, schedule_path {schedule_path:?}, script_path: {script_path:?}, email {email}, workspace_id {workspace_id}"); - let uuid = sqlx::query_scalar!( - "INSERT INTO queue - (workspace_id, id, running, parent_job, created_by, permissioned_as, scheduled_for, - script_hash, script_path, raw_code, raw_lock, args, job_kind, schedule_path, raw_flow, \ - flow_status, is_flow_step, language, started_at, same_worker, pre_run_error, email, \ - visible_to_owner, root_job, tag, concurrent_limit, concurrency_time_window_s, timeout, \ - flow_step_id, cache_ttl, priority, last_ping) - VALUES ($1, $2, $3, $4, $5, $6, COALESCE($7, now()), $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, CASE WHEN $3 THEN now() END, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, NULL) \ - RETURNING id AS \"id!\"", - workspace_id, - job_id, - is_running, + let pre_run_error = pre_run_error.map(Error::to_string); + let args = serde_json::value::to_raw_value(&args).map_err(|e| { + Error::InternalErr(format!("Could not serialize args for job {job_id}: {e:#}")) + })?; + tracing::debug!( + "Pushing job {job_id} with tag {tag}, schedule_path {schedule_path:?}, \ + script_path: {script_path:?}, email {email}, workspace_id {workspace_id}" + ); + tx = RawJob { + created_by: &user, + permissioned_as: &permissioned_as, + permissioned_as_email: &email, + kind: job_kind, + runnable_id: script_hash, + runnable_path: script_path.as_deref(), parent_job, - user, - permissioned_as, - scheduled_for_o, - script_hash, - script_path.clone(), - raw_code, - raw_lock, - Json(args) as Json, - job_kind.clone() as JobKind, - schedule_path, - raw_flow.as_ref() as Option<&Json>, - flow_status.map(Json) as Option>, - is_flow_step, - language as Option, + script_lang: language, + flow_step_id: flow_step_id.as_deref(), + flow_root_job: root_job, + trigger: schedule_path.as_deref(), + trigger_kind: schedule_path + .as_ref() + .and_then(|_| Some(JobTriggerKind::Schedule)), + tag: &tag, same_worker, - pre_run_error.map(|e| e.to_string()), - email, visible_to_owner, - root_job, - tag, concurrent_limit, - if concurrent_limit.is_some() { concurrency_time_window_s } else { None }, - custom_timeout, - flow_step_id, + concurrency_time_window_s, cache_ttl, - final_priority, - ) - .fetch_one(&mut *tx) - .warn_after_seconds(1) - .await - .map_err(|e| Error::InternalErr(format!("Could not insert into queue {job_id} with tag {tag}, schedule_path {schedule_path:?}, script_path: {script_path:?}, email {email}, workspace_id {workspace_id}: {e:#}")))?; - - tracing::debug!("Pushed {job_id}"); - // TODO: technically the job isn't queued yet, as the transaction can be rolled back. Should be solved when moving these metrics to the queue abstraction. - #[cfg(feature = "prometheus")] - if METRICS_ENABLED.load(std::sync::atomic::Ordering::Relaxed) { - QUEUE_PUSH_COUNT.inc(); + timeout: custom_timeout, + priority: final_priority, + pre_run_error: pre_run_error.as_deref(), + raw_code: raw_code.as_deref(), + raw_lock: raw_lock.as_deref(), + raw_flow: raw_flow.as_ref(), + flow_status: flow_status.as_ref(), + scheduled_for: scheduled_for_o, + running: is_running, } + .push(tx, job_id, workspace_id, Json(args)) + .await + .map_err(|e| { + Error::InternalErr(format!( + "Could not insert into queue {job_id} with tag {tag}, \ + schedule_path {schedule_path:?}, script_path: {script_path:?}, \ + email {email}, workspace_id {workspace_id}: {e:#}" + )) + })?; + tracing::debug!("Pushed {job_id}"); if JOB_TOKEN.is_none() { let job_authed = match authed { @@ -3886,7 +3980,7 @@ pub async fn push<'c, 'd>( .await?; } - Ok((uuid, tx)) + Ok((job_id, tx)) } pub fn canceled_job_to_result(job: &QueuedJob) -> serde_json::Value { @@ -3922,7 +4016,7 @@ async fn restarted_flows_resolution( job_kind AS \"job_kind!: JobKind\", flow_status AS \"flow_status: Json>\", raw_flow AS \"raw_flow: Json>\" - FROM completed_job WHERE id = $1 and workspace_id = $2", + FROM v2_completed_job WHERE id = $1 and workspace_id = $2", completed_flow_id, workspace_id, ) diff --git a/backend/windmill-queue/src/schedule.rs b/backend/windmill-queue/src/schedule.rs index ea9f476ab6..dfb8170df9 100644 --- a/backend/windmill-queue/src/schedule.rs +++ b/backend/windmill-queue/src/schedule.rs @@ -71,7 +71,7 @@ pub async fn push_scheduled_job<'c>( let next = next.with_timezone(&chrono::Utc); let already_exists: bool = query_scalar!( - "SELECT EXISTS (SELECT 1 FROM queue WHERE workspace_id = $1 AND schedule_path = $2 AND scheduled_for = $3)", + "SELECT EXISTS (SELECT 1 FROM v2_queue WHERE workspace_id = $1 AND schedule_path = $2 AND scheduled_for = $3)", &schedule.workspace_id, &schedule.path, next diff --git a/backend/windmill-worker/Cargo.toml b/backend/windmill-worker/Cargo.toml index 7bec644550..ca00a3185f 100644 --- a/backend/windmill-worker/Cargo.toml +++ b/backend/windmill-worker/Cargo.toml @@ -102,6 +102,7 @@ object_store = { workspace = true, optional = true} convert_case.workspace = true yaml-rust.workspace = true backon.workspace = true +ulid.workspace = true opentelemetry = { workspace = true, optional = true } bollard = { workspace = true, optional = true } diff --git a/backend/windmill-worker/src/bench.rs b/backend/windmill-worker/src/bench.rs new file mode 100644 index 0000000000..a22ff71ea7 --- /dev/null +++ b/backend/windmill-worker/src/bench.rs @@ -0,0 +1,226 @@ +use serde::Serialize; +use serde_json::json; +use tokio::time::Instant; +use windmill_common::{ + worker::{write_file, TMP_DIR}, + DB, +}; + +#[derive(Serialize)] +pub struct BenchmarkInfo { + #[serde(skip)] + pub start: Instant, + #[serde(skip)] + pub iters: u64, + timings: Vec, + pub iter_durations: Vec, + pub total_duration: Option, +} + +impl BenchmarkInfo { + pub fn new() -> Self { + BenchmarkInfo { + iters: 0, + timings: vec![], + start: Instant::now(), + iter_durations: vec![], + total_duration: None, + } + } + + pub fn add_iter(&mut self, bench: BenchmarkIter, inc_iters: bool) { + if inc_iters { + self.iters += 1; + } + let elapsed_total = bench.start.elapsed().as_nanos() as u64; + self.timings.push(bench); + self.iter_durations.push(elapsed_total); + } + + pub fn write_to_file(&mut self, path: &str) -> anyhow::Result<()> { + let total_duration = self.start.elapsed().as_millis() as u64; + self.total_duration = Some(total_duration as u64); + + println!( + "Writing benchmark {path}, duration of benchmark: {total_duration}s and RPS: {}", + self.iters as f64 / total_duration as f64 + ); + write_file(TMP_DIR, path, &serde_json::to_string(&self).unwrap()).expect("write profiling"); + Ok(()) + } +} + +#[derive(Serialize)] +pub struct BenchmarkIter { + #[serde(skip)] + pub start: Instant, + #[serde(skip)] + last_instant: Instant, + last_step: String, + timings: Vec<(String, u32)>, +} + +impl BenchmarkIter { + pub fn new() -> Self { + BenchmarkIter { + last_instant: Instant::now(), + timings: vec![], + start: Instant::now(), + last_step: String::new(), + } + } + + pub fn add_timing(&mut self, name: &str) { + let elapsed = self.last_instant.elapsed().as_nanos() as u32; + self.timings + .push((format!("{}->{}", self.last_step, name), elapsed)); + self.last_instant = Instant::now(); + self.last_step = name.to_string(); + } +} + +pub async fn benchmark_init(benchmark_jobs: usize, db: &DB) { + use std::iter; + + use windmill_common::{jobs::JobKind, scripts::ScriptLang}; + use windmill_queue::RawJob; + + let benchmark_kind = std::env::var("BENCHMARK_KIND").unwrap_or("noop".to_string()); + let uuids = Vec::from_iter(iter::repeat_with(|| ulid::Ulid::new().into()).take(benchmark_jobs)); + + if !uuids.is_empty() { + match benchmark_kind.as_str() { + "dedicated" => { + // you need to create the script first, check https://github.com/windmill-labs/windmill/blob/b76a92cfe454c686f005c65f534e29e039f3c706/benchmarks/lib.ts#L47 + let hash = sqlx::query_scalar!( + "SELECT hash FROM script WHERE path = $1 AND workspace_id = $2", + "f/benchmarks/dedicated", + "admins" + ) + .fetch_one(db) + .await + .unwrap_or_else(|_e| panic!("failed to insert dedicated jobs")); + RawJob { + runnable_id: Some(hash), + runnable_path: Some("f/benchmarks/dedicated"), + kind: JobKind::Script, + script_lang: Some(ScriptLang::Bun), + tag: "admins:f/benchmarks/dedicated", + created_by: "admin", + permissioned_as: "u/admin", + permissioned_as_email: "admin@windmill.dev", + ..RawJob::default() + } + .push_many(db.begin().await.unwrap(), uuids.as_slice(), "admins", &[]) + .await + .unwrap_or_else(|_e| panic!("failed to insert dedicated jobs")) + .commit() + .await + .unwrap_or_else(|_e| panic!("failed to commit insert of dedicated jobs")); + } + "parallelflow" => { + // create dedicated script + sqlx::query!( + "INSERT INTO script ( + summary, description, dedicated_worker, content, workspace_id, path, hash, + language, tag, created_by, lock + ) VALUES ('', '', true, $1, $2, $3, $4, $5, $6, $7, '') + ON CONFLICT (workspace_id, hash) DO NOTHING", + "export async function main() { + console.log('hello world'); + }", + "admins", + "u/admin/parallelflow", + 1234567890, + ScriptLang::Deno as ScriptLang, + "flow", + "admin", + ) + .execute(db) + .await + .unwrap_or_else(|e| panic!("failed to insert parallelflow script {e:#}")); + RawJob { + kind: JobKind::FlowPreview, + tag: "flow", + created_by: "admin", + permissioned_as: "u/admin", + permissioned_as_email: "admin@windmill.dev", + raw_flow: Some( + &serde_json::from_value(json!({ + "modules": [ + { + "id": "a", + "value": { + "type": "forloopflow", + "modules": [ + { + "id": "b", + "value": { + "path": "u/admin/parallelflow", + "type": "script", + "tag_override": "", + "input_transforms": {} + }, + "summary": "calctest" + } + ], + "iterator": { + "expr": "[...new Array(300)]", + "type": "javascript" + }, + "parallel": true, + "parallelism": 10, + "skip_failures": true + } + } + ], + "preprocessor_module": null + })) + .unwrap(), + ), + flow_status: Some( + &serde_json::from_value(json!({ + "step": 0, + "modules": [ + { + "id": "a", + "type": "WaitingForPriorSteps" + } + ], + "cleanup_module": {}, + "failure_module": { + "id": "failure", + "type": "WaitingForPriorSteps" + }, + "preprocessor_module": null + })) + .unwrap(), + ), + ..RawJob::default() + } + .push_many(db.begin().await.unwrap(), uuids.as_slice(), "admins", &[]) + .await + .unwrap_or_else(|_e| panic!("failed to insert parallelflow jobs")) + .commit() + .await + .unwrap_or_else(|_e| panic!("failed to commit insert of parallelflow jobs")); + } + _ => { + RawJob { + kind: JobKind::Noop, + tag: "deno", + created_by: "admin", + permissioned_as: "u/admin", + permissioned_as_email: "admin@windmill.dev", + ..RawJob::default() + } + .push_many(db.begin().await.unwrap(), uuids.as_slice(), "admins", &[]) + .await + .unwrap_or_else(|_e| panic!("failed to insert noop jobs")) + .commit() + .await + .unwrap_or_else(|_e| panic!("failed to commit insert of noop jobs")); + } + } + } +} diff --git a/backend/windmill-worker/src/common.rs b/backend/windmill-worker/src/common.rs index 61ec9cee6a..1eb50f0fe6 100644 --- a/backend/windmill-worker/src/common.rs +++ b/backend/windmill-worker/src/common.rs @@ -265,7 +265,7 @@ pub async fn transform_json_value( } Value::String(y) if y.starts_with("$") => { let flow_path = if let Some(uuid) = job.parent_job { - sqlx::query_scalar!("SELECT script_path FROM queue WHERE id = $1", uuid) + sqlx::query_scalar!("SELECT script_path FROM v2_queue WHERE id = $1", uuid) .fetch_optional(db) .await? .flatten() @@ -399,7 +399,7 @@ pub async fn get_reserved_variables( db: &sqlx::Pool, ) -> Result, Error> { let flow_path = if let Some(uuid) = job.parent_job { - sqlx::query_scalar!("SELECT script_path FROM queue WHERE id = $1", uuid) + sqlx::query_scalar!("SELECT script_path FROM v2_queue WHERE id = $1", uuid) .fetch_optional(db) .await? .flatten() diff --git a/backend/windmill-worker/src/handle_child.rs b/backend/windmill-worker/src/handle_child.rs index 8088f078cb..6d824ea0d8 100644 --- a/backend/windmill-worker/src/handle_child.rs +++ b/backend/windmill-worker/src/handle_child.rs @@ -208,7 +208,7 @@ pub async fn handle_child( if matches!(kill_reason, KillReason::Timeout { .. }) { if let Err(err) = sqlx::query!( r#" - UPDATE queue + UPDATE v2_queue SET canceled = true , canceled_by = 'timeout' , canceled_reason = $1 @@ -645,7 +645,7 @@ where } if job_id != Uuid::nil() { let (canceled, canceled_by, canceled_reason, already_completed) = sqlx::query!( - "UPDATE queue SET mem_peak = $1, last_ping = now() + "UPDATE v2_queue SET mem_peak = $1, last_ping = now() WHERE id = $2 RETURNING canceled AS \"canceled!\", canceled_by, canceled_reason", *mem_peak, diff --git a/backend/windmill-worker/src/lib.rs b/backend/windmill-worker/src/lib.rs index d887f14d81..9a0587fd73 100644 --- a/backend/windmill-worker/src/lib.rs +++ b/backend/windmill-worker/src/lib.rs @@ -38,6 +38,9 @@ mod worker_flow; mod worker_lockfiles; #[cfg(feature = "oracledb")] mod oracledb_executor; +#[cfg(feature = "benchmark")] +pub mod bench; + pub use worker::*; pub use result_processor::handle_job_error; diff --git a/backend/windmill-worker/src/python_executor.rs b/backend/windmill-worker/src/python_executor.rs index c2696ed22f..ac281500fd 100644 --- a/backend/windmill-worker/src/python_executor.rs +++ b/backend/windmill-worker/src/python_executor.rs @@ -1563,29 +1563,29 @@ pub async fn handle_python_reqs( // Notify server that we are still alive // Detect if job has been canceled - let canceled = - sqlx::query_scalar::<_, bool> - (r#" - - UPDATE queue - SET last_ping = now() - , mem_peak = $1 - WHERE id = $2 - RETURNING canceled - - "#) - .bind(mem_peak_actual) - .bind(job_id_2) - .fetch_optional(&db_2) - .await - .unwrap_or_else(|e| { - tracing::error!(%e, "error updating job {job_id_2}: {e:#}"); - Some(false) - }) - .unwrap_or_else(|| { - // if the job is not in queue, it can only be in the completed_job so it is already complete - false - }); + let canceled = sqlx::query_scalar!( + r#" + UPDATE v2_queue + SET last_ping = now() + , mem_peak = $1 + WHERE id = $2 + RETURNING canceled AS "canceled!" + "#, + mem_peak_actual, + job_id_2 + ) + .bind(mem_peak_actual) + .bind(job_id_2) + .fetch_optional(&db_2) + .await + .unwrap_or_else(|e| { + tracing::error!(%e, "error updating job {job_id_2}: {e:#}"); + Some(false) + }) + .unwrap_or_else(|| { + // if the job is not in queue, it can only be in the completed_job so it is already complete + false + }); if canceled { @@ -1784,12 +1784,12 @@ pub async fn handle_python_reqs( uv_install_proccess.kill().await?; pids.lock().await.get_mut(i).and_then(|e| e.take()); return Err(anyhow::anyhow!("uv pip install was canceled")); - }, + }, (_, exitstatus) = async { // See tokio::process::Child::wait_with_output() for more context // Sometimes uv_install_proccess.wait() is not exiting if stderr is not awaited before it :/ (stderr_future.await, uv_install_proccess.wait().await) - } => match exitstatus { + } => match exitstatus { Ok(status) => if !status.success() { tracing::warn!( workspace_id = %w_id, diff --git a/backend/windmill-worker/src/result_processor.rs b/backend/windmill-worker/src/result_processor.rs index 5812b12175..d15d510abc 100644 --- a/backend/windmill-worker/src/result_processor.rs +++ b/backend/windmill-worker/src/result_processor.rs @@ -26,7 +26,7 @@ use windmill_common::{ }; #[cfg(feature = "benchmark")] -use windmill_common::bench::{BenchmarkInfo, BenchmarkIter}; +use crate::bench::{BenchmarkInfo, BenchmarkIter}; use windmill_queue::{append_logs, get_queued_job, CanceledBy, WrappedError}; diff --git a/backend/windmill-worker/src/worker.rs b/backend/windmill-worker/src/worker.rs index 0a0599047f..3ea0c8109d 100644 --- a/backend/windmill-worker/src/worker.rs +++ b/backend/windmill-worker/src/worker.rs @@ -90,12 +90,26 @@ use tokio::{ use rand::Rng; use crate::{ - bash_executor::{handle_bash_job, handle_powershell_job}, bun_executor::handle_bun_job, common::{ + bash_executor::{handle_bash_job, handle_powershell_job}, + bun_executor::handle_bun_job, + common::{ build_args_map, cached_result_path, get_cached_resource_value_if_valid, get_reserved_variables, update_worker_ping_for_failed_init_script, OccupancyMetrics, - }, csharp_executor::handle_csharp_job, deno_executor::handle_deno_job, go_executor::handle_go_job, graphql_executor::do_graphql, handle_child::SLOW_LOGS, handle_job_error, job_logger::NO_LOGS_AT_ALL, js_eval::{eval_fetch_timeout, transpile_ts}, pg_executor::do_postgresql, result_processor::{process_result, start_background_processor}, worker_flow::{handle_flow, update_flow_status_in_progress}, worker_lockfiles::{ + }, + csharp_executor::handle_csharp_job, + deno_executor::handle_deno_job, + go_executor::handle_go_job, + graphql_executor::do_graphql, + handle_child::SLOW_LOGS, + handle_job_error, + job_logger::NO_LOGS_AT_ALL, + js_eval::{eval_fetch_timeout, transpile_ts}, + pg_executor::do_postgresql, + result_processor::{process_result, start_background_processor}, + worker_flow::{handle_flow, update_flow_status_in_progress}, + worker_lockfiles::{ handle_app_dependency_job, handle_dependency_job, handle_flow_dependency_job, - } + }, }; #[cfg(feature = "rust")] @@ -132,7 +146,7 @@ use crate::mssql_executor::do_mssql; use crate::bigquery_executor::do_bigquery; #[cfg(feature = "benchmark")] -use windmill_common::bench::{benchmark_init, BenchmarkInfo, BenchmarkIter}; +use crate::bench::{benchmark_init, BenchmarkInfo, BenchmarkIter}; use windmill_common::add_time; @@ -325,7 +339,6 @@ const DOTNET_DEFAULT_PATH: &str = "C:\\Program Files\\dotnet\\dotnet.exe"; #[cfg(unix)] const DOTNET_DEFAULT_PATH: &str = "/usr/bin/dotnet"; - lazy_static::lazy_static! { pub static ref JOB_TOKEN: Option = std::env::var("JOB_TOKEN").ok(); @@ -995,9 +1008,9 @@ pub async fn run_worker( let is_dedicated_worker: bool = WORKER_CONFIG.read().await.dedicated_worker.is_some(); #[cfg(feature = "benchmark")] - let benchmark_jobs: i32 = std::env::var("BENCHMARK_JOBS") + let benchmark_jobs: usize = std::env::var("BENCHMARK_JOBS") .unwrap_or("5000".to_string()) - .parse::() + .parse::() .unwrap(); #[cfg(feature = "benchmark")] @@ -1225,7 +1238,7 @@ pub async fn run_worker( tokio::task::spawn( (async move { tracing::info!(worker = %worker_name, hostname = %hostname, "vacuuming queue"); - if let Err(e) = sqlx::query!("VACUUM (skip_locked) queue") + if let Err(e) = sqlx::query!("VACUUM (skip_locked) v2_job_queue, v2_job_runtime, v2_job_flow_runtime") .execute(&db2) .await { @@ -1272,7 +1285,7 @@ pub async fn run_worker( same_worker_job.job_id ); let r = sqlx::query_as::<_, PulledJob>( - "UPDATE queue SET last_ping = now() WHERE id = $1 RETURNING *", + "UPDATE v2_queue SET last_ping = now() WHERE id = $1 RETURNING *", ) .bind(same_worker_job.job_id) .fetch_optional(db) @@ -1948,7 +1961,7 @@ async fn handle_queued_job( .await?; } else if let Some(parent_job) = job.parent_job { if let Err(e) = sqlx::query_scalar!( - "UPDATE queue SET flow_status = jsonb_set(jsonb_set(COALESCE(flow_status, '{}'::jsonb), array[$1], COALESCE(flow_status->$1, '{}'::jsonb)), array[$1, 'started_at'], to_jsonb(now()::text)) WHERE id = $2 AND workspace_id = $3", + "UPDATE v2_queue SET flow_status = jsonb_set(jsonb_set(COALESCE(flow_status, '{}'::jsonb), array[$1], COALESCE(flow_status->$1, '{}'::jsonb)), array[$1, 'started_at'], to_jsonb(now()::text)) WHERE id = $2 AND workspace_id = $3", &job.id.to_string(), parent_job, &job.workspace_id diff --git a/backend/windmill-worker/src/worker_flow.rs b/backend/windmill-worker/src/worker_flow.rs index b81717cee1..836f4e3c39 100644 --- a/backend/windmill-worker/src/worker_flow.rs +++ b/backend/windmill-worker/src/worker_flow.rs @@ -11,6 +11,8 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; use std::time::Duration; +#[cfg(feature = "benchmark")] +use crate::bench::BenchmarkIter; use crate::common::{cached_result_path, save_in_cache}; use crate::js_eval::{eval_timeout, IdContext}; use crate::{ @@ -30,8 +32,6 @@ use tracing::instrument; use uuid::Uuid; use windmill_common::add_time; use windmill_common::auth::JobPerms; -#[cfg(feature = "benchmark")] -use windmill_common::bench::BenchmarkIter; use windmill_common::cache::{self, RawData}; use windmill_common::db::Authed; use windmill_common::flow_status::{ @@ -224,7 +224,7 @@ pub async fn update_flow_status_after_job_completion_internal( script_hash AS \"script_hash: ScriptHash\", flow_status AS \"flow_status!: Json>\", raw_flow AS \"raw_flow: Json>\" - FROM queue WHERE id = $1 AND workspace_id = $2 LIMIT 1", + FROM v2_queue WHERE id = $1 AND workspace_id = $2 LIMIT 1", flow, w_id ) @@ -353,14 +353,13 @@ pub async fn update_flow_status_after_job_completion_internal( )), _ => None, }; - let args = sqlx::query_as::<_, RowArgs>( + let args = sqlx::query_scalar!( "SELECT - args - FROM queue - WHERE id = $2", + args AS \"args: Json>>\" + FROM v2_queue + WHERE id = $1", + flow ) - .bind(old_status.step) - .bind(flow) .fetch_one(db) .await .map_err(|e| { @@ -368,7 +367,7 @@ pub async fn update_flow_status_after_job_completion_internal( })?; compute_bool_from_expr( &expr, - Marc::new(args.args.unwrap_or_default().0), + Marc::new(args.unwrap_or_default().0), result.clone(), all_iters, None, @@ -412,7 +411,7 @@ pub async fn update_flow_status_after_job_completion_internal( if matches!(module_step, Step::PreprocessorStep) { sqlx::query!( - "UPDATE queue SET args = (select result FROM completed_job WHERE id = $1) WHERE id = $2", + "UPDATE v2_queue SET args = (select result FROM v2_completed_job WHERE id = $1) WHERE id = $2", job_id_for_status, flow ).execute(db).await.map_err(|e| { @@ -420,7 +419,7 @@ pub async fn update_flow_status_after_job_completion_internal( })?; sqlx::query!( - r#"UPDATE completed_job SET args = '{"reason":"PREPROCESSOR_ARGS_ARE_DISCARDED"}'::jsonb WHERE id = $1"#, + r#"UPDATE v2_completed_job SET args = '{"reason":"PREPROCESSOR_ARGS_ARE_DISCARDED"}'::jsonb WHERE id = $1"#, job_id_for_status ) .execute(db) @@ -455,7 +454,7 @@ pub async fn update_flow_status_after_job_completion_internal( let nindex = if let Some(position) = position { sqlx::query_scalar!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET( JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'flow_jobs_success', $3::TEXT], $4), ARRAY['modules', $1::TEXT, 'iterator', 'index'], @@ -470,7 +469,7 @@ pub async fn update_flow_status_after_job_completion_internal( json!(success) )} else { sqlx::query_scalar!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'iterator', 'index'], ((flow_status->'modules'->$1::int->'iterator'->>'index')::int + 1)::text::jsonb), last_ping = NULL WHERE id = $2 @@ -502,7 +501,7 @@ pub async fn update_flow_status_after_job_completion_internal( let nindex = if let Some(position) = position { sqlx::query_scalar!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET( JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'flow_jobs_success', $3::TEXT], $4), ARRAY['modules', $1::TEXT, 'branchall', 'branch'], ((flow_status->'modules'->$1::int->'branchall'->>'branch')::int + 1)::text::jsonb), @@ -515,7 +514,7 @@ pub async fn update_flow_status_after_job_completion_internal( json!(success) ) } else { sqlx::query_scalar!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'branchall', 'branch'], ((flow_status->'modules'->$1::int->'branchall'->>'branch')::int + 1)::text::jsonb), last_ping = NULL WHERE id = $2 @@ -550,7 +549,7 @@ pub async fn update_flow_status_after_job_completion_internal( let new_status = if skip_loop_failures || sqlx::query_scalar!( - "SELECT success AS \"success!\" FROM completed_job WHERE id = ANY($1)", + "SELECT success AS \"success!\" FROM v2_completed_job WHERE id = ANY($1)", jobs.as_slice() ) .fetch_all(&mut *tx) @@ -609,7 +608,7 @@ pub async fn update_flow_status_after_job_completion_internal( if parallelism.is_some() { sqlx::query!( - "UPDATE queue SET suspend = 0 WHERE parent_job = $1 AND suspend = $2 AND (flow_status->'step')::int = 0", + "UPDATE v2_queue SET suspend = 0 WHERE parent_job = $1 AND suspend = $2 AND (flow_status->'step')::int = 0", flow, nindex ) @@ -713,7 +712,7 @@ pub async fn update_flow_status_after_job_completion_internal( let is_skipped = if current_module.as_ref().is_some_and(|m| m.skip_if.is_some()) { sqlx::query_scalar!( - "SELECT job_kind = 'identity' FROM completed_job WHERE id = $1", + "SELECT job_kind = 'identity' FROM v2_completed_job WHERE id = $1", job_id_for_status ) .fetch_one(db) @@ -766,7 +765,7 @@ pub async fn update_flow_status_after_job_completion_internal( let step_counter = if inc_step_counter { sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET(flow_status, ARRAY['step'], $1) WHERE id = $2", json!(old_status.step + 1), @@ -790,7 +789,7 @@ pub async fn update_flow_status_after_job_completion_internal( if let Some(new_status) = new_status.as_ref() { if is_failure_step { let parent_module = sqlx::query_scalar!( - "SELECT flow_status->'failure_module'->>'parent_module' FROM queue WHERE id = $1", + "SELECT flow_status->'failure_module'->>'parent_module' FROM v2_queue WHERE id = $1", flow ) .fetch_one(&mut *tx) @@ -801,7 +800,7 @@ pub async fn update_flow_status_after_job_completion_internal( })?; sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET(flow_status, ARRAY['failure_module'], $1) WHERE id = $2", json!(FlowStatusModuleWParent { @@ -819,7 +818,7 @@ pub async fn update_flow_status_after_job_completion_internal( })?; } else if matches!(module_step, Step::PreprocessorStep) { sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET(flow_status, ARRAY['preprocessor_module'], $1) WHERE id = $2", json!(new_status), @@ -834,7 +833,7 @@ pub async fn update_flow_status_after_job_completion_internal( })?; } else { sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT], $2) WHERE id = $3", old_status.step.to_string(), @@ -849,9 +848,9 @@ pub async fn update_flow_status_after_job_completion_internal( if let Some(job_result) = new_status.job_result() { sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET leaf_jobs = JSONB_SET(coalesce(leaf_jobs, '{}'::jsonb), ARRAY[$1::TEXT], $2) - WHERE COALESCE((SELECT root_job FROM queue WHERE id = $3), $3) = id", + WHERE COALESCE((SELECT root_job FROM v2_queue WHERE id = $3), $3) = id", new_status.id(), json!(job_result), flow @@ -883,7 +882,7 @@ pub async fn update_flow_status_after_job_completion_internal( let args = sqlx::query_as::<_, RowArgs>( "SELECT args - FROM queue + FROM v2_queue WHERE id = $2", ) .bind(old_status.step) @@ -926,7 +925,7 @@ pub async fn update_flow_status_after_job_completion_internal( && matches!(&new_status, Some(FlowStatusModule::Success { .. })) { sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = flow_status - 'retry' WHERE id = $1", flow @@ -937,7 +936,7 @@ pub async fn update_flow_status_after_job_completion_internal( } let flow_job = sqlx::query_as::<_, QueuedJob>( - "SELECT * FROM queue WHERE id = $1 AND workspace_id = $2", + "SELECT * FROM v2_queue WHERE id = $1 AND workspace_id = $2", ) .bind(flow) .bind(w_id) @@ -1033,7 +1032,7 @@ pub async fn update_flow_status_after_job_completion_internal( _cleanup_module.flow_jobs_to_clean ); sqlx::query!( - "UPDATE completed_job + "UPDATE v2_completed_job SET logs = '##DELETED##', args = '{}'::jsonb, result = '{}'::jsonb WHERE id = ANY($1)", &_cleanup_module.flow_jobs_to_clean, @@ -1041,7 +1040,7 @@ pub async fn update_flow_status_after_job_completion_internal( .execute(db) .await .map_err(|e| { - Error::InternalErr(format!("error while cleaning up completed_job: {e:#}")) + Error::InternalErr(format!("error while cleaning up completed job: {e:#}")) })?; } } @@ -1189,7 +1188,7 @@ async fn set_success_in_flow_job_success<'c>( let position = find_flow_job_index(flow_jobs, job_id_for_status); if let Some(position) = position { sqlx::query!( - "UPDATE queue SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'flow_jobs_success', $3::TEXT], $4) WHERE id = $2", + "UPDATE v2_queue SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'flow_jobs_success', $3::TEXT], $4) WHERE id = $2", old_status.step as i32, flow, position as i32, @@ -1213,7 +1212,7 @@ async fn retrieve_flow_jobs_results( ) -> error::Result> { let results = sqlx::query_as::<_, BranchResults>( "SELECT result, id - FROM completed_job + FROM v2_completed_job WHERE id = ANY($1) AND workspace_id = $2", ) .bind(job_uuids.as_slice()) @@ -1245,24 +1244,27 @@ async fn compute_skip_branchall_failure<'c>( flow_module: Option<&FlowModule>, ) -> Result, Error> { let branch = if parallel { - sqlx::query_scalar!("SELECT script_path FROM completed_job WHERE id = $1", job) - .fetch_one(db) - .await - .map_err(|e| { - Error::InternalErr(format!("error during retrieval of branchall index: {e:#}")) - })? - .map(|p| { - BRANCHALL_INDEX_RE - .captures(&p) - .map(|x| x.get(1).unwrap().as_str().parse::().ok()) - .flatten() - .ok_or(Error::InternalErr(format!( - "could not parse branchall index from path: {p}" - ))) - }) - .ok_or_else(|| { - Error::InternalErr(format!("no branchall script path found for job {job}")) - })?? + sqlx::query_scalar!( + "SELECT script_path FROM v2_completed_job WHERE id = $1", + job + ) + .fetch_one(db) + .await + .map_err(|e| { + Error::InternalErr(format!("error during retrieval of branchall index: {e:#}")) + })? + .map(|p| { + BRANCHALL_INDEX_RE + .captures(&p) + .map(|x| x.get(1).unwrap().as_str().parse::().ok()) + .flatten() + .ok_or(Error::InternalErr(format!( + "could not parse branchall index from path: {p}" + ))) + }) + .ok_or_else(|| { + Error::InternalErr(format!("no branchall script path found for job {job}")) + })?? } else { branch as i32 }; @@ -1355,7 +1357,7 @@ pub async fn update_flow_status_in_progress( match step { Step::Step(step) => { sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = jsonb_set( jsonb_set(flow_status, ARRAY['modules', $4::INTEGER::TEXT, 'job'], to_jsonb($1::UUID::TEXT)), ARRAY['modules', $4::INTEGER::TEXT, 'type'], @@ -1372,7 +1374,7 @@ pub async fn update_flow_status_in_progress( } Step::PreprocessorStep => { sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = jsonb_set( jsonb_set(flow_status, ARRAY['preprocessor_module', 'job'], to_jsonb($1::UUID::TEXT)), ARRAY['preprocessor_module', 'type'], @@ -1388,7 +1390,7 @@ pub async fn update_flow_status_in_progress( } Step::FailureStep => { sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = jsonb_set( jsonb_set(flow_status, ARRAY['failure_module', 'job'], to_jsonb($1::UUID::TEXT)), ARRAY['failure_module', 'type'], @@ -1429,7 +1431,7 @@ impl Step { #[instrument(level = "trace", skip_all)] pub async fn get_step_of_flow_status(db: &DB, id: Uuid) -> error::Result { let r = sqlx::query!( - "SELECT (flow_status->'step')::integer as step, jsonb_array_length(flow_status->'modules') as len FROM queue WHERE id = $1", + "SELECT (flow_status->'step')::integer as step, jsonb_array_length(flow_status->'modules') as len FROM v2_queue WHERE id = $1", id ) .fetch_one(db) @@ -1687,7 +1689,7 @@ async fn push_next_flow_job( .await?; if no_flow_overlap { let overlapping = sqlx::query_scalar!( - "SELECT id AS \"id!\" FROM queue WHERE schedule_path = $1 AND workspace_id = $2 AND id != $3 AND running = true", + "SELECT id AS \"id!\" FROM v2_queue WHERE schedule_path = $1 AND workspace_id = $2 AND id != $3 AND running = true", flow_job.schedule_path.as_ref().unwrap(), flow_job.workspace_id.as_str(), flow_job.id @@ -1800,7 +1802,7 @@ async fn push_next_flow_job( * * This only works because jobs::resume_job does the same thing. */ sqlx::query_scalar!( - "SELECT null FROM queue WHERE id = $1 FOR UPDATE", + "SELECT null FROM v2_job_queue WHERE id = $1 FOR UPDATE", flow_job.id ) .fetch_one(&mut *tx) @@ -1877,7 +1879,7 @@ async fn push_next_flow_job( self_approval_disabled: self_approval_disabled, }; sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET(flow_status, ARRAY['approval_conditions'], $1) WHERE id = $2", json!(approval_conditions), @@ -1909,7 +1911,7 @@ async fn push_next_flow_job( resume_messages.push(to_raw_value(&js)); } sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'approvers'], $2) WHERE id = $3", (status.step - 1).to_string(), @@ -1930,7 +1932,7 @@ async fn push_next_flow_job( // Remove the approval conditions from the flow status sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = flow_status - 'approval_conditions' WHERE id = $1", flow_job.id @@ -1948,7 +1950,7 @@ async fn push_next_flow_job( ) && is_disapproved.is_none() { sqlx::query!( - "UPDATE queue SET + "UPDATE v2_queue SET flow_status = JSONB_SET(flow_status, ARRAY['modules', flow_status->>'step'::text], $1), suspend = $2, suspend_until = now() + $3 @@ -1962,7 +1964,7 @@ async fn push_next_flow_job( .await?; sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET last_ping = null WHERE id = $1 AND last_ping = $2", flow_job.id, @@ -2134,7 +2136,7 @@ async fn push_next_flow_job( scheduled_for_o = Some(from_now(retry_in)); status.retry.failed_jobs.push(job.clone()); sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET(JSONB_SET(flow_status, ARRAY['retry'], $1), ARRAY['modules', $3::TEXT, 'failed_retries'], $4) WHERE id = $2", json!(RetryStatus { fail_count, ..status.retry.clone() }), @@ -2171,7 +2173,7 @@ async fn push_next_flow_job( if module.retry.as_ref().is_some_and(|x| x.has_attempts()) { sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET(flow_status, ARRAY['retry'], $1) WHERE id = $2", json!(RetryStatus { fail_count: 0, failed_jobs: vec![] }), @@ -2231,7 +2233,7 @@ async fn push_next_flow_job( } else if let Some(id) = get_args_from_id { let args = sqlx::query_scalar!( "SELECT args AS \"args: Json>>\" - FROM completed_job WHERE id = $1 AND workspace_id = $2", + FROM v2_completed_job WHERE id = $1 AND workspace_id = $2", id, &flow_job.workspace_id ) @@ -2318,7 +2320,7 @@ async fn push_next_flow_job( NextFlowTransform::Continue(job_payload, next_state) => (job_payload, next_state), NextFlowTransform::EmptyInnerFlows => { sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT], $2) WHERE id = $3", status.step.to_string(), @@ -2369,7 +2371,7 @@ async fn push_next_flow_job( if i % 100 == 0 && i != 0 { tracing::info!(id = %flow_job.id, root_id = %job_root, "pushed (non-commited yet) first {i} subflows of {len}"); sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET last_ping = now() WHERE id = $1 AND last_ping < now()", flow_job.id, @@ -2595,9 +2597,9 @@ async fn push_next_flow_job( if i as u16 >= p { sqlx::query!( - "UPDATE queue - SET suspend = $1, suspend_until = now() + interval '14 day', running = true - WHERE id = $2", + "UPDATE v2_queue + SET suspend = $1, suspend_until = now() + interval '14 day', running = true + WHERE id = $2", (i as u16 - p + 1) as i32, uuid, ) @@ -2614,7 +2616,7 @@ async fn push_next_flow_job( })?; sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET(flow_status, ARRAY['cleanup_module', 'flow_jobs_to_clean'], COALESCE(flow_status->'cleanup_module'->'flow_jobs_to_clean', '[]'::jsonb) || $1) WHERE id = $2", uuid_singleton_json, @@ -2743,7 +2745,7 @@ async fn push_next_flow_job( match step { Step::FailureStep => { sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET( JSONB_SET(flow_status, ARRAY['failure_module'], $1), ARRAY['step'], $2) WHERE id = $3", @@ -2759,7 +2761,7 @@ async fn push_next_flow_job( } Step::PreprocessorStep => { sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET( JSONB_SET(flow_status, ARRAY['preprocessor_module'], $1), ARRAY['step'], $2) WHERE id = $3", @@ -2772,7 +2774,7 @@ async fn push_next_flow_job( } Step::Step(i) => { sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET flow_status = JSONB_SET( JSONB_SET(flow_status, ARRAY['modules', $1::TEXT], $2), ARRAY['step'], $3) WHERE id = $4", @@ -2789,7 +2791,7 @@ async fn push_next_flow_job( potentially_crash_for_testing(); sqlx::query!( - "UPDATE queue + "UPDATE v2_queue SET last_ping = null WHERE id = $1", flow_job.id @@ -3951,11 +3953,11 @@ async fn get_previous_job_result( Ok(Some(retrieve_flow_jobs_results(db, w_id, flow_jobs).await?)) } Some(FlowStatusModule::Success { job, .. }) => Ok(Some( - sqlx::query_scalar::<_, Json>>( - "SELECT result FROM completed_job WHERE id = $1 AND workspace_id = $2", + sqlx::query_scalar!( + "SELECT result AS \"result!: Json>\" FROM v2_completed_job WHERE id = $1 AND workspace_id = $2", + job, + w_id ) - .bind(job) - .bind(w_id) .fetch_one(db) .await? .0, diff --git a/backend/windmill-worker/src/worker_lockfiles.rs b/backend/windmill-worker/src/worker_lockfiles.rs index 8553e5c867..399aae736c 100644 --- a/backend/windmill-worker/src/worker_lockfiles.rs +++ b/backend/windmill-worker/src/worker_lockfiles.rs @@ -633,7 +633,7 @@ pub async fn handle_flow_dependency_job( // Re-check cancellation to ensure we don't accidentally override a flow. if sqlx::query_scalar!( - "SELECT canceled AS \"canceled!\" FROM queue WHERE id = $1", + "SELECT canceled AS \"canceled!\" FROM v2_queue WHERE id = $1", job.id ) .fetch_optional(db) @@ -1527,7 +1527,7 @@ pub async fn handle_app_dependency_job( // Re-check cancelation to ensure we don't accidentially override an app. if sqlx::query_scalar!( - "SELECT canceled AS \"canceled!\" FROM queue WHERE id = $1", + "SELECT canceled AS \"canceled!\" FROM v2_queue WHERE id = $1", job.id ) .fetch_optional(db)