MySQL deadlock. How to exactly find the cause - innodb

When I key command "SHOW ENGINE INNODB STATUS\g;" to show the status. I found there is deadlock. It indicates the deadlock occurs in table TaskInfo. But what is "HT_TaskInfo"? I did not create this table. Will anybody kindly explain me what exactly caused the deadlock?
------------------------
LATEST DETECTED DEADLOCK
------------------------
141009 22:55:13
*** (1) TRANSACTION:
TRANSACTION 0 333298183, ACTIVE 1 sec, OS thread id 5628 starting index read
mysql tables in use 1, locked 1
LOCK WAIT 2 lock struct(s), heap size 368, 1 row lock(s)
MySQL thread id 4591, query id 1071477 10.0.0.4 ptrackUser Updating
update TaskInfo set actualHB='2014-10-09 22:56:00', actualHO='2014-10-09 22:55:05', assignee_username='7438', assigner_username='P0041057', basi
Task_id=19429, clientQualityRequirement=null, confirmscore=0.0, createDate='2014-10-08 10:02:45', creater='7438', deliverables=null, dis_id=null
hipmStatus=null, instruction=null, isnewHipmTask=0, isrework=0, jobBatch_id=null, ongoing=0, parentTask=41641, plannedHB='2014-10-09 09:00:00',
plannedHO='2014-10-08 10:03:00', reason=null, reworkTaskId=null, score=null, sourceFilePath=null, status=2, subType=0, taskBatch_id=88410, taskC
de=null, type='1', unit='Words', volume=1661.0 where taskId=41878
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 689799 n bits 176 index `PRIMARY` of table `ptrack`.`taskinfo` trx id 0 333298183 lock_mode X locks rec but not
ap waiting
Record lock, heap no 108 PHYSICAL RECORD: n_fields 37; compact format; info bits 0
0: len 4; hex 8000a396; asc ;; 1: len 6; hex 000013ddb9f6; asc ;; 2: len 7; hex 00000634cc0938; asc 4 8;; 3: len 4; hex 00a0cf44;
asc D;; 4: SQL NULL; 5: len 8; hex 8000125171b34721; asc Qq G!;; 6: SQL NULL; 7: SQL NULL; 8: SQL NULL; 9: len 8; hex 8000125171b135d0; as
Qq 5 ;; 10: len 8; hex 8000125171a21bcc; asc Qq ;; 11: len 4; hex 80000001; asc ;; 12: len 1; hex 31; asc 1;; 13: len 5; hex 576f72
473; asc Words;; 14: len 4; hex 37343338; asc 7438;; 15: len 4; hex 80004be5; asc K ;; 16: SQL NULL; 17: SQL NULL; 18: SQL NULL; 19: len 4; he
8000a2a9; asc ;; 20: len 8; hex 5030303431303537; asc P0041057;; 21: SQL NULL; 22: len 4; hex 8001595a; asc YZ;; 23: len 1; hex 80; asc
; 24: len 8; hex 8000125171a21b95; asc Qq ;; 25: len 4; hex 37343338; asc 7438;; 26: len 4; hex 80000000; asc ;; 27: SQL NULL; 28: SQL
ULL; 29: SQL NULL; 30: len 1; hex 80; asc ;; 31: SQL NULL; 32: len 1; hex 80; asc ;; 33: SQL NULL; 34: len 4; hex 00000000; asc ;; 35: SQL
NULL; 36: SQL NULL;
*** (2) TRANSACTION:
TRANSACTION 0 333298182, ACTIVE 1 sec, OS thread id 5596 fetching rows, thread declared inside InnoDB 419
mysql tables in use 2, locked 2
423 lock struct(s), heap size 47088, 36018 row lock(s), undo log entries 1
MySQL thread id 4589, query id 1071475 10.0.0.4 ptrackUser Sending data
update TaskInfo set hipmStatus='FAIL' where (taskId) IN (select taskId from HT_TaskInfo)
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 0 page no 689799 n bits 176 index `PRIMARY` of table `ptrack`.`taskinfo` trx id 0 333298182 lock mode S locks rec but not
ap
Record lock, heap no 108 PHYSICAL RECORD: n_fields 37; compact format; info bits 0
0: len 4; hex 8000a396; asc ;; 1: len 6; hex 000013ddb9f6; asc ;; 2: len 7; hex 00000634cc0938; asc 4 8;; 3: len 4; hex 00a0cf44;
asc D;; 4: SQL NULL; 5: len 8; hex 8000125171b34721; asc Qq G!;; 6: SQL NULL; 7: SQL NULL; 8: SQL NULL; 9: len 8; hex 8000125171b135d0; as
Qq 5 ;; 10: len 8; hex 8000125171a21bcc; asc Qq ;; 11: len 4; hex 80000001; asc ;; 12: len 1; hex 31; asc 1;; 13: len 5; hex 576f72
473; asc Words;; 14: len 4; hex 37343338; asc 7438;; 15: len 4; hex 80004be5; asc K ;; 16: SQL NULL; 17: SQL NULL; 18: SQL NULL; 19: len 4; he
8000a2a9; asc ;; 20: len 8; hex 5030303431303537; asc P0041057;; 21: SQL NULL; 22: len 4; hex 8001595a; asc YZ;; 23: len 1; hex 80; asc
; 24: len 8; hex 8000125171a21b95; asc Qq ;; 25: len 4; hex 37343338; asc 7438;; 26: len 4; hex 80000000; asc ;; 27: SQL NULL; 28: SQL
ULL; 29: SQL NULL; 30: len 1; hex 80; asc ;; 31: SQL NULL; 32: len 1; hex 80; asc ;; 33: SQL NULL; 34: len 4; hex 00000000; asc ;; 35: SQL
NULL; 36: SQL NULL;
*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 689799 n bits 176 index `PRIMARY` of table `ptrack`.`taskinfo` trx id 0 333298182 lock_mode X waiting
Record lock, heap no 108 PHYSICAL RECORD: n_fields 37; compact format; info bits 0
0: len 4; hex 8000a396; asc ;; 1: len 6; hex 000013ddb9f6; asc ;; 2: len 7; hex 00000634cc0938; asc 4 8;; 3: len 4; hex 00a0cf44;
asc D;; 4: SQL NULL; 5: len 8; hex 8000125171b34721; asc Qq G!;; 6: SQL NULL; 7: SQL NULL; 8: SQL NULL; 9: len 8; hex 8000125171b135d0; as
Qq 5 ;; 10: len 8; hex 8000125171a21bcc; asc Qq ;; 11: len 4; hex 80000001; asc ;; 12: len 1; hex 31; asc 1;; 13: len 5; hex 576f72
473; asc Words;; 14: len 4; hex 37343338; asc 7438;; 15: len 4; hex 80004be5; asc K ;; 16: SQL NULL; 17: SQL NULL; 18: SQL NULL; 19: len 4; he
8000a2a9; asc ;; 20: len 8; hex 5030303431303537; asc P0041057;; 21: SQL NULL; 22: len 4; hex 8001595a; asc YZ;; 23: len 1; hex 80; asc
; 24: len 8; hex 8000125171a21b95; asc Qq ;; 25: len 4; hex 37343338; asc 7438;; 26: len 4; hex 80000000; asc ;; 27: SQL NULL; 28: SQL
ULL; 29: SQL NULL; 30: len 1; hex 80; asc ;; 31: SQL NULL; 32: len 1; hex 80; asc ;; 33: SQL NULL; 34: len 4; hex 00000000; asc ;; 35: SQL
NULL; 36: SQL NULL;
*** WE ROLL BACK TRANSACTION (1)

Related

Using CD74HC4067 16-Channel Analog Multiplexer Demultiplexer is not working as expected

I am working on a project that needs multiple digital signals and I am considering the CD74HC4067 (on a break-board) to work as a multiplexer. More specifically i am trying to build a keypad with multiple ttp123 break-boards. Each ttp123 signal is connected to one of the 0-15 pins of the CD74HC4067. The S0-S3 pins are connected to digital Pins 7-4 on a pro mini. Signal is on A0 and EN is on A1. A1 and EN have a 4K7 resistor to ground. I power the setup with a separate 5v and the arduino is connected on a pc usb port.
I expect when a ttp123 is pressed to trigger a HIGH and this event to be passed to SIG pin.
Here is my code:
//Using CD74HC4067 16-Channel Analog Multiplexer
//Mux control pins
int s0 = 6;
int s1 = 7;
int s2 = 8;
int s3 = 9;
//Mux in "SIG" pin
int SIG_pin = A0;
int EN_pin = A1;
void setup(){
pinMode(s0, OUTPUT);
pinMode(s1, OUTPUT);
pinMode(s2, OUTPUT);
pinMode(s3, OUTPUT);
pinMode(EN_pin, OUTPUT);
digitalWrite(s0, LOW);
digitalWrite(s1, LOW);
digitalWrite(s2, LOW);
digitalWrite(s3, LOW);
digitalWrite(EN_pin, LOW);
Serial.begin(9600);
Serial.println("keypad interfacing_CD74HC4067 starting...");
}
void loop(){
String a;
//digitalWrite(EN_pin, HIGH);
Serial.println(" press any key to continue ...");
//digitalWrite(EN_pin, LOW);
while (!Serial.available());
while(Serial.available()) {
//Loop through and read all 16 values
for(int i = 0; i < 16; i ++){
//Serial.print("Value at channel ");
//Serial.print(i);
//Serial.print("is : ");
//Serial.println(readMux(i));
float volts = readMux(i);
Serial.print("Value at channel ");
Serial.print(i);
Serial.print(" is : ");
Serial.print(volts);
Serial.println();
//delay(1000);
}
a= Serial.readString();// read the incoming data as string
}
}
float readMux(int channel){
int controlPin[] = {s0, s1, s2, s3};
int muxChannel[16][4]={
{0,0,0,0}, //channel 0
{1,0,0,0}, //channel 1
{0,1,0,0}, //channel 2
{1,1,0,0}, //channel 3
{0,0,1,0}, //channel 4
{1,0,1,0}, //channel 5
{0,1,1,0}, //channel 6
{1,1,1,0}, //channel 7
{0,0,0,1}, //channel 8
{1,0,0,1}, //channel 9
{0,1,0,1}, //channel 10
{1,1,0,1}, //channel 11
{0,0,1,1}, //channel 12
{1,0,1,1}, //channel 13
{0,1,1,1}, //channel 14
{1,1,1,1} //channel 15
};
//loop through the 4 sig
for(int j = 0; j < 4; j ++){
digitalWrite(controlPin[j], muxChannel[channel][j]);
}
//read the value at the SIG pin
int val = analogRead(SIG_pin);
//return the value
float voltage = (val * 5) / 1024.0;
return voltage;
}
Just for simplicity, I have connected only one ttp123 on the system, ttp123 signal to channel12 on 74HC4067. With ttp123 touched, I would expect to get a high on SIG when I write
{0,0,1,1}, to S0-S3. All other channels should be LOW. However here is what I get:
On my first run after boot:
press any key to continue ...
Value at channel 0 is : 2.53
Value at channel 1 is : 2.58
Value at channel 2 is : 2.53
Value at channel 3 is : 2.60
Value at channel 4 is : 2.51
Value at channel 5 is : 2.55
Value at channel 6 is : 2.50
Value at channel 7 is : 2.52
Value at channel 8 is : 2.42
Value at channel 9 is : 2.47
Value at channel 10 is : 2.43
Value at channel 11 is : 2.50
Value at channel 12 is : 2.40
Value at channel 13 is : 2.43
Value at channel 14 is : 2.38
Value at channel 15 is : 2.44
and then all channels seem to lower...
press any key to continue ...
Value at channel 0 is : 1.70
Value at channel 1 is : 1.76
Value at channel 2 is : 1.71
Value at channel 3 is : 1.78
Value at channel 4 is : 1.70
Value at channel 5 is : 1.76
Value at channel 6 is : 1.72
Value at channel 7 is : 1.77
Value at channel 8 is : 1.67
Value at channel 9 is : 1.72
Value at channel 10 is : 1.69
Value at channel 11 is : 1.76
Value at channel 12 is : 1.69
Value at channel 13 is : 1.73
Value at channel 14 is : 1.67
Value at channel 15 is : 1.74
and I get no HIGH on channel 12 as I should.
Is there a need for a pullup or pulldown resistors in this setup? Should I connect a resistor to each S0-S3 with ground? Why is this not working?
Since there was an elementary failure in the code as well I would like to post the solution in here:
I had failed to initialize the A0 pin as input:
pinMode(SIG_pin, INPUT);
Here is the working set of code:
// interfacing mux with tp223
//Mux control pins
const int s0 = 6;
const int s1 = 7;
const int s2 = 8;
const int s3 = 9;
//Mux in "SIG" pin
int SIG_pin = A0;
int EN_pin = 10;
void setup(){
pinMode(s0, OUTPUT);
pinMode(s1, OUTPUT);
pinMode(s2, OUTPUT);
pinMode(s3, OUTPUT);
pinMode(SIG_pin, INPUT);
pinMode(EN_pin, OUTPUT);
digitalWrite(s0, LOW);
digitalWrite(s1, LOW);
digitalWrite(s2, LOW);
digitalWrite(s3, LOW);
digitalWrite(EN_pin, LOW);
Serial.begin(115200);
Serial.println("keypad interfacing_CD74HC4067 starting...");
}
void loop(){
//Loop through and read all 16 values
for(int i = 0; i < 16; i ++){
int val = readMux(i);
if (val > 0) {
Serial.print(i);
Serial.print(" pressed ");
Serial.print(val);
Serial.println();
}
}
}
float readMux(int channel){
int controlPin[] = {s0, s1, s2, s3};
int muxChannel[16][4]={
{0,0,0,0}, //channel 0
{1,0,0,0}, //channel 1
{0,1,0,0}, //channel 2
{1,1,0,0}, //channel 3
{0,0,1,0}, //channel 4
{1,0,1,0}, //channel 5
{0,1,1,0}, //channel 6
{1,1,1,0}, //channel 7
{0,0,0,1}, //channel 8
{1,0,0,1}, //channel 9
{0,1,0,1}, //channel 10
{1,1,0,1}, //channel 11
{0,0,1,1}, //channel 12
{1,0,1,1}, //channel 13
{0,1,1,1}, //channel 14
{1,1,1,1} //channel 15
};
//loop through the 4 sig
for(int j = 0; j < 4; j ++){
digitalWrite(controlPin[j], muxChannel[channel][j]);
}
//read the value at the SIG pin
int val = digitalRead(SIG_pin);
//return the value
return val;
}
I would like to mention that there was a cabling issue as well. I pulled down the signal pin with a 10k resistor.

GLPSOL Problem within the Operation Research field

For a couple of months now, I am trying to solve an operational research model with glpk on a mac. The thing is that I have searched throughout the internet and also I have tried to find help in universities based in Athens Greece but it seems that noone has a clue regarding the specific program. So, my MODEL is the following:
#PARAMETERS
#
param P;
param D;
param S;
param R;
param B;
param LS;
param CLNGs;
param Tp;
param H;
param Frest;
param MA;
param f;
param Cvr {1..B};
param Cvf {1..B};
param Vv {1..B};
param Qv {1..B};
param Demand {1..R};
param d {1..P, 1..D};
# VARIABLES
#
var z{1..B} >=0, integer;
var x{1..P,1..R,1..B,1..S,1..D} >=0, continuous;
var y{1..P,1..B,1..R,1..S,1..D} >=0, integer;
# OBJECTIVE FUNCTION
#
minimize F {p<>m}: sum {p in 1..P} sum {m in 1..D}
sum {v in 1..B}Cf[v]*d[p,m]*y[p,m,v] + H* sum {v in 1..B} Cr[v]*z[v] +
sum {s in 1..S} sum {r in 1..R} sum {v in 1..B} CLNG[s]*Q[v]*x[s,r,v];
# CONSTRAINTS
#
s.t. constr1 {r in 1..R, r<>p, r<>m }: sum {p in 1..P}
sum {v in 1..B}Q[v]*x[p,r,v] - sum{m in 1..D}
sum{v in 1..B}Q[v]*x[r,m,v] >=Demand[r];
s.t. constr2 {p in 1..P, r in 1..R, v in 1..B}: y[p,r,v] >= x[p,r,v];
s.t. constr3 { r in 1..R, v in 1..B}:
sum {p in 1..P} x[p,r,v] >= sum {m in 1..D} x[r,m,v];
s.t. constr4 { p in 1..P, v in 1..B, p<>m}:
sum {m in 1..D} y[m,p,v] = sum {m in 1..D} y[p,m,v];
s.t. constr5 {v in 1..B, p<>m}: H*z[v] >= 1/V[v] *sum{p in 1..P}
sum{m in 1..D} d[p,m]*y[p,m,v] +
sum{p in 1..P}*(T[p]*sum{m in 1..D}y[p,m,v]);
s.t. constr6 {p in 1..P, r in 1..R, v in 1..B}:
Q[v]*y[p,r,v] <= Frest*y[p,r,v];
s.t. constr7 {v in 1..LS, i<>j}: sum {i in 1..R}
sum {j in 1..R} x[i,j,v] = 0;
s.t. constr8 {s in 1..S}: sum {r in 1..R}
sum {v in 1..V} Q[v]*x[s,r,v] <= MA[s];
s.t. constr9 {s in 1..S, r in 1..R}: x[s,r,v] >= f*y[s,r,v];
end;
And my DATA:
#test comments
param P := 7;
param D := 7;
param S := 3;
param R := 4;
param B := 4;
param LS := 2;
param CLNGs := 200;
param Tp := 24;
param H := 30;
param Frest := 1000000000
param MA := 10000000000
param f :=0.8
param Cvr : 1 :=
1 510000
2 600000
3 700000
4 900000
;
param Cvf : 1 :=
1 22
2 26
3 32
4 42
;
param Vv : 1 :=
1 24
2 26
3 28
4 30
;
param Qv : 1 :=
1 5000
2 7500
3 10000
4 15000
;
param Demand : 1 :=
1 2595.9
2 3781.2
3 1668
4 372.9
;
param d: 1 2 3 4 5 6 7:=
1 0 1663 996 306 291 333 372
2 1663 0 2413 1867 1905 1856 2050
3 996 2413 0 924 938 761 1103
4 306 1867 924 0 107 202 110
5 291 1905 938 107 0 122 184
6 333 1856 761 202 122 0 302
7 372 1050 1103 110 184 302 0
;
end;
When I am trying to run this i get always the following error:
thesis.mod:29: syntax error in variable statement
Context: ..... P , 1 .. R , 1 .. B , 1 .. S , 1 .. D } >= 0 ,continuous
MathProg model processing error
Do you have any ideas on how to solve this?
There is no 'continuous' attribute defined in the var statement of the GMPL language. Variables are by default continuous.
Please, read doc/gmpl.pdf that comes with GLPK.

Order boxes left to right in dot graphviz

I have this gv code,
I want to have the horizontal order :
12 13 14 15 23 24
but I get:
23 13 12 24 14 15
graph "tree" {
node [shape=plaintext];
1 [label = "1"]
2 [label = "2"]
3 [label = "3"]
4 [label = "4"]
5 [label = "5"]
12 [label = "12"]
13 [label = "13"]
14 [label = "14"]
15 [label = "15"]
23 [label = "23"]
24 [label = "24"]
1 -- 12;
2 -- 12;
1 -- 13;
3 -- 13;
1 -- 14;
4 -- 14;
1 -- 15;
5 -- 15;
2 -- 23;
3 -- 23;
2 -- 24;
4 -- 24;}
the solution : Force the left to right order of nodes in graphviz? did not work for this case (ordering nodes not edges).
If I add :
{rank = same; 12 13 14 15 23 24; rankdir=LR;}
We get the same unordered nodes:
png file made with:
dot -T png test.gv > test.png
Or more simply:
graph "tree" {
node[shape=plaintext]
1 -- {12 13 14 15}
2 -- {12 23 24}
3 -- {13 23}
4 -- {14 24}
5 -- 15;
{
rank = same;
12 -- 13 -- 14 -- 15 -- 23 -- 24 [color=invis]
}
}
Simplest is to add 'invisible' (white on white, no arrows) edges.
This will encourage dot to align the nodes in order.
graph "tree" {
node [shape=plaintext];
1 [label = "1"]
2 [label = "2"]
3 [label = "3"]
4 [label = "4"]
5 [label = "5"]
12 [label = "12"]
13 [label = "13"]
14 [label = "14"]
15 [label = "15"]
23 [label = "23"]
24 [label = "24"]
1 -- 12;
2 -- 12;
1 -- 13;
3 -- 13;
1 -- 14;
4 -- 14;
1 -- 15;
5 -- 15;
2 -- 23;
3 -- 23;
2 -- 24;
4 -- 24;
// 'white' (invisible on white background) edges, weight to encourage order
// results in tidiest graph with horizontal nodes in desired order.
edge [color=white,weight=4,arrowhead=none,arrowtail=none];
12 -- 13 -- 14 -- 15 -- 23 -- 24 -- 25 -- 34 -- 35 -- 45;
{rank = same; 12 13 14 15 23 24 25 34 35 45; rankdir=LR;}
}

Calculate decimal value related to 4 byte hex array

I am looking through a field of bytes with hex values. The first 4 bytes map to one real-Value, a number. Now I need to know what decimal value it stands for and how to get this information?
ByteA = '12'; that means '18' in dec;
ByteB = '01'; that means '1' in dec;
ByteC = '00'; that means '0' in dec;
ByteD = '00'; that means '0' in dec;
Each byte gets multiplied by 256 ^ the position in the field, so it could be either:
Big-endian (most significant byte first)
18 * 256 ^ 3 = 301,989,888
1 * 256 ^ 2 = 65,536
0 * 256 ^ 1 = 0
0 * 256 ^ 0 = 0
-----------
302,055,424
Little-endian:
0 * 256 ^ 3 = 0
0 * 256 ^ 2 = 0
1 * 256 ^ 1 = 256
18 * 256 ^ 0 = 18
-----------
274
Most programming languages have built-in hex to decimal capabilities.

Interpretation of double inequality in SAS

I wrote
do while (A<=B<=C);...;end
and I did not obtain what I expected (which is A<=B and B<=C). So how does SAS interpret the expression A<=B<=C ? Note: SAS did not give an error for A<=B<=C.
I believe it evaluates left to right:
(A <= B) <= C
A <= B evaluates to 0 or 1. This value is then compared to C.
This works as you expect in a Data Step. It does not work in PROC IML.
1189 data _null_;
1190 a = 10;
1191 b = 10;
1192 c = 15;
1193
1194 do while(a<=b<=c);
1195 put b=;
1196 b = b + 1;
1197 /*Abort if this runs away*/
1198 if b > 20 then
1199 stop;
1200 end;
1201 run;
b=10
b=11
b=12
b=13
b=14
b=15
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
1203 proc iml;
NOTE: IML Ready
1204 a = 10;
1205 b = 10;
1206 c = 15;
1207 file log;
1208
1209 do while (a<=b<=c);
1210 put "B=" b;
1211 b = b+1;
1212
1213 if b>20 then stop;
1214 end;
B= 10
B= 11
B= 12
B= 13
B= 14
B= 15
B= 16
B= 17
B= 18
B= 19
B= 20
1215 quit;
NOTE: Exiting IML.
NOTE: PROCEDURE IML used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
IML has slightly different logical syntax than Base SAS. In IML, use
do while ( (a<=b) & (b<=c));

Resources