Skip to content

Commit 8d9baab

Browse files
RELEASE 2021.1 hotfix patch 12.04
1 parent 635bb25 commit 8d9baab

26 files changed

Lines changed: 396 additions & 306 deletions

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ Next, specify the necessary set of keys in the project
6565
-Dcom.sun.management.jmxremote.local.only=false
6666
-Dcom.sun.management.jmxremote.authenticate=false
6767
-Dcom.sun.management.jmxremote.ssl=false
68-
-Xms256m
69-
-Xmn512m
68+
-Xms1g
7069
-Xmx4g
7170
-XX:MaxMetaspaceSize=256m
7271
-XX:ParallelGCThreads=8

src/main/java/su/interference/core/DataChunk.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ this software and associated documentation files (the "Software"), to deal in
4343
import java.util.Map;
4444
import java.util.concurrent.atomic.AtomicInteger;
4545

46-
import static su.interference.persistent.Table.SYSTEM_PKG_PREFIX;
47-
4846
/**
4947
* @author Yuriy Glotanov
5048
* @since 1.0
@@ -355,7 +353,7 @@ public DataChunk (byte[] b, int file, long frame, int hsize, Table t, Class c)
355353
this.chunk = bsc.getBytes();
356354
}
357355

358-
//constructor for clone method - de-serialize chunk only without header
356+
//constructor for clone method - de-serialize chunk only without header
359357
public DataChunk (byte[] b, Table t, RowHeader h, DataChunk source) {
360358
this.chunk = b;
361359
this.header = h;
@@ -695,13 +693,13 @@ public DataChunk cloneEntity(Session s) throws InternalException {
695693
return dc_;
696694
}
697695

698-
public DataChunk restore(UndoChunk uc) throws Exception {
696+
public DataChunk restore(UndoChunk uc, Session s, LLT llt) throws Exception {
699697
// since we are using a dirty hack with changing the header in a source chunk for rollback his,
700698
// we need to first delete the source chunk in the target block to prevent inconsistency within ChunkMap / chunk headers
701699
if (!(this.getHeader().getRowID().getFileId() == uc.getFile() && this.getHeader().getRowID().getFramePointer() == uc.getFrame())) {
702700
final long srcFrameId = uc.getFile() + uc.getFrame();
703701
final Frame srcFrame = Instance.getInstance().getFrameById(srcFrameId).getFrame();
704-
srcFrame.removeChunk(uc.getPtr(), null, true);
702+
srcFrame.removeChunk(uc.getPtr(), llt, true);
705703
}
706704
return this;
707705
}
@@ -727,7 +725,6 @@ public void setHeader(Header header) {
727725
}
728726

729727
//lock mechanism
730-
731728
private synchronized DataChunk insertUC (UndoChunk uc, Session s, LLT llt) throws Exception {
732729
final WaitFrame ubw = s.getTransaction().getAvailableFrame(uc, true);
733730
final FrameData ub = ubw.getBd();
@@ -827,13 +824,12 @@ protected void cleanUpIcs() {
827824
}
828825

829826
public DataChunk getIc(IndexDescript ids, Session s) throws Exception {
830-
final Table ixt = Instance.getInstance().getTableByName(SYSTEM_PKG_PREFIX + ids.getName());
831-
final DataChunk ic = this.ics.get(ixt.getObjectId());
827+
final DataChunk ic = this.ics.get(ids.getIndex().getObjectId());
832828
if (ic == null) {
833829
final ValueSet key = this.getValueByColumnName(ids.getColumns(), s);
834-
final DataChunk ic_ = ixt.getObjectByKey(key, s);
830+
final DataChunk ic_ = ids.getIndex().getObjectByKey(key, s);
835831
if (ic_ != null) {
836-
this.ics.put(ixt.getObjectId(), ic_);
832+
this.ics.put(ids.getIndex().getObjectId(), ic_);
837833
return ic_;
838834
} else {
839835
throw new RuntimeException("Unable to retrieve index chunk: " + ids.getName());
@@ -842,6 +838,13 @@ public DataChunk getIc(IndexDescript ids, Session s) throws Exception {
842838
return ic;
843839
}
844840

841+
public DataChunk getIcForUpdate(IndexDescript ids, Session s, LLT llt) throws Exception {
842+
final DataChunk ic = getIc(ids, s);
843+
llt.add(ic.getFrameData().getFrame());
844+
this.ics.remove(ids.getIndex().getObjectId());
845+
return getIc(ids, s);
846+
}
847+
845848
public ValueSet getValueByColumnName(String[] columns, Session s) throws Exception {
846849
final Class c = this.getEntity().getClass();
847850
final SystemEntity sa = (SystemEntity)c.getAnnotation(SystemEntity.class);
@@ -874,4 +877,9 @@ public synchronized String getHexByChunk() {
874877
return sb.toString();
875878
}
876879

880+
public FrameData getFrameData() {
881+
final long ptr = this.getHeader().getRowID().getFileId() + this.getHeader().getRowID().getFramePointer();
882+
return Instance.getInstance().getFrameById(ptr);
883+
}
884+
877885
}

src/main/java/su/interference/core/DataFrame.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2019 head systems, ltd
4+
Copyright (c) 2010-2021 head systems, ltd
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy of
77
this software and associated documentation files (the "Software"), to deal in
@@ -130,8 +130,9 @@ public DataFrame(byte[] b, int file, long pointer, Map<Long, Long> imap, Map<Lon
130130
final UndoChunk uc = (UndoChunk)dc.getEntity();
131131
final long allocId = imap.get(uc.getFile() + uc.getFrame());
132132
final long bptr = hmap.get(allocId) != null ? hmap.get(allocId) : Instance.getInstance().getFrameByAllocId(allocId).getFrameId();
133-
uc.setFile((int) bptr % 4096);
134-
uc.setFrame(bptr - (bptr % 4096));
133+
final long fbptr = bptr%4096;
134+
uc.setFile((int) fbptr);
135+
uc.setFrame(bptr - fbptr);
135136
data.add(dc);
136137
ptr = ptr + ROW_HEADER_SIZE + h.getLen();
137138
} else {

src/main/java/su/interference/core/Frame.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2020 head systems, ltd
4+
Copyright (c) 2010-2021 head systems, ltd
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy of
77
this software and associated documentation files (the "Software"), to deal in
@@ -123,14 +123,14 @@ public Frame(int file, long pointer, int size, Table t) {
123123
}
124124

125125
public Frame(FrameData bd, Table t) {
126-
this.file = bd.getFile();
127-
this.pointer = bd.getPtr();
128-
this.allocFile = (int)bd.getAllocId()%4096;
129-
this.allocPointer = bd.getAllocId() - (bd.getAllocId()%4096);
130-
this.rowCntr = 1;
131-
this.frameData = bd;
132-
this.dataObject = t;
133-
this.frameSize = bd.getSize();
126+
this.file = bd.getFile();
127+
this.pointer = bd.getPtr();
128+
this.allocFile = (int)bd.getAllocFile();
129+
this.allocPointer = bd.getAllocPtr();
130+
this.rowCntr = 1;
131+
this.frameData = bd;
132+
this.dataObject = t;
133+
this.frameSize = bd.getSize();
134134
if (this.frameSize<MIN_FRAME_SIZE) {
135135
throw new InternalException();
136136
}
@@ -486,6 +486,10 @@ public synchronized boolean checkChunk(int ptr) {
486486
return data.getByPtr(ptr) != null;
487487
}
488488

489+
public synchronized Chunk getChunkByPtr(int ptr) {
490+
return data.getByPtr(ptr);
491+
}
492+
489493
public synchronized void removeChunk (int ptr, LLT llt, boolean ignore) {
490494
final long sync = LLT.getSyncId();
491495
final Chunk chunk = data.getByPtr(ptr);
@@ -563,6 +567,8 @@ public ArrayList<Chunk> getFrameChunks (Session s) {
563567

564568
public synchronized void rollbackTransaction(Transaction tran, ArrayList<FrameData> ubs, Session s) throws Exception {
565569
data.check();
570+
final LLT llt = LLT.getLLT();
571+
llt.add(this);
566572

567573
//rollback inserted records
568574
final ArrayList<Integer> r = new ArrayList<>();
@@ -585,7 +591,7 @@ public synchronized void rollbackTransaction(Transaction tran, ArrayList<FrameDa
585591
final int ucfile = uc.getDataChunk().getHeader().getRowID().getFileId();
586592
final long frameptr = uc.getDataChunk().getHeader().getRowID().getFramePointer();
587593
if (uc.getTransId() == tran.getTransId() && ucfile == this.file && frameptr == this.pointer) {
588-
final DataChunk rc = uc.getDataChunk().restore(uc);
594+
final DataChunk rc = uc.getDataChunk().restore(uc, s, llt);
589595
if (this instanceof IndexFrame && rc.getExistingEntity() != null) {
590596
((IndexChunk) rc.getExistingEntity()).setDataChunk(null);
591597
}
@@ -594,8 +600,6 @@ public synchronized void rollbackTransaction(Transaction tran, ArrayList<FrameDa
594600
}
595601
}
596602
}
597-
final LLT llt = LLT.getLLT();
598-
llt.add(this);
599603
llt.commit();
600604
}
601605

src/main/java/su/interference/core/IndexChunk.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2020 head systems, ltd
4+
Copyright (c) 2010-2021 head systems, ltd
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy of
77
this software and associated documentation files (the "Software"), to deal in
@@ -32,6 +32,7 @@ this software and associated documentation files (the "Software"), to deal in
3232
public interface IndexChunk {
3333

3434
DataChunk getDataChunk();
35+
DataChunk getDataChunkForUpdate(LLT llt);
3536
RowId getFramePtrRowId();
3637
void setDataChunk(DataChunk c);
3738
void setFramePtrRowId(RowId r);

src/main/java/su/interference/core/IndexDescript.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2019 head systems, ltd
4+
Copyright (c) 2010-2021 head systems, ltd
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy of
77
this software and associated documentation files (the "Software"), to deal in
@@ -31,18 +31,22 @@ this software and associated documentation files (the "Software"), to deal in
3131
import java.util.ArrayList;
3232
import java.lang.reflect.Field;
3333

34+
import static su.interference.persistent.Table.SYSTEM_PKG_PREFIX;
35+
3436
/**
3537
* @author Yuriy Glotanov
3638
* @since 1.0
3739
*/
3840

