Skip to content

Commit 348fe72

Browse files
authored
Merge pull request #8482 from dannyzaken/danny-dedup
Avoid dedup chunks that are relatively new
2 parents 2789d60 + fa948fc commit 348fe72

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

config.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,9 @@ config.CHUNK_CODER_EC_PARITY_TYPE = 'cm256';
392392
config.CHUNK_CODER_EC_TOLERANCE_THRESHOLD = 2;
393393
config.CHUNK_CODER_EC_IS_DEFAULT = false;
394394

395+
// DEDUP
396+
config.MIN_CHUNK_AGE_FOR_DEDUP = 60 * 60 * 1000; // 1 hour
397+
395398
//////////////////////////
396399
// DEDUP INDEXER CONFIG //
397400
//////////////////////////
@@ -870,7 +873,7 @@ config.ENDPOINT_SSL_PORT = Number(process.env.ENDPOINT_SSL_PORT) || 6443;
870873
config.ENDPOINT_SSL_STS_PORT = Number(process.env.ENDPOINT_SSL_STS_PORT) || -1;
871874
config.ENDPOINT_SSL_IAM_PORT = Number(process.env.ENDPOINT_SSL_IAM_PORT) || -1;
872875
config.ALLOW_HTTP = false;
873-
// config files should allow access to the owner of the files
876+
// config files should allow access to the owner of the files
874877
config.BASE_MODE_CONFIG_FILE = 0o600;
875878
config.BASE_MODE_CONFIG_DIR = 0o700;
876879

@@ -1054,10 +1057,10 @@ function _get_config_root() {
10541057
}
10551058

10561059
/**
1057-
* validate_nc_master_keys_config validates the following -
1060+
* validate_nc_master_keys_config validates the following -
10581061
* 1. if type is file -
10591062
* 1.1. no GET/PUT executables provided
1060-
* 2. if type is executable -
1063+
* 2. if type is executable -
10611064
* 2.1. no file location provided
10621065
* 2.2. GET & PUT executables exist and executables
10631066
*/

src/server/object_services/mapper.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ function map_chunk(chunk, tier, tiering, tiering_status, location_info) {
186186
}
187187

188188
/**
189-
* @param {nb.TierMirror} mirror
189+
* @param {nb.TierMirror} mirror
190190
*/
191191
function map_frag_in_mirror(mirror) {
192192
const used_blocks = [];
@@ -291,6 +291,13 @@ function is_chunk_good_for_dedup(chunk) {
291291
if (!chunk.is_accessible) return false;
292292
if (chunk.is_building_blocks) return false;
293293
if (chunk.is_building_frags) return false;
294+
295+
// reject chunks that are not at least config.MIN_CHUNK_AGE_FOR_DEDUP old
296+
// this is to avoid deduping chunks that might be from a previous attempt to write the same object
297+
// see https://bugzilla.redhat.com/show_bug.cgi?id=2256223
298+
const chunk_age = Date.now() - chunk._id.getTimestamp().getTime();
299+
if (chunk_age < config.MIN_CHUNK_AGE_FOR_DEDUP) return false;
300+
294301
return true;
295302
}
296303

@@ -360,15 +367,15 @@ function _block_sort_newer_first(block1, block2) {
360367

361368

362369
/**
363-
* @param {nb.Pool} pool
370+
* @param {nb.Pool} pool
364371
* @returns {boolean}
365372
*/
366373
function _pool_has_redundancy(pool) {
367374
return Boolean(pool.cloud_pool_info || pool.mongo_pool_info);
368375
}
369376

370377
// /**
371-
// *
378+
// *
372379
// * @param {nb.Chunk} chunk
373380
// * @param {nb.LocationInfo} [location_info]
374381
// */

src/test/unit_tests/test_encryption.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ let wrapped_coretest_secret_key;
2929
const BKT = `bucket.example`;
3030
const key_rotator = new KeyRotator({ name: 'kr'});
3131

32+
config.MIN_CHUNK_AGE_FOR_DEDUP = 0;
33+
3234
mocha.describe('Encryption tests', function() {
3335
const { rpc_client, EMAIL, SYSTEM } = coretest;
3436
let response_account;
@@ -991,10 +993,10 @@ mocha.describe('Rotation tests', function() {
991993
compare_secrets(secrets, system_store_account.master_key_id._id);
992994
});
993995
});
994-
// TODO:
996+
// TODO:
995997
// 1. add more tests for checking namespace resources
996998
// 2. add tests for enable/disable account that has pool/namespace resource
997-
////////////// HELPERS
999+
////////////// HELPERS
9981000

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

0 commit comments

Comments
 (0)