mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-07 04:27:49 +01:00
filer: keep the remote check for an exclusive create in a transaction
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bd0505eb80
commit
b6aac15c3b
2 files changed
+8
-3
No files matched your search
+3
-3
@@ -525,10 +525,10 @@ func (f *Filer) CreateEntry(ctx context.Context, entry *Entry, existing *Entry,
|
||||
if oldEntry == nil {
|
||||
var findErr error
|
||||
// A lazy fetch here would persist outside the transaction and wait on
|
||||
// the lock it holds for a target it just deleted; the create writes
|
||||
// the path either way.
|
||||
// the lock it holds for a target it just deleted; a non-exclusive
|
||||
// create writes the path either way.
|
||||
findCtx := ctx
|
||||
if ctx.Value(storeTransactionKey{}) != nil {
|
||||
if ctx.Value(storeTransactionKey{}) != nil && !o_excl {
|
||||
findCtx = context.WithValue(ctx, lazyFetchContextKey{}, true)
|
||||
}
|
||||
oldEntry, findErr = f.FindEntry(findCtx, entry.FullPath)
|
||||
|
||||
@@ -763,6 +763,11 @@ func TestCreateEntry_SkipsTheLazyFetchInsideAStoreTransaction(t *testing.T) {
|
||||
require.NotNil(t, entry)
|
||||
assert.True(t, entry.IsInRemoteOnly())
|
||||
assert.NotZero(t, countingStub.statCalls)
|
||||
|
||||
// an exclusive create inside the transaction still sees the remote object
|
||||
excl := &Entry{FullPath: "/buckets/mybucket/dir/c.txt", Attr: Attr{Mode: 0644, Mtime: time.Now(), Crtime: time.Now()}}
|
||||
err = f.CreateEntry(txCtx, excl, nil, true, false, nil, false, f.MaxFilenameLength)
|
||||
assert.ErrorIs(t, err, filer_pb.ErrEntryAlreadyExists)
|
||||
}
|
||||
|
||||
func TestMaybeLazyFetchFromRemote_GuardedClientRejectsEndpoint(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user