From 7b2f04bb3d29f8780caa7fc85e9f06db72df7d0e Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 1 Dec 2026 12:43:47 -0800 Subject: [PATCH] filer: add log_ts_ns to ObjectTransactionResponse CreateEntry and UpdateEntry return the filer log position stamped under the path lock; a conditional write through ObjectTransaction had no such field. Add it as field 4 so callers can order one key's commits the same way regardless of which RPC applied them. Co-Authored-By: Claude Opus 5.5 --- weed/pb/filer.proto | 3 +++ weed/pb/filer_pb/filer.pb.go | 19 +++++++++++++++---- weed/pb/filer_pb/filer_vtproto.pb.go | 27 +++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/weed/pb/filer.proto b/weed/pb/filer.proto index c0ed942a9c..cc32b5f2e2 100644 --- a/weed/pb/filer.proto +++ b/weed/pb/filer.proto @@ -416,6 +416,9 @@ message ObjectTransactionResponse { string error = 1; FilerError error_code = 2; optional int32 failed_mutation = 3; // index of the mutation that failed (its condition or its apply); unset when the request-level condition failed + // filer log position stamped under the lock after the last mutation + // committed; 0 when the transaction was refused or failed + int64 log_ts_ns = 4; } // PosixLockRange is one advisory byte-range lock. Owner identity is (sid, owner): diff --git a/weed/pb/filer_pb/filer.pb.go b/weed/pb/filer_pb/filer.pb.go index fef06d720e..ac39495150 100644 --- a/weed/pb/filer_pb/filer.pb.go +++ b/weed/pb/filer_pb/filer.pb.go @@ -1992,8 +1992,11 @@ type ObjectTransactionResponse struct { Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` ErrorCode FilerError `protobuf:"varint,2,opt,name=error_code,json=errorCode,proto3,enum=filer_pb.FilerError" json:"error_code,omitempty"` FailedMutation *int32 `protobuf:"varint,3,opt,name=failed_mutation,json=failedMutation,proto3,oneof" json:"failed_mutation,omitempty"` // index of the mutation that failed (its condition or its apply); unset when the request-level condition failed - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + // filer log position stamped under the lock after the last mutation + // committed; 0 when the transaction was refused or failed + LogTsNs int64 `protobuf:"varint,4,opt,name=log_ts_ns,json=logTsNs,proto3" json:"log_ts_ns,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ObjectTransactionResponse) Reset() { @@ -2047,6 +2050,13 @@ func (x *ObjectTransactionResponse) GetFailedMutation() int32 { return 0 } +func (x *ObjectTransactionResponse) GetLogTsNs() int64 { + if x != nil { + return x.LogTsNs + } + return 0 +} + // PosixLockRange is one advisory byte-range lock. Owner identity is (sid, owner): // sid is the mount session, owner the FUSE lock owner within it, so owners from // different mounts never alias. end is inclusive (max uint64 = to EOF); is_flock @@ -7691,12 +7701,13 @@ const file_filer_proto_rawDesc = "" + "request_id\x18\t \x01(\tR\trequestId\x12*\n" + "\x11condition_alt_key\x18\n" + " \x01(\tR\x0fconditionAltKey\x120\n" + - "\x14condition_prefer_alt\x18\v \x01(\bR\x12conditionPreferAlt\"\xa8\x01\n" + + "\x14condition_prefer_alt\x18\v \x01(\bR\x12conditionPreferAlt\"\xc4\x01\n" + "\x19ObjectTransactionResponse\x12\x14\n" + "\x05error\x18\x01 \x01(\tR\x05error\x123\n" + "\n" + "error_code\x18\x02 \x01(\x0e2\x14.filer_pb.FilerErrorR\terrorCode\x12,\n" + - "\x0ffailed_mutation\x18\x03 \x01(\x05H\x00R\x0efailedMutation\x88\x01\x01B\x12\n" + + "\x0ffailed_mutation\x18\x03 \x01(\x05H\x00R\x0efailedMutation\x88\x01\x01\x12\x1a\n" + + "\tlog_ts_ns\x18\x04 \x01(\x03R\alogTsNsB\x12\n" + "\x10_failed_mutation\"\xa1\x01\n" + "\x0ePosixLockRange\x12\x14\n" + "\x05start\x18\x01 \x01(\x04R\x05start\x12\x10\n" + diff --git a/weed/pb/filer_pb/filer_vtproto.pb.go b/weed/pb/filer_pb/filer_vtproto.pb.go index 5f54af4fb5..60a348b62e 100644 --- a/weed/pb/filer_pb/filer_vtproto.pb.go +++ b/weed/pb/filer_pb/filer_vtproto.pb.go @@ -1768,6 +1768,11 @@ func (m *ObjectTransactionResponse) MarshalToSizedBufferVT(dAtA []byte) (int, er i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } + if m.LogTsNs != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.LogTsNs)) + i-- + dAtA[i] = 0x20 + } if m.FailedMutation != nil { i = protohelpers.EncodeVarint(dAtA, i, uint64(*m.FailedMutation)) i-- @@ -7481,6 +7486,9 @@ func (m *ObjectTransactionResponse) SizeVT() (n int) { if m.FailedMutation != nil { n += 1 + protohelpers.SizeOfVarint(uint64(*m.FailedMutation)) } + if m.LogTsNs != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.LogTsNs)) + } n += len(m.unknownFields) return n } @@ -14654,6 +14662,25 @@ func (m *ObjectTransactionResponse) UnmarshalVT(dAtA []byte) error { } } m.FailedMutation = &v + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LogTsNs", wireType) + } + m.LogTsNs = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LogTsNs |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := protohelpers.Skip(dAtA[iNdEx:])