File tree Expand file tree Collapse file tree
broker/src/main/java/org/apache/rocketmq/broker/transaction
common/src/main/java/org/apache/rocketmq/common
store/src/main/java/org/apache/rocketmq/store/timer Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525import java .io .IOException ;
2626import java .io .OutputStreamWriter ;
2727import java .io .Writer ;
28+ import java .nio .channels .FileChannel ;
2829import java .nio .charset .StandardCharsets ;
30+ import java .nio .file .Path ;
31+ import java .nio .file .Paths ;
32+ import java .nio .file .StandardOpenOption ;
2933import java .util .Iterator ;
3034import java .util .Map ;
3135import java .util .Set ;
@@ -209,6 +213,10 @@ public synchronized void persist() {
209213 File configFile = new File (config );
210214 if (configFile .exists ()) {
211215 Files .copy (configFile , new File (backup ));
216+ Path backupPath = Paths .get (backup );
217+ try (FileChannel channel = FileChannel .open (backupPath , StandardOpenOption .WRITE )) {
218+ channel .force (true ); // force flush before deleting original file.
219+ }
212220 configFile .delete ();
213221 }
214222
Original file line number Diff line number Diff line change @@ -287,7 +287,7 @@ public class BrokerConfig extends BrokerIdentity {
287287 @ ImportantField
288288 private long transactionCheckInterval = 30 * 1000 ;
289289
290- private long transactionMetricFlushInterval = 3 * 1000 ;
290+ private long transactionMetricFlushInterval = 10 * 1000 ;
291291
292292 /**
293293 * transaction batch op message
Original file line number Diff line number Diff line change 2525import java .io .IOException ;
2626import java .io .OutputStreamWriter ;
2727import java .io .Writer ;
28+ import java .nio .channels .FileChannel ;
2829import java .nio .charset .StandardCharsets ;
30+ import java .nio .file .Path ;
31+ import java .nio .file .Paths ;
32+ import java .nio .file .StandardOpenOption ;
2933import java .util .ArrayList ;
3034import java .util .Iterator ;
3135import java .util .List ;
@@ -263,6 +267,10 @@ public synchronized void persist() {
263267 File configFile = new File (config );
264268 if (configFile .exists ()) {
265269 Files .copy (configFile , new File (backup ));
270+ Path backupPath = Paths .get (backup );
271+ try (FileChannel channel = FileChannel .open (backupPath , StandardOpenOption .WRITE )) {
272+ channel .force (true ); // force flush before deleting original file.
273+ }
266274 configFile .delete ();
267275 }
268276
You can’t perform that action at this time.
0 commit comments