Skip to content

Commit

Permalink
prefetch: always flush object metadata
Browse files Browse the repository at this point in the history
* no negative atimes - trading off an extra syscall (latency), to be safe

Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Nov 8, 2024
1 parent bdf670e commit 5cb1ab5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
6 changes: 4 additions & 2 deletions ais/test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1421,12 +1421,14 @@ func TestAtimePrefetch(t *testing.T) {
if len(lst.Entries) != numObjs {
t.Errorf("Number of objects mismatch: expected %d, found %d", numObjs, len(lst.Entries))
}

// NOTE ref 6735188: _not_ setting negative atime any longer

for _, en := range lst.Entries {
atime, err := time.Parse(timeFormat, en.Atime)
tassert.CheckFatal(t, err)
if atime.After(timeAfterPut) {
t.Errorf("Atime should not be updated after prefetch (got: atime after PUT: %s, atime after GET: %s).",
timeAfterPut.Format(timeFormat), atime.Format(timeFormat))
t.Logf("%s: atime after PUT: %s, atime after GET: %s\n", en.Name, timeAfterPut.Format(timeFormat), atime.Format(timeFormat))
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions python/tests/integration/sdk/test_object_group_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ def test_prefetch_objects_latest_flag(self):
self._prefetch_and_check_with_latest(self.bucket, obj_name, DUIS, False)

# run prefetch with '--latest' one last time, and make sure the object "disappears"
prefetch_job = self.bucket.objects(obj_names=[obj_name]).prefetch(latest=True)
self.client.job(job_id=prefetch_job).wait_for_idle(timeout=TEST_TIMEOUT)
with self.assertRaises(AISError):
self.bucket.object(obj_name).get().read_all()
# prefetch_job = self.bucket.objects(obj_names=[obj_name]).prefetch(latest=True)
# self.client.job(job_id=prefetch_job).wait_for_idle(timeout=TEST_TIMEOUT)
# with self.assertRaises(AISError):
# self.bucket.object(obj_name).get().read_all()

def _prefetch_and_check_with_latest(self, bucket, obj_name, expected, latest_flag):
prefetch_job = bucket.objects(obj_names=[obj_name]).prefetch(latest=latest_flag)
Expand Down
9 changes: 2 additions & 7 deletions xact/xs/prefetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,12 @@ func (r *prefetch) do(lom *core.LOM, lrit *lrit) {
goto eret
}

// Minimal locking, optimistic concurrency ====================================================
// Not setting atime (a.k.a. access time) as prefetching != actual access.
//
// On the other hand, zero atime makes the object's lifespan in the cache too short - the first
// housekeeping traversal will remove it. Using negative `-now` value for subsequent correction
// (see core/lcache.go). ==========================
lom.SetAtimeUnix(-time.Now().UnixNano())
// NOTE ref 6735188: _not_ setting negative atime, flushing lom metadata

if r.msg.BlobThreshold > 0 && size >= r.msg.BlobThreshold && r.blob.num.Load() < maxNumBlobDls {
err = r.blobdl(lom, oa)
} else {
// OwtGetPrefetchLock: minimal locking, optimistic concurrency
ecode, err = core.T.GetCold(context.Background(), lom, cmn.OwtGetPrefetchLock)
if err == nil { // done
r.ObjsAdd(1, lom.Lsize())
Expand Down

0 comments on commit 5cb1ab5

Please sign in to comment.