Skip to content

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

@XiaoyiPeng

Description

@XiaoyiPeng

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();
             // ....
             }

     }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions