@@ -455,34 +455,28 @@ public void append(String tableName, long commitId, Mutation mutation) throws IO
455
455
456
456
/**
457
457
* Performs a sync operation, but only after verifying that the writer's generation stamp
458
- * is still valid. Acquires the manager's lock during the check and the delegate sync
459
- * operation. It is therefore impossible for a sync of the underlying writer and a log
460
- * roll to happen concurrently. We are guaranteed the sync will succeed (or fail) without
461
- * interference from the manager.
458
+ * is still valid.
462
459
* @throws IOException if the underlying sync fails.
463
460
* @throws StaleLogWriterException if the writer instance has been rotated
464
461
* out since it was acquired.
465
462
*/
466
463
@ Override
467
464
public void sync () throws IOException {
468
- lock .lock (); // Acquire the manager's lock so sync doesn't race with a roll.
469
- try {
470
- long current = writerGeneration ;
471
- if (this .generation != current ) {
472
- throw new StaleLogWriterException (
473
- "Log writer rotated during operation. Expected generation " + generation
474
- + ", found " + current );
475
- }
476
- // Generation is still valid, proceed with sync on the delegate writer
477
- if (LOG .isTraceEnabled ()) {
478
- LOG .trace ("Syncing writer {} with generation {}" , delegate , generation );
479
- }
480
- delegate .sync ();
481
- if (LOG .isTraceEnabled ()) {
482
- LOG .trace ("Sync successful for writer {} with generation {}" , delegate , generation );
483
- }
484
- } finally {
485
- lock .unlock (); // Release the manager's lock
465
+ long current = writerGeneration ;
466
+ if (this .generation != current ) {
467
+ throw new StaleLogWriterException (
468
+ "Log writer rotated during operation. Expected generation " + generation
469
+ + ", found " + current );
470
+ }
471
+ // Generation is still valid, proceed with sync on the delegate writer
472
+ if (LOG .isTraceEnabled ()) {
473
+ LOG .trace ("Syncing writer {} with generation {}" , delegate , generation );
474
+ }
475
+ // We can drop the lock to do the actual sync. We only needed the lock to know the
476
+ // writer is still valid at the time we go to invoke sync on the delegate.
477
+ delegate .sync ();
478
+ if (LOG .isTraceEnabled ()) {
479
+ LOG .trace ("Sync successful for writer {} with generation {}" , delegate , generation );
486
480
}
487
481
}
488
482
0 commit comments