@@ -40,7 +40,7 @@ const (
4040// If xmax != xid, it adds xid to the xip_list to make the snapshot unique.
4141func createFinalSnapshot (snapshotValue string , xid uint64 ) string {
4242 // Parse snapshot: "xmin:xmax:xip_list"
43- parts := strings .Split ( snapshotValue , ":" )
43+ parts := strings .SplitN ( strings . TrimSpace ( snapshotValue ) , ":" , 3 )
4444 if len (parts ) < 2 {
4545 // Invalid snapshot format, return original
4646 return snapshotValue
@@ -65,14 +65,18 @@ func createFinalSnapshot(snapshotValue string, xid uint64) string {
6565 return snapshotValue
6666 }
6767
68- // xmax > xid, need to add xid to xip_list for uniqueness
68+ // xmax > xid, need to consider adding xid to xip_list for uniqueness
6969 xmin := parts [0 ]
70+ // Do not add if xid <= xmin; it would wrongly mark a visible xid as in-progress.
71+ if xminVal , err := strconv .ParseUint (xmin , 10 , 64 ); err == nil && xid <= xminVal {
72+ return snapshotValue
73+ }
7074
7175 // Check if xip_list exists and is not empty
7276 if len (parts ) == 3 && parts [2 ] != "" {
7377 // Check if xid is already in xip_list
7478 xipList := parts [2 ]
75- for xip := range strings .SplitSeq (xipList , "," ) {
79+ for _ , xip := range strings .Split (xipList , "," ) {
7680 if strings .TrimSpace (xip ) == fmt .Sprintf ("%d" , xid ) {
7781 // xid already in xip_list, return original snapshot
7882 return snapshotValue
0 commit comments