Skip to content

[Backport to 5.17] Avoid dedup chunks that are relatively new #8530

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

Merged
merged 1 commit into from
Nov 17, 2024
Merged
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
9 changes: 6 additions & 3 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ config.CHUNK_CODER_EC_PARITY_TYPE = 'cm256';
config.CHUNK_CODER_EC_TOLERANCE_THRESHOLD = 2;
config.CHUNK_CODER_EC_IS_DEFAULT = false;

// DEDUP
config.MIN_CHUNK_AGE_FOR_DEDUP = 60 * 60 * 1000; // 1 hour

//////////////////////////
// DEDUP INDEXER CONFIG //
//////////////////////////
Expand Down Expand Up @@ -886,7 +889,7 @@ config.ENDPOINT_SSL_PORT = Number(process.env.ENDPOINT_SSL_PORT) || 6443;
config.ENDPOINT_SSL_STS_PORT = Number(process.env.ENDPOINT_SSL_STS_PORT) || -1;
config.ENDPOINT_SSL_IAM_PORT = Number(process.env.ENDPOINT_SSL_IAM_PORT) || -1;
config.ALLOW_HTTP = false;
// config files should allow access to the owner of the files
// config files should allow access to the owner of the files
config.BASE_MODE_CONFIG_FILE = 0o600;
config.BASE_MODE_CONFIG_DIR = 0o700;

Expand Down Expand Up @@ -1069,10 +1072,10 @@ function _get_config_root() {
}

/**
* validate_nc_master_keys_config validates the following -
* validate_nc_master_keys_config validates the following -
* 1. if type is file -
* 1.1. no GET/PUT executables provided
* 2. if type is executable -
* 2. if type is executable -
* 2.1. no file location provided
* 2.2. GET & PUT executables exist and executables
*/
Expand Down
13 changes: 10 additions & 3 deletions src/server/object_services/mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function map_chunk(chunk, tier, tiering, tiering_status, location_info) {
}

/**
* @param {nb.TierMirror} mirror
* @param {nb.TierMirror} mirror
*/
function map_frag_in_mirror(mirror) {
const used_blocks = [];
Expand Down Expand Up @@ -291,6 +291,13 @@ function is_chunk_good_for_dedup(chunk) {
if (!chunk.is_accessible) return false;
if (chunk.is_building_blocks) return false;
if (chunk.is_building_frags) return false;

// reject chunks that are not at least config.MIN_CHUNK_AGE_FOR_DEDUP old
// this is to avoid deduping chunks that might be from a previous attempt to write the same object
// see https://bugzilla.redhat.com/show_bug.cgi?id=2256223
const chunk_age = Date.now() - chunk._id.getTimestamp().getTime();
if (chunk_age < config.MIN_CHUNK_AGE_FOR_DEDUP) return false;

return true;
}

Expand Down Expand Up @@ -360,15 +367,15 @@ function _block_sort_newer_first(block1, block2) {


/**
* @param {nb.Pool} pool
* @param {nb.Pool} pool
* @returns {boolean}
*/
function _pool_has_redundancy(pool) {
return Boolean(pool.cloud_pool_info || pool.mongo_pool_info);
}

// /**
// *
// *
// * @param {nb.Chunk} chunk
// * @param {nb.LocationInfo} [location_info]
// */
Expand Down
6 changes: 4 additions & 2 deletions src/test/unit_tests/test_encryption.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ let wrapped_coretest_secret_key;
const BKT = `bucket.example`;
const key_rotator = new KeyRotator({ name: 'kr'});

config.MIN_CHUNK_AGE_FOR_DEDUP = 0;

mocha.describe('Encryption tests', function() {
const { rpc_client, EMAIL, SYSTEM } = coretest;
let response_account;
Expand Down Expand Up @@ -991,10 +993,10 @@ mocha.describe('Rotation tests', function() {
compare_secrets(secrets, system_store_account.master_key_id._id);
});
});
// TODO:
// TODO:
// 1. add more tests for checking namespace resources
// 2. add tests for enable/disable account that has pool/namespace resource
////////////// HELPERS
////////////// HELPERS

async function multipart_upload(bucket, key, s3_conf) {
let res = await s3_conf.createMultipartUpload({Bucket: bucket, Key: key, ContentType: 'text/plain'});
Expand Down