3941
public class IndexDescript {
4042

41-
private final Table t;
42-
private final String name;
43+
private final Table t;
44+
private final Table index;
45+
private final String name;
46+
private final String className;
4347
private final String[] columns;
44-
private final Field[] fields;
45-
private final boolean unique;
48+
private final Field[] fields;
49+
private final boolean unique;
4650

4751
public IndexDescript(Table t, String name, String columns, boolean unique) throws InternalException {
4852
this.t = t;
@@ -67,6 +71,8 @@ public IndexDescript(Table t, String name, String columns, boolean unique) throw
6771
}
6872

6973
this.name = name;
74+
this.className = SYSTEM_PKG_PREFIX + name;
75+
this.index = Instance.getInstance().getTableByName(this.className);
7076
this.columns = cs.toArray(new String[]{});
7177
this.fields = fs.toArray(new Field[]{});
7278
this.unique = unique;
@@ -88,6 +94,10 @@ public Table getT() {
8894
return t;
8995
}
9096

97+
public Table getIndex() {
98+
return index;
99+
}
100+
91101
public boolean isUnique() {
92102
return unique;
93103
}

src/main/java/su/interference/core/IndexFrame.java

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2020 head systems, ltd
4+
Copyright (c) 2010-2021 head systems, ltd
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy of
77
this software and associated documentation files (the "Software"), to deal in
@@ -127,6 +127,8 @@ public IndexFrame(byte[] b, int file, long pointer, Map<Long, Long> imap, Map<Lo
127127
@Override
128128
public synchronized void rollbackTransaction(Transaction tran, ArrayList<FrameData> ubs, Session s) throws Exception {
129129
data.check();
130+
final LLT llt = LLT.getLLT();
131+
llt.add(this);
130132
final Map<Integer, DataChunk> ucmap = new HashMap();
131133

132134
if (ubs!=null) {
@@ -143,20 +145,29 @@ public synchronized void rollbackTransaction(Transaction tran, ArrayList<FrameDa
143145
}
144146

145147
//rollback modified index records
148+
final ArrayList<Integer> r = new ArrayList<>();
146149
for (Chunk c : data.getChunks()) {
147150
if (c.getHeader().getTran().getTransId() == tran.getTransId()) {
148151
final DataChunk dc = ucmap.get(c.getHeader().getPtr());
149-
final DataChunk dc_ = ((IndexChunk) c.getEntity()).getDataChunk().getUndoChunk().getDataChunk();
150-
((DataChunk) c).setUndoChunk(null);
151-
((DataChunk) c).cleanUpIcs();
152-
((IndexChunk)c.getEntity()).setDataChunk(dc_);
153-
((IndexChunk)c.getEntity()).setFramePtrRowId(dc_.getHeader().getRowID());
154-
((DataChunk)c).getHeader().setFramePtr(dc_.getHeader().getRowID());
152+
if (dc != null) {
153+
final DataChunk dc_ = ((IndexChunk) c.getEntity()).getDataChunk().getUndoChunk().getDataChunk();
154+
((DataChunk) c).setUndoChunk(null);
155+
((DataChunk) c).cleanUpIcs();
156+
((IndexChunk) c.getEntity()).setDataChunk(dc_);
157+
((IndexChunk) c.getEntity()).setFramePtrRowId(dc_.getHeader().getRowID());
158+
((DataChunk) c).getHeader().setFramePtr(dc_.getHeader().getRowID());
159+
c.getHeader().setState(Header.RECORD_NORMAL_STATE);
160+
} else {
161+
if (c.getHeader().getState() == Header.RECORD_NORMAL_STATE) {
162+
r.add(c.getHeader().getPtr());
163+
}
164+
}
155165
}
156166
}
167+
for (Integer i : r) {
168+
data.removeByPtr(i);
169+
}
157170

158-
final LLT llt = LLT.getLLT();
159-
llt.add(this);
160171
llt.commit();
161172
}
162173

@@ -445,7 +456,8 @@ public synchronized long getLcId() {
445456
}
446457

447458
public synchronized void setLcId(long lcId) {
448-
this.setRes05((int)lcId%4096);
449-
this.setRes07(lcId - lcId%4096);
459+
final long lcF = lcId%4096;
460+
this.setRes05((int)lcF);
461+
this.setRes07(lcId - lcF);
450462
}
451463
}

0 commit comments

Comments
 (0)