justinmclean opened a new issue, #10167:
URL: https://github.com/apache/gravitino/issues/10167

   ### What would you like to be improved?
   
   TopicOperationDispatcher#createTopic creates the topic in the catalog, then 
persists TopicEntity via store.put(...). If store.put throws, the exception is 
caught and only logged; the method still returns a successful Topic result. 
This can report success while Gravitino metadata was not written, leaving the 
catalog and metadata store inconsistent and causing later operations to behave 
incorrectly.
   
   ### How should we improve?
   
   Treat store.put failure as an operation failure: rethrow as a runtime/domain 
exception instead of returning success. 
   
   Here's a unit test to help:
   ```
   @Test
   public void testCreateTopicShouldFailWhenStorePutFails() throws IOException {
     Namespace topicNs = Namespace.of(metalake, catalog, "schema171");
     Map<String, String> props = ImmutableMap.of("k1", "v1", "k2", "v2");
     
schemaOperationDispatcher.createSchema(NameIdentifier.of(topicNs.levels()), 
"comment", props);
   
     reset(entityStore);
     doThrow(new IOException("store put failed")).when(entityStore).put(any(), 
eq(true));
   
     NameIdentifier topicIdent = NameIdentifier.of(topicNs, "topic71");
     Assertions.assertThrows(
         RuntimeException.class,
         () -> topicOperationDispatcher.createTopic(topicIdent, "comment", 
null, props));
   }
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to