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

To test if sync writes #7860

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1410,9 +1410,14 @@ private void compact() {
boolean success = false;
try {
// create the new file
openRAF();
openRAF(true);
// fill the new file with data
writeLiveData();

if (shouldCloseAndReopenRAF()) {
ifRAF.close();
openRAF(false);
}
success = true;

// delete the old file
Expand All @@ -1424,6 +1429,10 @@ private void compact() {
if (logger.isDebugEnabled()) {
logger.debug("Exception compacting init file {}", this, e);
}
} catch (IOException e) {
if (logger.isDebugEnabled()) {
logger.debug("Exception when closing init file {}", this, e);
}
} finally {
if (!success) {
// if we failed
Expand All @@ -1440,7 +1449,7 @@ private void compact() {
"could not rename file " + tmpFile + " to " + ifFile, parent);
}
// reopen the old file since we couldn't write the new one
openRAF();
openRAF(false);
// reset the counts to 0 so we will try a compaction again
// in the future but not right away.
ifLiveRecordCount = 0;
Expand All @@ -1449,7 +1458,7 @@ private void compact() {
}
} else {
// reopen the old file since we couldn't rename it
openRAF();
openRAF(false);
// reset the counts to 0 so we will try a compaction again
// in the future but not right away.
ifLiveRecordCount = 0;
Expand All @@ -1461,14 +1470,14 @@ private void compact() {
}
}

private void openRAF() {
private void openRAF(boolean isCompaction) {
if (DiskStoreImpl.PREALLOCATE_IF) {
openRAF2();
openRAF2(isCompaction);
return;
}

try {
ifRAF = new RandomAccessFile(ifFile, getFileMode());
ifRAF = new RandomAccessFile(ifFile, isCompaction ? getCompactionFileMode() : getFileMode());
long len = ifRAF.length();
if (len != 0) {
ifRAF.seek(len);
Expand All @@ -1484,9 +1493,17 @@ protected String getFileMode() {
return DiskStoreImpl.SYNC_IF_WRITES ? "rwd" : "rw";
}

private void openRAF2() {
protected String getCompactionFileMode() {
return DiskStoreImpl.SYNC_IF_COMPACTION_WRITES ? "rwd" : "rw";
}

protected boolean shouldCloseAndReopenRAF() {
return !getCompactionFileMode().equals(getFileMode());
}

private void openRAF2(boolean isCompaction) {
try {
ifRAF = new RandomAccessFile(ifFile, getFileMode());
ifRAF = new RandomAccessFile(ifFile, isCompaction ? getCompactionFileMode() : getFileMode());
long len = ifRAF.length();
if (len != 0) {
// this.ifRAF.seek(len);
Expand Down Expand Up @@ -1810,7 +1827,7 @@ private byte[] pmidToBytes(PersistentMemberID id) {
&& !this.parent.isOfflineModify()) {
dump();
}
openRAF();
openRAF(false);
if (!this.parent.isOffline() || this.parent.isOfflineCompacting()) {
if (didNotExist) {
this.parent.setDiskStoreID(DiskStoreID.random());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,16 @@ public static boolean getBoolean(String sysProp, boolean def) {
public static boolean SET_IGNORE_PREALLOCATE = false;

/**
* This system property turns on synchronous writes just the the init file.
* This system property turns on synchronous writes just the init file.
*/
static final boolean SYNC_IF_WRITES =
Boolean.getBoolean(GeodeGlossary.GEMFIRE_PREFIX + "syncMetaDataWrites");
static final boolean SYNC_IF_WRITES = true;


/**
* This system property turns on synchronous writes just for the init file during compaction.
*/
static final boolean SYNC_IF_COMPACTION_WRITES =
Boolean.getBoolean(GeodeGlossary.GEMFIRE_PREFIX + "syncMetaDataCompactionWrites");

/**
* For testing - to keep track of files for which fallocate happened
Expand Down