{"id":18251,"date":"2026-07-06T16:59:34","date_gmt":"2026-07-06T08:59:34","guid":{"rendered":"https:\/\/kbwp.transwarp.cn\/?p=18251"},"modified":"2026-07-06T16:59:34","modified_gmt":"2026-07-06T08:59:34","slug":"3-1-x3-3-x-workflow%e6%89%a7%e8%a1%8c%e6%95%b0%e6%8d%ae%e6%b8%85%e7%90%86","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=18251","title":{"rendered":"3.1.X~3.3.X Workflow\u6267\u884c\u6570\u636e\u6e05\u7406"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<hr \/>\n<p>1\u3001\u4efb\u52a1\u6d41\u95f4\u4f9d\u8d56\u5173\u7cfb\uff1a\u4ec5\u652f\u6301\u65e0\u5468\u671f\u4efb\u52a1\u6d41\u4f9d\u8d56\u6709\u5468\u671f\u4efb\u52a1\u6d41\uff0c\u5e76\u4e14\u5728\u6709\u4efb\u52a1\u6d41\u95f4\u4f9d\u8d56\u5173\u7cfb\u7684\u60c5\u51b5\u4e0b\uff0c\u4ec5\u652f\u6301\u4e00\u5929\u4e00\u6b21\u7684\u8c03\u5ea6\uff0c\u4e0d\u9700\u8981\u7279\u6b8a\u5904\u7406\uff08\u5982\u679c\u8fdb\u884c\u6570\u636e\u6e05\u7406\u65f6\uff0c\u4e00\u822c\u6e05\u7406\u6700\u5c0f\u5355\u4f4d\u4e3a\u5df2\u7ed3\u675f\u7684\u4e00\u5929\uff09<\/p>\n<p>2\u3001\u4efb\u52a1\u6d41\u81ea\u8eab\u4f9d\u8d56\uff1a\u4efb\u52a1\u6d41\u914d\u7f6e\u4f9d\u8d56\u4e0a\u6b21\uff0c\u4efb\u52a1\u6d41\u8c03\u5ea6\u6267\u884c\u65f6\uff0c\u9700\u8981\u786e\u8ba4\u4e0a\u4e00\u6b21\u8c03\u5ea6\u6267\u884c\u7684\u6267\u884c\u7ed3\u679c\u3002\u6240\u4ee5\uff0c\u8fdb\u884c\u6570\u636e\u6e05\u7406\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4fdd\u7559\u81f3\u5c11\u4e00\u6761\u5386\u53f2\u6267\u884c\u8bb0\u5f55\uff08\u5982\u679c\u6709\u591a\u5929\u6267\u884c\u4e00\u6b21\u7684\u4efb\u52a1\u6d41\u7684\u60c5\u51b5\u9700\u8981\u6ce8\u610f\uff0c\u8981\u4fdd\u7559\u6700\u5927\u5468\u671f\u8de8\u5ea6\u7684\u65f6\u95f4\u8303\u56f4\u7684\u6570\u636e\uff09<\/p>\n<p>\u76f8\u5173\u6570\u636e\u8868\uff1aWORKFLOW_COMPLEMENT_COMMAND\u3001WORKFLOW_COMPLEMENT_RECORD\u3001WORKFLOW_COMPLEMENT_WORKSPACE\u3001WORKFLOW_DEBUG_COMMAND\u3001WORKFLOW_DEBUG_RECORD\u3001WORKFLOW_FLOW_EXECUTION\u3001WORKFLOW_FLOW_EXECUTION_DEPENDENCY\u3001WORKFLOW_TASK_EXECUTION<\/p>\n<p>\u5176\u4e2d\uff0cWORKFLOW_FLOW_EXECUTION\u3001WORKFLOW_TASK_EXECUTION\u3001WORKFLOW_FLOW_EXECUTION_DEPENDENCY\u662f\u65e5\u5e38\u65f6\u95f4\u8c03\u5ea6\u4f1a\u4e0d\u65ad\u5199\u5165\u6570\u636e\u7684\u8868\uff0c\u5176\u4ed6\u8868\u591a\u8bb0\u5f55\u7528\u6237\u64cd\u4f5c\u884c\u4e3a\u3002<\/p>\n<h3>\u8be6\u7ec6\u8bf4\u660e<\/h3>\n<hr \/>\n<p>1\u3001\u4e0d\u505c\u673a\u6e05\u7406<\/p>\n<p>\u4ee5\u8c03\u5ea6\u65f6\u95f4\u4e3a\u4f9d\u636e\u8fdb\u884c\u5f85\u6e05\u7406\u6570\u636e\u7b5b\u9009\u53ca\u6e05\u7406\uff0c\u4ee5\u88ab\u6e05\u7406\u7684\u65f6\u95f4\u8303\u56f4\u5185\u7684\u6267\u884c\u8bb0\u5f55\u90fd\u5df2\u6267\u884c\u7ed3\u675f\u4e3a\u524d\u63d0\u3002\u9700\u8981\u6ce8\u610f\uff0c1. \u5982\u679c\u8f83\u65e9\u7684\u8c03\u5ea6\u65f6\u95f4\u7684\u6267\u884c\u8bb0\u5f55\u5728\u8fd1\u671f\u6709\u91cd\u8dd1\u3001\u9519\u8bef\u6062\u590d\u7684\u8fd0\u7ef4\u64cd\u4f5c\uff0c\u4f1a\u88ab\u4e00\u540c\u6e05\u7406\uff0c\u4e3a\u907f\u514d\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528startTime\uff08\u5373\u4efb\u52a1\u6d41\u6267\u884c\u5f00\u59cb\u65f6\u95f4\uff09\u5b57\u6bb5\u66ff\u4ee3\u8c03\u5ea6\u65f6\u95f4\u5b57\u6bb5\u8fdb\u884c\u7b5b\u9009\uff1b2. \u5982\u679c\u8fd1\u671f\u6709\u9488\u5bf9\u6e05\u7406\u65f6\u95f4\u8303\u56f4\u5185\u7684\u65e5\u671f\u8fdb\u884c\u8865\u6570\u7684\u64cd\u4f5c\uff0c\u76f8\u5173\u8865\u6570\u6267\u884c\u8bb0\u5f55\u4f1a\u88ab\u4e00\u8d77\u6e05\u7406\uff0c\u4e3a\u907f\u514d\u8fd9\u4e2a\u95ee\u9898\uff0c\u9700\u8981\u5728\u67e5\u8be2\u5f85\u6e05\u7406\u6267\u884c\u8bb0\u5f55\u65f6\uff0c\u5c06executionMode\u4e3a4\u7684\u8bb0\u5f55\u8fc7\u6ee4\u51fa\u53bb\u3002<\/p>\n<p>\u4ee5\u4e0b\u65b9\u5f0f\u6bcf\u6b21\u6e05\u740610000\u6761\u4efb\u52a1\u6d41\u6267\u884c\u8bb0\u5f55\u53ca\u76f8\u5173\u7684\u4efb\u52a1\u6267\u884c\u8bb0\u5f55\uff0c\u8d85\u51fa\u90e8\u5206\u9700\u8981\u518d\u6b21\u6267\u884c\u3002\u5047\u8bbe\u9700\u8981\u4fdd\u7559\u4ece2024.1.1\u5f00\u59cb\u7684\u6267\u884c\u8bb0\u5f55\u3002<\/p>\n<pre><code class=\"language-sql\"># \u7b2c\u4e00\u90e8\u5206 \u6ce8\u610f\u8be5\u90e8\u5206sql\u53ea\u9700\u8981\u6267\u884c\u4e00\u6b21\uff0c\u4e14\u6267\u884c\u65f6\u52a1\u5fc5\u4fdd\u8bc1\u548c\u7b2c\u4e8c\u90e8\u5206\u7684schedule_time\u8303\u56f4\u4fdd\u6301\u4e00\u81f4\ndelete from WORKFLOW_FLOW_EXECUTION_EXPIRATION where schedule_time < '2024-01-01 00:00:00';\n\n# \u7b2c\u4e8c\u90e8\u5206\u5f00\u59cb \u7b2c\u4e8c\u90e8\u5206\u9700\u8981\u5faa\u73af\u6267\u884c\uff0c\u6bcf\u6b21\u5faa\u73af\u6267\u884c\u7684\u8303\u56f4\u622a\u6b62\u5230\u7b2c\u4e8c\u90e8\u5206\u7ed3\u675f\nDROP temporary table if exists wait_to_delete_flow_execution_ids;\ncreate temporary table wait_to_delete_flow_execution_ids as\nselect id\nfrom WORKFLOW_FLOW_EXECUTION\n# \u6b64\u5904\u5b9a\u4e49\u5220\u9664\u7684\u6761\u4ef6\nwhere scheduleTime < '2024-01-01 00:00:00'\norder by id\nlimit 10000;\n# delete execution dependence\nDELETE\nFROM WORKFLOW_EXECUTION_DEPENDENCY\nWHERE (post_execution_id in (select id from wait_to_delete_flow_execution_ids) AND post_type = 'FLOW')\n   OR (post_execution_id IN (SELECT id\n                             FROM WORKFLOW_TASK_EXECUTION\n                             WHERE parentFlowExecutionId IN (select id\n                                                             from wait_to_delete_flow_execution_ids))\n    AND post_type = 'TASK'\n    );\nDELETE\nFROM WORKFLOW_EXECUTION_DEPENDENCY\nWHERE (pre_execution_id IN (select id from wait_to_delete_flow_execution_ids) AND pre_type = 'FLOW')\n   OR (pre_execution_id IN (SELECT id\n                            FROM WORKFLOW_TASK_EXECUTION\n                            WHERE parentFlowExecutionId IN (select id\n                                                            from wait_to_delete_flow_execution_ids))\n    AND pre_type = 'TASK'\n    );\n# task execution\ndelete\nfrom WORKFLOW_TASK_EXECUTION\nwhere parentFlowExecutionId in (select id from wait_to_delete_flow_execution_ids);\n#  flow execution\ndelete\nfrom WORKFLOW_FLOW_EXECUTION\nwhere id in (select id from wait_to_delete_flow_execution_ids);\n\nDROP temporary table if exists wait_to_delete_flow_execution_ids;\n# \u7b2c\u4e8c\u90e8\u5206\u7ed3\u675f<\/code><\/pre>\n<p>\u6839\u636e\u5982\u4e0a\u64cd\u4f5c\u6e05\u7406\u6267\u884c\u8bb0\u5f55\u6570\u636e\u540e\uff0c\u9488\u5bf9\u7528\u6237\u64cd\u4f5c\u8bb0\u5f55\u7684\u6e05\u7406\u65b9\u5f0f\u5982\u4e0b\u3002<\/p>\n<p>\uff081\uff09\u4ee5createTime\u4e3a\u4f9d\u636e\uff0c\u6e05\u7406\u8865\u6570\u64cd\u4f5c\u8bb0\u5f55\uff08\u4e0d\u5305\u542b\u5bf9flow execution\u7684\u6e05\u7406\uff09\uff0c\u6e05\u7406WORKFLOW_COMPLEMENT_COMMAND\u3001WORKFLOW_COMPLEMENT_RECORD\u4ee5\u53caWORKFLOW_COMPLEMENT_WORKSPACE\u8868\u3002<\/p>\n<pre><code class=\"language-sql\">delete from WORKFLOW_COMPLEMENT_RECORD where commandId in (select commandId from WORKFLOW_COMPLEMENT_COMMAND where createTime < '2024-01-01 00:00:00');\ndelete from WORKFLOW_COMPLEMENT_WORKSPACE where commandId in (select commandId from WORKFLOW_COMPLEMENT_COMMAND where createTime < '2024-01-01 00:00:00');\ndelete from WORKFLOW_COMPLEMENT_COMMAND where createTime < '2024-01-01 00:00:00';<\/code><\/pre>\n<p>\uff082\uff09\u4ee5createTime\u3001scheduleTime\u4e3a\u4f9d\u636e\uff0c\u6e05\u7406\u8c03\u8bd5\u64cd\u4f5c\u8bb0\u5f55\uff08\u4e0d\u5305\u542b\u5bf9flow execution\u7684\u6e05\u7406\uff09\uff0c\u6e05\u7406WORKFLOW_DEBUG_COMMAND\u4ee5\u53caWORKFLOW_DEBUG_RECORD\u8868\u3002<\/p>\n<pre><code class=\"language-sql\">delete from WORKFLOW_DEBUG_COMMAND where createTime < '2024-01-01 00:00:00';\ndelete from WORKFLOW_DEBUG_RECORD where scheduleTime < '2024-01-01 00:00:00';<\/code><\/pre>\n<p>\uff083\uff09\u4ee5createTime\u4e3a\u4f9d\u636e\uff0c\u6e05\u7406\u7528\u6237\u64cd\u4f5c\u8bb0\u5f55\uff0c\u6e05\u7406WORKFLOW_MANUAL_COMMAND\u3001WORKFLOW_OPERATION_COMMAND\u8868\u3002<\/p>\n<pre><code class=\"language-sql\">delete from WORKFLOW_MANUAL_COMMAND where createTime < '2024-01-01 00:00:00';\ndelete from WORKFLOW_OPERATION_COMMAND where createTime < '2024-01-01 00:00:00';<\/code><\/pre>\n<p>\uff084\uff09\u4ee5event_time\u4e3a\u4f9d\u636e\uff0c\u6e05\u7406\u4efb\u52a1\u6d41\u4e8b\u4ef6\u89e6\u53d1\u8bb0\u5f55\uff0c\u6e05\u7406WORKFLOW_FLOW_EVENT_RECORD\u8868\u3002<\/p>\n<pre><code class=\"language-sql\">delete from WORKFLOW_FLOW_EVENT_RECORD where event_ime < '2024-01-01 00:00:00';<\/code><\/pre>\n<p>2\u3001\u505c\u673a\u6e05\u7406<br \/>\n\uff081\uff09\u505c\u6b62workflow\u670d\u52a1<\/p>\n<p>\uff082\uff09\u5c06\u9700\u8981\u4fdd\u7559\u7684\u6570\u636e\u5199\u5165\u65b0\u7684\u8bb0\u5f55\u8868<\/p>\n<pre><code class=\"language-sql\"># rename\nrename table WORKFLOW_FLOW_EXECUTION to WORKFLOW_FLOW_EXECUTION_BAK;\nrename table WORKFLOW_TASK_EXECUTION to WORKFLOW_TASK_EXECUTION_BAK;\nrename table WORKFLOW_EXECUTION_DEPENDENCY to WORKFLOW_EXECUTION_DEPENDENCY_BAK;\nrename table WORKFLOW_FLOW_EXECUTION_EXPIRATION to WORKFLOW_FLOW_EXECUTION_EXPIRATION_BAK;\n# new table\ncreate table WORKFLOW_FLOW_EXECUTION like WORKFLOW_FLOW_EXECUTION_BAK;\ncreate table WORKFLOW_TASK_EXECUTION like WORKFLOW_TASK_EXECUTION_BAK;\ncreate table WORKFLOW_EXECUTION_DEPENDENCY like WORKFLOW_EXECUTION_DEPENDENCY_BAK;\ncreate table WORKFLOW_FLOW_EXECUTION_EXPIRATION like WORKFLOW_FLOW_EXECUTION_EXPIRATION_BAK;\n# insert valid data\ninsert into WORKFLOW_FLOW_EXECUTION select * from WORKFLOW_FLOW_EXECUTION_BAK where scheduleTime >= '2024-01-01 00:00:00';\ninsert into WORKFLOW_FLOW_EXECUTION_EXPIRATION select * from WORKFLOW_FLOW_EXECUTION_EXPIRATION_BAK where schedule_time >= '2024-01-01 00:00:00';\ninsert into WORKFLOW_TASK_EXECUTION select * from WORKFLOW_TASK_EXECUTION_BAK where parentFlowExecutionId in (select id from WORKFLOW_FLOW_EXECUTION);\ninsert into WORKFLOW_EXECUTION_DEPENDENCY select * from WORKFLOW_EXECUTION_DEPENDENCY_BAK where post_execution_id in (select id from WORKFLOW_FLOW_EXECUTION) and post_type = 'FLOW';<\/code><\/pre>\n<p>\uff083\uff09\u5220\u9664\u65e7\u8868\uff0c\u6839\u636e\u5b9e\u9645\u9700\u6c42\u64cd\u4f5c\uff0c\u5982\u679c\u9700\u8981\u4fdd\u7559\u5386\u53f2\u6570\u636e\uff0c\u4e14\u6570\u636e\u76d8\u7a7a\u95f4\u5145\u88d5\uff0c\u4e0d\u9700\u8981\u53e6\u5916\u5220\u9664\uff0c\u4e4b\u540e\u8fdb\u884c\u5347\u7ea7\u3001\u8fc1\u79fb\u7b49\u64cd\u4f5c\u65f6\uff0c\u6ce8\u610f\u6392\u9664\u5907\u4efd\u8868\u3002<\/p>\n<pre><code class=\"language-sql\">drop table WORKFLOW_FLOW_EXECUTION_BAK;\ndrop table WORKFLOW_TASK_EXECUTION_BAK;\ndrop table WORKFLOW_EXECUTION_DEPENDENCY_BAK;\ndrop table WORKFLOW_FLOW_EXECUTION_EXPIRATION_BAK;<\/code><\/pre>\n<p>\uff084\uff09\u542f\u52a8workflow\u670d\u52a1<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 1\u3001\u4efb\u52a1\u6d41\u95f4\u4f9d\u8d56\u5173\u7cfb\uff1a\u4ec5\u652f\u6301\u65e0\u5468\u671f\u4efb\u52a1\u6d41\u4f9d\u8d56\u6709\u5468\u671f\u4efb\u52a1\u6d41\uff0c\u5e76\u4e14\u5728\u6709\u4efb\u52a1\u6d41\u95f4\u4f9d\u8d56\u5173\u7cfb\u7684\u60c5\u51b5\u4e0b\uff0c\u4ec5\u652f\u6301\u4e00 ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=18251\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":161,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-18251","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/18251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/161"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=18251"}],"version-history":[{"count":3,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/18251\/revisions"}],"predecessor-version":[{"id":18254,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/18251\/revisions\/18254"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=18251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=18251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=18251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}