Skip to content

Commit f88d402

Browse files
authored
remove post insert validation from enqueue_workflow for cockroach db compat (#301)
1 parent 1d42e27 commit f88d402

2 files changed

Lines changed: 1 addition & 63 deletions

File tree

transact/src/main/java/dev/dbos/transact/migrations/MigrationManager.java

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,6 @@ created_at BIGINT NOT NULL DEFAULT (EXTRACT(epoch FROM now()) * 1000.0)::bigint
479479
v_now BIGINT;
480480
v_recovery_attempts INTEGER := 0;
481481
v_priority INTEGER;
482-
v_existing_name TEXT;
483-
v_existing_class_name TEXT;
484-
v_existing_config_name TEXT;
485482
BEGIN
486483
487484
-- Validate required parameters
@@ -526,26 +523,7 @@ IF named_args IS NOT NULL AND jsonb_typeof(named_args::jsonb) != 'object' THEN
526523
)
527524
ON CONFLICT (workflow_uuid)
528525
DO UPDATE SET
529-
updated_at = EXCLUDED.updated_at
530-
RETURNING workflow_status.name, workflow_status.class_name, workflow_status.config_name
531-
INTO v_existing_name, v_existing_class_name, v_existing_config_name;
532-
533-
-- Validate workflow metadata matches
534-
IF v_existing_name IS DISTINCT FROM workflow_name THEN
535-
RAISE EXCEPTION 'Conflicting DBOS workflow name'
536-
USING DETAIL = format('Workflow %%s exists with name %%s, but the provided workflow name is: %%s', v_workflow_id, v_existing_name, workflow_name),
537-
ERRCODE = 'invalid_parameter_value';
538-
END IF;
539-
IF v_existing_class_name IS DISTINCT FROM class_name THEN
540-
RAISE EXCEPTION 'Conflicting DBOS workflow class_name'
541-
USING DETAIL = format('Workflow %%s exists with class_name %%s, but the provided class_name is: %%s', v_workflow_id, v_existing_class_name, class_name),
542-
ERRCODE = 'invalid_parameter_value';
543-
END IF;
544-
IF v_existing_config_name IS DISTINCT FROM config_name THEN
545-
RAISE EXCEPTION 'Conflicting DBOS workflow config_name'
546-
USING DETAIL = format('Workflow %%s exists with config_name %%s, but the provided config_name is: %%s', v_workflow_id, v_existing_config_name, config_name),
547-
ERRCODE = 'invalid_parameter_value';
548-
END IF;
526+
updated_at = EXCLUDED.updated_at;
549527
550528
RETURN v_workflow_id;
551529

transact/src/test/java/dev/dbos/transact/client/PgSqlClientTest.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -126,46 +126,6 @@ public interface ThrowingFunction<P, T, E extends Exception> {
126126
T execute(P param) throws E;
127127
}
128128

129-
@Test
130-
public void clientEnqueueInvalidWorkflowName() throws Exception {
131-
final var workflowId = UUID.randomUUID().toString();
132-
133-
ThrowingFunction<String, String, Exception> enqueueSupplier =
134-
(workflowName) -> {
135-
var sql = "SELECT dbos.enqueue_workflow(?, ?, ?, workflow_id => ?, class_name => ?)";
136-
try (var conn = dataSource.getConnection();
137-
var stmt = conn.prepareCall(sql)) {
138-
stmt.setString(1, workflowName);
139-
stmt.setString(2, "testQueue");
140-
var argsArray =
141-
conn.createArrayOf(
142-
"json",
143-
new String[] {
144-
MAPPER.writeValueAsString("42"), MAPPER.writeValueAsString("spam")
145-
});
146-
stmt.setObject(3, argsArray);
147-
stmt.setString(4, workflowId);
148-
stmt.setString(5, "ClientServiceImpl");
149-
try (ResultSet rs = stmt.executeQuery()) {
150-
return rs.next() ? rs.getString(1) : null;
151-
} finally {
152-
argsArray.free();
153-
}
154-
}
155-
};
156-
157-
String retValue = enqueueSupplier.execute("enqueueTest");
158-
assertEquals(workflowId, retValue);
159-
160-
var ex = assertThrows(PSQLException.class, () -> enqueueSupplier.execute("wrong name"));
161-
assertTrue(ex.getMessage().startsWith("ERROR: Conflicting DBOS workflow name"));
162-
assertTrue(
163-
ex.getMessage()
164-
.contains(
165-
"Workflow %s exists with name %s, but the provided workflow name is: %s"
166-
.formatted(workflowId, "enqueueTest", "wrong name")));
167-
}
168-
169129
@Test
170130
public void clientEnqueueDeDupe() throws Exception {
171131
var qs = DBOSTestAccess.getQueueService();

0 commit comments

Comments
 (0)