How Long Can You Stay in Space, and What Happens if You Stay Too Long?

The longest contiguous amount of time a human has spent in space is 437 days. That was done by Valeri Polyakov, almost twenty years ago. Sergei Krikalev, over six flights, has spent 803 days in space. Space is a harsh environment for humans. Systems throughout our body have evolved to function under the stresses of gravity.
Our muscles are constantly working against gravity on Earth. Those muscles have less work to do in space, and so they atrophy, waste away. That includes the heart, which shrinks a little, the neck muscles that hold up our heads, and our calves.
Since our bones are not experiencing the loads they experience on the ground, they feel no need to maintain themselves. Bone tissue is absorbed and not rebuilt. This absorbed bone can cause kidney stones. The places where the bone has weakened can easily fracture.
There is evidence that extended periods in space can result in dysregulation of the immune system. While there isn’t too much risk of exposure to pathogens, a compromised immune system can result in autoimmune responses and hypersensitivity.
Aside from the deleterious affects of microgravity, a potentially larger threat is radiation. We take for granted how much our planet protects us from radiation. Out in space, astronauts are exposed to galactic cosmic radiation, solar radiation, solar cosmic particles, and geomagnetically bound radiation. This radiation is so prevalent that when astronauts close their eyes, they often “see” bright flashes, as cosmic rays hit their optic nerves.
Radiation exposure can result in cell death or can cause mutations that result in cancers or epigenetic effects. Some systems are quite sensitive to radiation and their functions can become impaired, such as the immune system and the bone marrow system and the eyes, resulting in cataracts.
We do our best to provide shielding, but paradoxically, shielding can result in more exposure by what is called secondary radiation. When an energetic particle hits the shielding material it can emit gamma rays and energetic neutrons.
NASA takes astronaut radiation exposure very seriously. When they hit the allowed threshold, they can be prohibited from flying again.