KX Community

Find answers, ask questions, and connect with our KX Community around the world.

Home Forums kdb+ kdb version 4.0 changes to port?

Tagged: , , ,

  • kdb version 4.0 changes to port?

    Posted by mmv456 on April 10, 2024 at 4:12 pm

    Hello, I am switching to version 4.0 and noticed some of my processes aren’t running due to a handle error, like below:

    'close. OS reports: The handle is invalid.

    [1] C:\s\generateQuery.q:32: produceReport:

    trap: @[{[x] x "exit 0";}; h; `trapped];

    handle_close handle;



    The value of the handle variable is 1104, which I’m guessing is the port. I used to use version 3.5 and it ran fine, but when I switch to 4.0 I get the message above. I am guessing there is some kind of port error or change when I switched to the new version.

    If anyone has any information on this, please let me know. I’m not sure if I was looking at the right documentation regarding ports and any changes.

    mmv456 replied 1 week, 1 day ago 3 Members · 4 Replies
  • 4 Replies
  • pgyorok

    April 10, 2024 at 4:29 pm

    The handle is an OS level file handle, not the port number. In fact it is possible to open multiple connections to the same process and naturally they get different handles.

    Does the handle show up in .z.W before you try to close it?

    Can you check the logs of the remote process to make sure it’s working fine?

    • mmv456

      April 10, 2024 at 4:32 pm

      Thanks for your answer. Unfortunately I’m fairly new to kdb so I will need to take a look to find out more about this. I’ll let you know if I find the answers to your questions. Do you know if there’s anything I can read up on about this?

  • rocuinneagain

    April 10, 2024 at 4:33 pm

    What is the definition of handle_close?

    Trying to close a handle which is already closed will throw that error.

    Since you call exit 0 above the handle will be closed by the process exiting.

    q)hclose 5 //Success first time

    q)hclose 5 //Fails as 5 no longer exists, was closed above

    'close. OS reports: Bad file descriptor

    [0] hclose 5

  • mmv456

    May 14, 2024 at 1:28 pm

    Hello, thank you for your answer. It looks like commenting that out worked. I wonder why that line wasn’t throwing an error when I used the v3.5 version, however. Is v4.0 more sensitive to this? And yes, the handle_close function closes the handle, similar to the “exit 0” command.

Log in to reply.