Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The variable DLedgerMmapFileStore#isDiskFull should be decorated with the volatile. #103

Closed
XiaoyiPeng opened this issue Jan 18, 2022 · 1 comment

Comments

@XiaoyiPeng
Copy link
Contributor

The variable DLedgerMmapFileStore#isDiskFull should be decorated with the volatile,

because it will be written by the thread CleanSpaceService, and it will be read by other threads when append DLedgerEntry, as shown below:

class CleanSpaceService extends ShutdownAbleThread {

      double storeBaseRatio = DLedgerUtils.getDiskPartitionSpaceUsedPercent(dLedgerConfig.getStoreBaseDir());
      double dataRatio = DLedgerUtils.getDiskPartitionSpaceUsedPercent(dLedgerConfig.getDataStorePath());

      public CleanSpaceService(String name, Logger logger) {
          super(name, logger);
      }

      @Override public void doWork() {
          try {
              storeBaseRatio = DLedgerUtils.getDiskPartitionSpaceUsedPercent(dLedgerConfig.getStoreBaseDir());
              dataRatio = DLedgerUtils.getDiskPartitionSpaceUsedPercent(dLedgerConfig.getDataStorePath());
              long hourOfMs = 3600L * 1000L;
              long fileReservedTimeMs = dLedgerConfig.getFileReservedHours() *  hourOfMs;
              if (fileReservedTimeMs < hourOfMs) {
                  logger.warn("The fileReservedTimeMs={} is smaller than hourOfMs={}", fileReservedTimeMs, hourOfMs);
                  fileReservedTimeMs =  hourOfMs;
              }
              //If the disk is full, should prevent more data to get in
              DLedgerMmapFileStore.this.isDiskFull = isNeedForbiddenWrite();
             // ....
             }

     }
}
XiaoyiPeng added a commit to XiaoyiPeng/dledger that referenced this issue Jan 18, 2022
…skFull should be decorated with the volatile
RongtongJin pushed a commit that referenced this issue Feb 18, 2022
… the volatile. (#104)

* [ISSUE #103] fix: The variable DLedgerMmapFileStore#isDiskFull should be decorated with the volatile

* fix: Avoid double counting elapsed time.
@RongtongJin
Copy link
Contributor

Merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants