Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vsam APIs call back twice with one error not readable when receiving SIGTERM #10

Open
tangthth opened this issue Sep 18, 2018 · 0 comments

Comments

@tangthth
Copy link

Issue Description:

When receiving SIGTERM, vsam APIs call back twice with one error not readable.

Reproduce Steps:

  1. write a nodejs script to allocate one data set, write a record, and then update the record in the data set cyclically until it receives SIGTERM. To avoid core dump in Issue 6, close and reopen the data set before updating the record. In its SIGTERM handler, write a new record into the data set.
  2. execute the script, and after several seconds send SIGTERM to it
    <=== vsamObj.write() is called back twice, one is successful and the other reports error "[object Object]"
  3. close and deallocate the data set to clean up environment. Change the nodejs script to close and deallocate the data set in its SIGTERM handler
  4. execute the script again, and after several seconds send SIGTERM to it
    <=== vsamObj.deallocate() is called back twice. No any error reported here, probably due to vasmObj.close() misses the error callback.

Logs:

For Step 2:
/u/usra/workdir/nodejs/nodejs.test.vsam_1.0.0/scripts:>node test_vsam.js &
[1] 50398990
/u/usra/workdir/nodejs/nodejs.test.vsam_1.0.0/scripts:>New vsam dataset allocated: USRA.NODEJSAT.VSAMWKLD
Writing record done. Record key: 00001
Closed the vsam dataset.
Open the vsam dataset: USRA.NODEJSAT.VSAMWKLD

/u/usra/workdir/nodejs/nodejs.test.vsam_1.0.0/scripts:>node sigterm_send.js 50398990
Send SIGTERM to process: 50398990
Received SIGTERM.
Number of vsamUpdate loops not executed before SIGTERM: 797948
Error in writing Record. Record key: 00002
The error is: [object Object]
Writing record done. Record key: 00002
[1]+ Done node test_vsam.js
/u/usra/workdir/nodejs/nodejs.test.vsam_1.0.0/scripts:>

For Step 4:
/u/usra/workdir/nodejs/nodejs.test.vsam_1.0.0/scripts:>node test_vsam.js &
[1] 83952921
/u/usra/workdir/nodejs/nodejs.test.vsam_1.0.0/scripts:>New vsam dataset allocated: USRA.NODEJSAT.VSAMWKLD
Writing record done. Record key: 00001
Closed the vsam dataset.
Open the vsam dataset: USRA.NODEJSAT.VSAMWKLD

/u/usra/workdir/nodejs/nodejs.test.vsam_1.0.0/scripts:>node sigterm_send.js 83952921
Send SIGTERM to process: 83952921
Received SIGTERM.
Number of vsamUpdate loops not executed before SIGTERM: 796775
Closed the vsam dataset.
Deallocated the vsam dataset.
Deallocated the vsam dataset.
/u/usra/workdir/nodejs/nodejs.test.vsam_1.0.0/scripts:>

Reference:

main code for Step 2:

// allocate a new VSAM dataset, write one record, close the dataset, open the dataset, find and update the record 1000000 times
vsamWorkload()

process.on('SIGTERM', function() {
console.log("Received SIGTERM.")
console.log("Number of vsamUpdate loops not executed before SIGTERM: " + loopCount)
var recordTemp ={"key": "00002", "name": "CICSUSRGHI", "gender": "MALEGROUP2"}

vsamObj.write(recordTemp, function(err) {
if (err !=null) {
console.log("Error in writing Record.  Record key: " + recordTemp.key)
console.error("The error is: " + err)
}
else {
console.log("Writing record done.  Record key: " + recordTemp.key) 
}
})
})

main code for Step 4:

// allocate a new VSAM dataset, write one record, close the dataset, open the dataset, find and update the record 1000000 times
vsamWorkload()

process.on('SIGTERM', function() {
console.log("Received SIGTERM.")
console.log("Number of vsamUpdate loops not executed before SIGTERM: " + loopCount)
var recordTemp ={"key": "00002", "name": "CICSUSRGHI", "gender": "MALEGROUP2"}

vsamObj.close(function(err) { 
if (err != null) {
// Note: vsam.js issue.  No callback for vsamObj.close() even when there is error.
console.log("Error in closing vsam dataset.")
console.error("The error is: " + err)
}
else {
// Note: Probably vsam.js issue.  No callback for vsamObj.close() when there is no error, different from other vsam.js APIs.
}
})
console.log("Closed the vsam dataset.")

vsamObj.dealloc(function (err) {
if (err != null) {
console.log("Error in deallocating vsam dataset.")
console.error("The error is: " + err)
}
else {
console.log("Deallocated the vsam dataset.")
}
})

})

main code to send SIGTERM:

targetPid = process.argv[2]
console.log("Send SIGTERM to process: " + targetPid)
process.kill(targetPid, 'SIGTERM')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant