Abacn commented on issue #18592:
URL: https://github.com/apache/beam/issues/18592#issuecomment-2245548223

   Found that tearDown is never called in Dataflow runner v1 or v2, even 
pipeline finished normally
   
   Just use a simple DoFn:
   
   ```
       pipeline
           .apply(GenerateSequence.from(0).to(1000))
           .apply(ParDo.of(new SomeDoFn()));
   ```
   
   where SomeDoFn is 
   
   ```
   static class SomeDoFn extends DoFn<Long, Long> {
   
       protected transient Integer id;
   
       @Setup
       public void setup() {
         Integer idOld = id;
         id = ThreadLocalRandom.current().nextInt(0, 1000);
         LOG.info("@Setup {}, {} at {}", idOld, id, 
Integer.toHexString(System.identityHashCode(this)));
       }
   
       @StartBundle
       public void startBundle() {
         LOG.info("@StartBundle {} at {}", id, 
Integer.toHexString(System.identityHashCode(this)));
       }
   
       @ProcessElement
       public void process(@Element Long input, OutputReceiver<Long> receiver) {
         // LOG.info("@ProcessElement for {} at bundle {}", input, id);
         receiver.output(input);
       }
   
       @FinishBundle
       public void finishBundle() throws Exception {
         LOG.info("@FinishBundle {} at {}", id, 
Integer.toHexString(System.identityHashCode(this)));
       }
   
       @Teardown
       public void teardown() {
         LOG.info("@Teardown {} at {}", id, 
Integer.toHexString(System.identityHashCode(this)));
       }
   
       @Override
       protected void finalize() throws Throwable {
         LOG.info("finalize");
       }
     }
   ```
   
   seen log in setup, start/finishBundle, but not teardown.


-- 
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